1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Tue Nov 28 13:44:31 2006 +0000
1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Thu Nov 30 20:06:25 2006 +0000
1.3 @@ -62,18 +62,16 @@
1.4 GnomeVFSContext *context)
1.5 {
1.6
1.7 - const gchar *user, *password, *host, *transfer_uri;
1.8 + gchar *transfer_uri;
1.9 MythtvHandle *myth_handle;
1.10
1.11 GString *uri_str;
1.12 - guint port;
1.13 - gchar *path;
1.14 gboolean ret;
1.15
1.16 _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
1.17 _GNOME_VFS_METHOD_PARAM_CHECK (uri != NULL);
1.18
1.19 - g_debug ("[%s] Calling do_open function", __FUNCTION__);
1.20 + //g_debug ("[%s] Calling do_open function", __FUNCTION__);
1.21
1.22 myth_handle = g_new0 (MythtvHandle, 1);
1.23
1.24 @@ -81,16 +79,10 @@
1.25 return GNOME_VFS_ERROR_NOT_PERMITTED;
1.26 }
1.27
1.28 - if ((host = gnome_vfs_uri_get_host_name (uri)) == NULL) {
1.29 - return GNOME_VFS_ERROR_INVALID_HOST_NAME;
1.30 + if (gnome_vfs_uri_get_host_name (uri) == NULL) {
1.31 + return GNOME_VFS_ERROR_INVALID_HOST_NAME;
1.32 }
1.33
1.34 - /* Parse URI */
1.35 - path = gnome_vfs_unescape_string (uri->text, NULL);
1.36 - port = gnome_vfs_uri_get_host_port (uri);
1.37 - user = gnome_vfs_uri_get_user_name (uri);
1.38 - password = gnome_vfs_uri_get_password (uri);
1.39 -
1.40 transfer_uri = gnome_vfs_uri_to_string (uri,
1.41 GNOME_VFS_URI_HIDE_USER_NAME | GNOME_VFS_URI_HIDE_PASSWORD);
1.42
1.43 @@ -107,6 +99,8 @@
1.44
1.45 /* sets the Playback monitor connection */
1.46 uri_str = g_string_new (transfer_uri);
1.47 + g_free (transfer_uri);
1.48 + transfer_uri = NULL;
1.49 ret = gmyth_file_transfer_open (myth_handle->file_transfer, uri_str);
1.50 if (ret == FALSE) {
1.51 g_printerr ("Mythtv FileTransfer open error\n");
1.52 @@ -137,9 +131,9 @@
1.53 MythtvHandle *myth_handle = (MythtvHandle *) method_handle;
1.54 GnomeVFSFileSize bytes_to_read;
1.55
1.56 - g_debug ("do_read(): file size: %llu, already read: %llu, requested: %llu, buffer_remain: %du",
1.57 - myth_handle->content_size, myth_handle->bytes_read, num_bytes,
1.58 - myth_handle->buffer_remain);
1.59 + //g_debug ("do_read(): file size: %llu, already read: %llu, requested: %llu, buffer_remain: %du",
1.60 + // myth_handle->content_size, myth_handle->bytes_read, num_bytes,
1.61 + // myth_handle->buffer_remain);
1.62
1.63 *bytes_read = 0;
1.64
1.65 @@ -155,41 +149,40 @@
1.66 /* Loop sending the Myth File Transfer request:
1.67 * Retry whilst authentication fails and we supply it. */
1.68
1.69 - if ( bytes_to_read > myth_handle->buffer_remain ) {
1.70 - GByteArray *tmp_buffer = g_byte_array_new();
1.71 + if ( bytes_to_read > myth_handle->buffer_remain ) {
1.72 + GByteArray *tmp_buffer = g_byte_array_new();
1.73
1.74 - gint len = gmyth_file_transfer_read( myth_handle->file_transfer,
1.75 - tmp_buffer, MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain, TRUE );
1.76 + gint len = gmyth_file_transfer_read (myth_handle->file_transfer,
1.77 + tmp_buffer, MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain, TRUE);
1.78
1.79 - if (len < 0)
1.80 + if (len < 0) {
1.81 + g_byte_array_free (tmp_buffer, TRUE);
1.82 return GNOME_VFS_ERROR_IO;
1.83 + }
1.84
1.85 - myth_handle->buffer = g_byte_array_append( myth_handle->buffer,
1.86 - g_memdup( tmp_buffer->data, len ), len );
1.87 + myth_handle->buffer = g_byte_array_append (myth_handle->buffer,
1.88 + tmp_buffer->data, len);
1.89
1.90 myth_handle->buffer_remain += len;
1.91
1.92 - g_debug ( "Reading %d data from backend", MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain );
1.93 + //g_debug ( "Reading %d data from backend", MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain );
1.94
1.95 - if ( tmp_buffer != NULL ) {
1.96 - g_byte_array_free( tmp_buffer, TRUE );
1.97 + g_byte_array_free (tmp_buffer, TRUE);
1.98 tmp_buffer = NULL;
1.99 }
1.100 -
1.101 - }
1.102
1.103 bytes_to_read = (bytes_to_read > myth_handle->buffer_remain) ? myth_handle->buffer_remain : bytes_to_read;
1.104
1.105 - g_debug ("Returning %du bytes to gnomevfs", (gint) bytes_to_read);
1.106 + //g_debug ("Returning %du bytes to gnomevfs", (gint) bytes_to_read);
1.107 /* gets the first buffer_size bytes from the byte array buffer variable */
1.108
1.109 - g_memmove( buffer, myth_handle->buffer->data, bytes_to_read );
1.110 + g_memmove (buffer, myth_handle->buffer->data, bytes_to_read);
1.111
1.112 myth_handle->bytes_read += bytes_to_read;
1.113 myth_handle->buffer_remain -= bytes_to_read;
1.114
1.115 /* flushs the newly buffer got from byte array */
1.116 - myth_handle->buffer = g_byte_array_remove_range( myth_handle->buffer, 0, bytes_to_read );
1.117 + myth_handle->buffer = g_byte_array_remove_range (myth_handle->buffer, 0, bytes_to_read);
1.118 *bytes_read = bytes_to_read;
1.119
1.120 return GNOME_VFS_OK;