diff -r a7237ce91c3b -r 1799c8782451 libgnomevfs2-mythtv/modules/mythtv-method.c --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Tue Nov 28 13:44:31 2006 +0000 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Thu Nov 30 19:23:52 2006 +0000 @@ -62,18 +62,16 @@ GnomeVFSContext *context) { - const gchar *user, *password, *host, *transfer_uri; + gchar *transfer_uri; MythtvHandle *myth_handle; GString *uri_str; - guint port; - gchar *path; gboolean ret; _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL); _GNOME_VFS_METHOD_PARAM_CHECK (uri != NULL); - g_debug ("[%s] Calling do_open function", __FUNCTION__); + //g_debug ("[%s] Calling do_open function", __FUNCTION__); myth_handle = g_new0 (MythtvHandle, 1); @@ -81,16 +79,10 @@ return GNOME_VFS_ERROR_NOT_PERMITTED; } - if ((host = gnome_vfs_uri_get_host_name (uri)) == NULL) { - return GNOME_VFS_ERROR_INVALID_HOST_NAME; + if (gnome_vfs_uri_get_host_name (uri) == NULL) { + return GNOME_VFS_ERROR_INVALID_HOST_NAME; } - /* Parse URI */ - path = gnome_vfs_unescape_string (uri->text, NULL); - port = gnome_vfs_uri_get_host_port (uri); - user = gnome_vfs_uri_get_user_name (uri); - password = gnome_vfs_uri_get_password (uri); - transfer_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_USER_NAME | GNOME_VFS_URI_HIDE_PASSWORD); @@ -107,6 +99,8 @@ /* sets the Playback monitor connection */ uri_str = g_string_new (transfer_uri); + g_free (transfer_uri); + transfer_uri = NULL; ret = gmyth_file_transfer_open (myth_handle->file_transfer, uri_str); if (ret == FALSE) { g_printerr ("Mythtv FileTransfer open error\n"); @@ -137,9 +131,9 @@ MythtvHandle *myth_handle = (MythtvHandle *) method_handle; GnomeVFSFileSize bytes_to_read; - g_debug ("do_read(): file size: %llu, already read: %llu, requested: %llu, buffer_remain: %du", - myth_handle->content_size, myth_handle->bytes_read, num_bytes, - myth_handle->buffer_remain); + //g_debug ("do_read(): file size: %llu, already read: %llu, requested: %llu, buffer_remain: %du", + // myth_handle->content_size, myth_handle->bytes_read, num_bytes, + // myth_handle->buffer_remain); *bytes_read = 0; @@ -155,41 +149,40 @@ /* Loop sending the Myth File Transfer request: * Retry whilst authentication fails and we supply it. */ - if ( bytes_to_read > myth_handle->buffer_remain ) { - GByteArray *tmp_buffer = g_byte_array_new(); + if ( bytes_to_read > myth_handle->buffer_remain ) { + GByteArray *tmp_buffer = g_byte_array_new(); - gint len = gmyth_file_transfer_read( myth_handle->file_transfer, - tmp_buffer, MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain, TRUE ); + gint len = gmyth_file_transfer_read (myth_handle->file_transfer, + tmp_buffer, MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain, TRUE); - if (len < 0) + if (len < 0) { + g_byte_array_free (tmp_buffer, TRUE); return GNOME_VFS_ERROR_IO; + } - myth_handle->buffer = g_byte_array_append( myth_handle->buffer, - g_memdup( tmp_buffer->data, len ), len ); + myth_handle->buffer = g_byte_array_append (myth_handle->buffer, + tmp_buffer->data, len); myth_handle->buffer_remain += len; - g_debug ( "Reading %d data from backend", MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain ); + //g_debug ( "Reading %d data from backend", MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain ); - if ( tmp_buffer != NULL ) { - g_byte_array_free( tmp_buffer, TRUE ); + g_byte_array_free (tmp_buffer, TRUE); tmp_buffer = NULL; } - - } bytes_to_read = (bytes_to_read > myth_handle->buffer_remain) ? myth_handle->buffer_remain : bytes_to_read; - g_debug ("Returning %du bytes to gnomevfs", (gint) bytes_to_read); + //g_debug ("Returning %du bytes to gnomevfs", (gint) bytes_to_read); /* gets the first buffer_size bytes from the byte array buffer variable */ - g_memmove( buffer, myth_handle->buffer->data, bytes_to_read ); + g_memmove (buffer, myth_handle->buffer->data, bytes_to_read); myth_handle->bytes_read += bytes_to_read; myth_handle->buffer_remain -= bytes_to_read; /* flushs the newly buffer got from byte array */ - myth_handle->buffer = g_byte_array_remove_range( myth_handle->buffer, 0, bytes_to_read ); + myth_handle->buffer = g_byte_array_remove_range (myth_handle->buffer, 0, bytes_to_read); *bytes_read = bytes_to_read; return GNOME_VFS_OK;