# HG changeset patch # User rosfran # Date 1164225232 0 # Node ID cf4a26332b8cb24f24278324f496c107153d7584 # Parent f4be69980934d11ab6fa7ee236e9452df0aa7756 [svn r102] Removed unused code, remade buffer fillment in the file transfer read methods. diff -r f4be69980934 -r cf4a26332b8c gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Wed Nov 22 14:37:47 2006 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Wed Nov 22 19:53:52 2006 +0000 @@ -37,6 +37,7 @@ #include "gmyth_livetv.h" #include "gmyth_util.h" #include "gmyth_socket.h" +#include "gmyth_context.h" #include "gmyth_stringlist.h" #include @@ -167,7 +168,7 @@ G_OBJECT_CLASS (gmyth_file_transfer_parent_class)->dispose (object); } - static void +static void gmyth_file_transfer_finalize (GObject *object) { g_signal_handlers_destroy (object); @@ -181,8 +182,7 @@ GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER ( g_object_new ( GMYTH_FILE_TRANSFER_TYPE, FALSE )); - if ( mythtv_version > 0 ) - transfer->mythtv_version = mythtv_version; + transfer->mythtv_version = MYTHTV_CANNOT_NEGOTIATE_VERSION; transfer->card_id = num; @@ -269,7 +269,6 @@ printf("[%s] Running config to the %s...\n", __FUNCTION__, live_tv ? "LiveTV" : "FileTransfer" ); -#if 0 /* configure the control socket */ if ((*transfer)->event_sock == NULL) { @@ -282,8 +281,6 @@ g_warning("Remote transfer control socket already created.\n"); } -#endif - /* configure the socket */ if ( (*transfer)->sock == NULL ) { @@ -293,8 +290,54 @@ g_printerr ("Connection to backend failed (Raw Transfer Socket).\n"); ret = FALSE; } + + GIOChannel* io_channel = (*transfer)->sock->sd_io_ch, + *io_channel_control = (*transfer)->control_sock->sd_io_ch; + GIOCondition io_cond, io_cond_control; + GIOStatus io_status = G_IO_STATUS_NORMAL; + GError *error = NULL; + gchar *trash = NULL; + guint bytes_read = 0; + + io_cond = g_io_channel_get_buffer_condition( io_channel ); + + if ( ( io_cond & G_IO_IN ) != 0 ) { + do + { + trash = g_new0( gchar, GMYTHTV_BUFFER_SIZE ); + + io_status = g_io_channel_read_chars( io_channel, trash, + GMYTHTV_BUFFER_SIZE, &bytes_read, &error); + + g_print( "[%s] cleaning buffer on IO binary channel... %d bytes gone!\n", + __FUNCTION__, bytes_read ); + + if ( trash != NULL ) + g_free( trash ); + + io_cond = g_io_channel_get_buffer_condition( io_channel ); + + } while ( ( io_cond & G_IO_IN ) != 0 && ( io_status != G_IO_STATUS_ERROR ) && (error == NULL) ); + + } + + io_cond_control = g_io_channel_get_buffer_condition( io_channel_control ); + + if ( ( io_cond_control & G_IO_IN ) != 0 ) { + g_print( "[%s] Finishind reading function: cleaning all data on the I/O control socket...\n", __FUNCTION__ ); + while ( gmyth_socket_read_stringlist( (*transfer)->control_sock, strlist ) > 0 ) + { + if ( strlist != NULL && gmyth_string_list_length(strlist) > 0 ) + { + gint backend_code = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error + g_print( "[%s]\t backend code = %d -\t"\ + "[%s prepared for reading]! (G_IO_IN) !!!\n\n", __FUNCTION__, + backend_code, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); + } + } + } - if ( !(*transfer)->live_tv && (*transfer)->control_sock != NULL) { + if ( /*!(*transfer)->live_tv && */ (*transfer)->control_sock != NULL ) { strlist = gmyth_string_list_new(); g_string_printf ( (*transfer)->query, "%s %d", GMYTHTV_QUERY_HEADER, (*transfer)->recordernum ); @@ -330,21 +373,13 @@ //myth_control_acquire_context (TRUE); gchar *path_dir = gmyth_uri_getpath( (*transfer)->uri ); - //g_print( "\t--> %s: path_dir = %s\n", __FUNCTION__, path_dir ); gchar *stype = g_strdup( "" ); - // if ( (*transfer)->live_tv == FALSE ) { - sock = gmyth_socket_new(); gmyth_socket_connect( &sock, (*transfer)->hostname->str, (*transfer)->port ); - /* - } else { - sock = (*transfer)->sock; - } - */ #ifdef GMYTHTV_ENABLE_DEBUG g_print( "[%s] --> Creating socket... (%s, %d)\n", __FUNCTION__, (*transfer)->hostname->str, (*transfer)->port ); @@ -355,7 +390,9 @@ GString *hostname = g_string_new( gmyth_uri_gethost( (*transfer)->uri ) ); GString *base_str = g_string_new( "" ); - if ( gmyth_socket_check_protocol_version_number (sock, (*transfer)->mythtv_version) ) { + if ( (*transfer)->mythtv_version != MYTHTV_CANNOT_NEGOTIATE_VERSION || + ( (*transfer)->mythtv_version = gmyth_socket_check_protocol_version_number (sock, + MYTHTV_VERSION_DEFAULT ) ) != MYTHTV_CANNOT_NEGOTIATE_VERSION ) { if (sock == NULL) { stype = (sock_type==GMYTH_PLAYBACK_TYPE) ? "control socket" : "file data socket"; @@ -374,7 +411,8 @@ if ( sock_type == GMYTH_PLAYBACK_TYPE ) { (*transfer)->control_sock = sock; - g_string_printf( base_str, "ANN Playback %s %d", hostname->str, FALSE ); + + g_string_printf( base_str, "ANN Playback %s %d", hostname->str, FALSE ); gmyth_socket_send_command( (*transfer)->control_sock, base_str ); GString *resp = gmyth_socket_receive_response( (*transfer)->control_sock ); @@ -390,18 +428,22 @@ GString *resp = gmyth_socket_receive_response( (*transfer)->event_sock ); g_print( "[%s] Got Monitor response from %s: %s\n", __FUNCTION__, base_str->str, resp->str ); //g_thread_create( myth_init_io_watchers, (void*)(*transfer), FALSE, NULL ); - g_thread_create( myth_init_io_watchers, (*transfer), FALSE, NULL ); + //g_thread_create( myth_init_io_watchers, (*transfer), FALSE, NULL ); - g_printerr( "[%s] Watch listener function to the IO control channel on thread %p.\n", __FUNCTION__, g_thread_self() ); + g_printerr( "[%s] Watch listener function to the IO control channel on thread %p.\n", + __FUNCTION__, g_thread_self() ); } else if ( sock_type == GMYTH_FILETRANSFER_TYPE ) { (*transfer)->sock = sock; strlist = gmyth_string_list_new(); - g_string_printf( base_str, "ANN FileTransfer %s %d %d", hostname->str, + + if ( gmyth_socket_get_protocol_version( (*transfer)->control_sock ) > 26 ) + g_string_printf( base_str, "ANN FileTransfer %s %d %d", hostname->str, (*transfer)->userreadahead, (*transfer)->retries ); - //g_string_printf( base_str, "ANN FileTransfer %s", hostname->str ); + else + g_string_printf( base_str, "ANN FileTransfer %s", hostname->str ); gmyth_string_list_append_string( strlist, base_str ); gmyth_string_list_append_char_array( strlist, path_dir ); @@ -745,16 +787,8 @@ GIOCondition io_cond; gchar *trash = g_new0( gchar, GMYTHTV_BUFFER_SIZE*10 ); guint recv = 0; - //gchar *msg = g_strdup(""); - while ( !has_io_access ) - g_cond_wait( io_watcher_cond, mutex ); - - //myth_control_acquire_context (TRUE); - - has_io_access = FALSE; - - g_mutex_lock( mutex ); + myth_control_acquire_context (TRUE); gsize len = 0; if (condition & G_IO_HUP) @@ -788,12 +822,7 @@ g_print ("[%s] Error reading: %s\n", __FUNCTION__, error != NULL ? error->message : "" ); g_print ("\n[%s]\tEVENT: Read %d bytes: %s\n\n", __FUNCTION__, len, trash != NULL ? trash : "[no event data]" ); - has_io_access = TRUE; - - //myth_control_release_context( ); - g_cond_broadcast( io_watcher_cond ); - - g_mutex_unlock( mutex ); + myth_control_release_context( ); return TRUE; @@ -872,27 +901,15 @@ GIOCondition io_cond_control; GIOStatus io_status = G_IO_STATUS_NORMAL, io_status_control = G_IO_STATUS_NORMAL; - gint buf_len = GMYTHTV_BUFFER_SIZE; - GMythStringList *strlist = NULL; GError *error = NULL; - gboolean found_backend_msg = FALSE; gchar *trash = g_strdup(""); g_return_val_if_fail ( data != NULL, -2 ); - - #if 0 - while ( !has_io_access ) - g_cond_wait( io_watcher_cond, mutex ); - - has_io_access = FALSE; - #endif - + myth_control_acquire_context (FALSE); - //g_mutex_lock( mutex ); - /* gets the size of the entire file, if the size requested is lesser than 0 */ if ( size <= 0 ) size = transfer->filesize; @@ -900,10 +917,6 @@ io_channel = transfer->sock->sd_io_ch; io_channel_control = transfer->control_sock->sd_io_ch; - //g_io_channel_set_flags( io_channel, G_IO_FLAG_APPEND | - // G_IO_STATUS_AGAIN | G_IO_FLAG_IS_READABLE | G_IO_FLAG_IS_WRITEABLE | - // G_IO_FLAG_IS_SEEKABLE, NULL ); - io_status = g_io_channel_set_encoding( io_channel, NULL, &error ); if ( io_status == G_IO_STATUS_NORMAL ) g_print( "[%s] Setting encoding to binary data socket).\n", __FUNCTION__ ); @@ -926,197 +939,84 @@ goto cleanup; } - /* - if (!controlSock->isOpen() || controlSock->error()) - return -1; - */ - - if ( ( io_cond & G_IO_IN ) != 0 ) { - do - { - trash = g_new0( gchar, GMYTHTV_BUFFER_SIZE ); - - io_status = g_io_channel_read_chars( io_channel, trash, - GMYTHTV_BUFFER_SIZE, &bytes_read, &error); - - g_print( "[%s] cleaning buffer on IO binary channel... %d bytes gone!\n", - __FUNCTION__, bytes_read ); - - if ( trash != NULL ) - g_free( trash ); - - io_cond = g_io_channel_get_buffer_condition( io_channel ); - - } while ( ( io_cond & G_IO_IN ) != 0 && ( io_status != G_IO_STATUS_ERROR ) && (error == NULL) ); - - //if ( trash!= NULL ) - // g_free( trash ); - } - - if ( ( io_cond_control & G_IO_IN ) != 0 ) { - GMythStringList *strlist_tmp = gmyth_string_list_new(); - gmyth_socket_read_stringlist( transfer->control_sock, strlist_tmp ); - g_object_unref( strlist_tmp ); - } - wait_to_transfer = 0; - //g_thread_create( myth_init_io_watchers, (void*)transfer, FALSE, NULL ); - //g_printerr( "[%s] Watch listener function to the IO control channel on thread %p.\n", __FUNCTION__, g_thread_self() ); - - //g_mutex_lock (mutex); - //strlist = gmyth_string_list_new(); - - g_string_printf ( transfer->query, "%s %d", - /*transfer->live_tv ? GMYTHTV_RECORDER_HEADER :*/ GMYTHTV_QUERY_HEADER, - /* transfer->live_tv ? transfer->card_id :*/ transfer->recordernum ); // transfer->recordernum + g_string_printf ( transfer->query, "%s %d", GMYTHTV_QUERY_HEADER, + transfer->recordernum ); // transfer->recordernum g_print( "\t[%s] Transfer_query = %s\n", __FUNCTION__, transfer->query->str ); sent = size; remaining = size - recv; - //g_mutex_unlock( mutex ); - //data = (void*)g_new0( gchar, size ); - //g_mutex_lock( mutex ); + while ( recv < size && !response ) + { - io_cond = g_io_channel_get_buffer_condition( io_channel ); - - if ( ( io_cond_control & G_IO_IN ) != 0 ) { - g_print( "[%s] Finishind reading function: cleaning all data on the I/O control socket...\n", __FUNCTION__ ); - while ( gmyth_socket_read_stringlist( transfer->control_sock, strlist ) > 0 ) - { - if ( strlist != NULL && gmyth_string_list_length(strlist) > 0 ) - { - gint backend_code = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error - g_print( "[%s]\t backend code = %d -\t"\ - "[%s prepared for reading]! (G_IO_IN) !!!\n\n", __FUNCTION__, - backend_code, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); - } - } - } - - while ( recv < size && !response )//&& ( io_cond & G_IO_IN ) != 0 ) - { - //g_io_channel_flush( io_channel_control, NULL ); - gint backend_msg_count = 1; - -resend_request: strlist = gmyth_string_list_new(); gmyth_string_list_append_char_array( strlist, transfer->query->str ); - gmyth_string_list_append_char_array( strlist, - /*transfer->live_tv ? "REQUEST_BLOCK_RINGBUF" :*/ "REQUEST_BLOCK" ); + gmyth_string_list_append_char_array( strlist, "REQUEST_BLOCK" ); gmyth_string_list_append_int( strlist, remaining ); gmyth_socket_write_stringlist( transfer->control_sock, strlist ); - /* iterates until find some non-MythTV backend message */ - do { - gmyth_socket_read_stringlist( transfer->control_sock, strlist ); - if ( strlist != NULL && gmyth_string_list_length( strlist ) > 0 ) - { - if ( gmyth_file_transfer_is_backend_message( transfer, strlist ) ) - { - recv = 0; - sent = 0; - response = FALSE; - found_backend_msg = TRUE; - goto cleanup; - } - else - { - sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error - g_print( "[%s] got SENT buffer message = %d\n", __FUNCTION__, sent ); - if ( sent != 0 ) - { - g_print( "[%s]\t received = %d bytes, backend says %d bytes sent, "\ - "io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, - recv, sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); - - if ( sent == remaining ) - { - g_print( "[%s]\t\tsent %d, which is equals to requested size = %d\n\n", - __FUNCTION__, sent, remaining ); - break; - } - else - { - g_print( "[%s]\t\tsent %d, which is NOT equals to requested size = %d\n\n", - __FUNCTION__, sent, remaining ); - size = remaining = sent; - if ( sent < 0 ) { - if ( --backend_msg_count > 0 ) - goto resend_request; - else - goto cleanup; - } else - break; - } - } else { - if ( --backend_msg_count > 0 ) - { - g_usleep( 200 ); - goto resend_request; - } else - goto cleanup; - } // if - } - } - } while ( found_backend_msg && --backend_msg_count > 0 ); + /* see the number of bytes transferred by the MythTV backend */ + gmyth_socket_read_stringlist( transfer->control_sock, strlist ); + if ( strlist != NULL && gmyth_string_list_length( strlist ) > 0 ) + { + sent = gmyth_string_list_get_int( strlist, 0 ); // -1 on backend error + g_print( "[%s] got SENT buffer message = %d\n", __FUNCTION__, sent ); + if ( sent != 0 ) + { + g_print( "[%s]\t received = %d bytes, backend says %d bytes sent, "\ + "io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, + recv, sent, ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); + + if ( sent == remaining ) + { + g_print( "[%s]\t\tsent %d, which is equals to requested size = %d\n\n", + __FUNCTION__, sent, remaining ); + } + else + { + g_print( "[%s]\t\tsent %d, which is NOT equals to requested size = %d\n\n", + __FUNCTION__, sent, remaining ); + size = remaining = sent; + if ( sent < 0 ) { + goto cleanup; + } + } + } else { + goto cleanup; + } // if + } guint count_bytes = 0; - do + bytes_read = 0; + + io_status = g_io_channel_read_chars( io_channel, data + recv, + remaining, &bytes_read, &error ); + + if ( bytes_read > 0 ) { - if ( remaining > GMYTHTV_BUFFER_SIZE ) { - buf_len = GMYTHTV_BUFFER_SIZE; - } else { - buf_len = remaining; - } - - bytes_read = 0; + recv += bytes_read; + count_bytes += bytes_read; + remaining -= bytes_read; + g_print( "[%s] Reading buffer (bytes read = %d, remaining = %d)\n", __FUNCTION__, bytes_read, remaining ); + if ( remaining == 0 ) { + response = TRUE; + break; + } - io_status = g_io_channel_read_chars( io_channel, data + recv, - buf_len, &bytes_read, &error ); + } else { + if ( io_status == G_IO_STATUS_EOF ) { + g_print( "[%s] got EOS!", __FUNCTION__ ); + } else if ( io_status == G_IO_STATUS_ERROR ) { + g_print( "[%s] gmyth_file_transfer_read(): socket error.\n", __FUNCTION__ ); + } + break; + } - if ( bytes_read > 0 ) - { - recv += bytes_read; - count_bytes += bytes_read; - remaining -= bytes_read; - g_print( "[%s] Reading buffer (bytes read = %d, remaining = %d)\n", __FUNCTION__, bytes_read, remaining ); - if ( remaining == 0 ) - break; - - } else { - break; - } - - if ( io_status == G_IO_STATUS_EOF ) { - g_print( "[%s] got EOS!", __FUNCTION__ ); - break; - } else if ( io_status == G_IO_STATUS_ERROR ) { - g_print( "[%s] gmyth_file_transfer_read(): socket error.\n", __FUNCTION__ ); - break; - } - - /* increase buffer size, to allow get more data (do not obey to the buffer size) */ - if ( read_unlimited == TRUE ) { - // FOR NOW, DO NOTHING!!! - } - - /* verify if the input (read) buffer is ready to receive data */ - //io_cond = g_io_channel_get_buffer_condition( io_channel ); - - g_print( "[%s]\t io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, - ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); - - } while ( remaining > 0 );//&& ( ( io_cond & G_IO_IN ) != 0 ) ); - - //io_cond_control = g_io_channel_get_buffer_condition( io_channel_control ); - if ( remaining == 0 )//( io_cond_control & G_IO_IN ) != 0 ) - { - response = TRUE; - break; - } + g_print( "[%s]\t io_cond %s prepared for reading! (G_IO_IN) !!!\n\n", __FUNCTION__, + ( ( io_cond & G_IO_IN ) != 0 ) ? "IS" : "IS NOT" ); if ( ( io_cond_control & G_IO_IN ) != 0 ) { g_print( "[%s] Finishind reading function: cleaning all data on the I/O control socket...\n", __FUNCTION__ ); @@ -1138,12 +1038,6 @@ cleanup: myth_control_release_context (mutex); - //has_io_access = TRUE; - - //g_cond_broadcast( io_watcher_cond ); - - //g_mutex_unlock( mutex ); - if ( trash != NULL ) g_free( trash ); diff -r f4be69980934 -r cf4a26332b8c gmyth/src/gmyth_socket.c --- a/gmyth/src/gmyth_socket.c Wed Nov 22 14:37:47 2006 +0000 +++ b/gmyth/src/gmyth_socket.c Wed Nov 22 19:53:52 2006 +0000 @@ -44,9 +44,12 @@ #include "gmyth_stringlist.h" #include "gmyth_context.h" -#define BUFLEN 512 -#define MYTH_SEPARATOR "[]:[]" -#define MYTH_PROTOCOL_FIELD_SIZE 8 +#define BUFLEN 512 +#define MYTH_SEPARATOR "[]:[]" +#define MYTH_PROTOCOL_FIELD_SIZE 8 + +/* max number of iterations */ +#define MYTHTV_MAX_VERSION_CHECKS 15 static GStaticMutex mutex = G_STATIC_MUTEX_INIT; @@ -195,6 +198,8 @@ gmyth_socket->hostname = g_strdup(""); gmyth_socket->port = 6543; + + gmyth_socket->mythtv_version = MYTHTV_VERSION_DEFAULT; return gmyth_socket; } @@ -330,7 +335,7 @@ * @param command The string command to be sent. */ gboolean -gmyth_socket_send_command(GMythSocket *gmyth_socket, const GString *command) +gmyth_socket_send_command(GMythSocket *gmyth_socket, GString *command) { gboolean ret = TRUE; @@ -422,7 +427,7 @@ return FALSE; } - if (gmyth_socket_check_protocol_version (gmyth_socket)) { + if ( gmyth_socket_check_protocol_version (gmyth_socket) ) { GString *result; GString *base_str = g_string_new(""); @@ -472,14 +477,18 @@ * * @param gmyth_socket The GMythSocket instance. * @param mythtv_version The Mythtv protocol version to be tested + * + * @return The actual MythTV the client is connected to. */ -gboolean +gint gmyth_socket_check_protocol_version_number (GMythSocket *gmyth_socket, gint mythtv_version) { GString *response; GString *payload; gchar *new_version = g_strdup(""); gboolean res = TRUE; + gint mythtv_new_version = MYTHTV_CANNOT_NEGOTIATE_VERSION; + guint max_iterations = MYTHTV_MAX_VERSION_CHECKS; try_new_version: payload = g_string_new ("MYTH_PROTO_VERSION"); @@ -503,26 +512,31 @@ if (new_version!=NULL) { ++new_version; /* skip ']' character */ if ( new_version != NULL ) { - g_print( "[%s] got MythTV version = %s\n", __FUNCTION__, new_version ); - mythtv_version = g_ascii_strtoull( g_strdup( new_version ), NULL, 10 ); + g_print( "[%s] got MythTV version = %s.\n", __FUNCTION__, new_version ); + mythtv_version = (gint)g_ascii_strtoull( g_strdup( new_version ), NULL, 10 ); /* do reconnection to the socket (socket is closed if the MythTV version was wrong) */ gmyth_socket_connect( &gmyth_socket, gmyth_socket->hostname, gmyth_socket->port ); /* g_free( new_version ); */ - goto try_new_version; + if ( --max_iterations > 0 ) + goto try_new_version; + else + goto done; } } } } + + /* change the return value to a valid one */ + if ( res ) + mythtv_new_version = mythtv_version; done: if ( payload != NULL ) g_string_free (payload, TRUE); if ( response != NULL ) g_string_free (response, TRUE); -// if (new_version!=NULL) -// g_free( new_version ); - return res; + return mythtv_new_version; } /** Verifies if the Mythtv backend supported the GMyth supported version. @@ -533,7 +547,20 @@ gboolean gmyth_socket_check_protocol_version (GMythSocket *gmyth_socket) { - return gmyth_socket_check_protocol_version_number( gmyth_socket, MYTHTV_VERSION_DEFAULT ); + return ( ( gmyth_socket->mythtv_version = + gmyth_socket_check_protocol_version_number ( gmyth_socket, + MYTHTV_VERSION_DEFAULT ) ) != MYTHTV_CANNOT_NEGOTIATE_VERSION ); +} + +/** Returns the Mythtv backend supported version. + * + * @param gmyth_socket The GMythSocket instance. + * @return The actual MythTV version number. + */ +gint +gmyth_socket_get_protocol_version (GMythSocket *gmyth_socket) +{ + return gmyth_socket->mythtv_version; } /** Receives a backend answer after a gmyth_socket_send_command_call (). @@ -564,7 +591,6 @@ io_status = g_io_channel_read_chars( gmyth_socket->sd_io_ch, buffer, MYTH_PROTOCOL_FIELD_SIZE, &bytes_read, &error ); - /* verify if the input (read) buffer is ready to receive data */ io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch ); @@ -588,7 +614,7 @@ /* removes trailing whitespace */ buffer = g_strstrip( buffer ); - len = (gint)strtoull ( buffer, NULL, 10 ); + len = (gint)g_ascii_strtoull ( buffer, NULL, 10 ); bytes_read = 0; io_status = g_io_channel_read_chars( gmyth_socket->sd_io_ch, buffer, len, &bytes_read, &error ); diff -r f4be69980934 -r cf4a26332b8c gmyth/src/gmyth_socket.h --- a/gmyth/src/gmyth_socket.h Wed Nov 22 14:37:47 2006 +0000 +++ b/gmyth/src/gmyth_socket.h Wed Nov 22 19:53:52 2006 +0000 @@ -74,8 +74,11 @@ gchar *hostname; gint port; + gint mythtv_version; }; +/* used when no protocol version number was negotiated */ +#define MYTHTV_CANNOT_NEGOTIATE_VERSION 0 GType gmyth_socket_get_type (void); @@ -87,7 +90,7 @@ gboolean gmyth_socket_is_able_to_write (GMythSocket *gmyth_socket ); gboolean gmyth_socket_send_command (GMythSocket *gmyth_socket, - const GString *command); + GString *command); GString * gmyth_socket_receive_response (GMythSocket *gmyth_socket); int gmyth_socket_sendreceive_stringlist (GMythSocket * gmyth_socket, GMythStringList *str_list); @@ -103,14 +106,15 @@ void gmyth_socket_close_connection (GMythSocket *gmyth_socket); gboolean gmyth_socket_check_protocol_version (GMythSocket *gmyth_socket); -gboolean gmyth_socket_check_protocol_version_number (GMythSocket *gmyth_socket, +gint gmyth_socket_check_protocol_version_number (GMythSocket *gmyth_socket, gint mythtv_version); +gint gmyth_socket_get_protocol_version (GMythSocket *gmyth_socket); + gboolean gmyth_socket_write_stringlist(GMythSocket *gmyth_socket, GMythStringList* str_list); int gmyth_socket_read_stringlist(GMythSocket *gmyth_socket, GMythStringList* str_list); - G_END_DECLS #endif /* __GMYTH_SOCKET_H__ */