1.1 --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Fri Mar 23 14:34:50 2007 +0000
1.2 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Fri Mar 23 22:57:05 2007 +0000
1.3 @@ -90,6 +90,8 @@
1.4 GMythBackendInfo *backend_info = NULL;
1.5 GMythURI *gmyth_uri = NULL;
1.6 gboolean ret = TRUE;
1.7 + gchar *tmp_str1;
1.8 + gchar *tmp_str2;
1.9
1.10 _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL);
1.11 _GNOME_VFS_METHOD_PARAM_CHECK (uri != NULL);
1.12 @@ -104,33 +106,35 @@
1.13
1.14 // FIXME: myth_handle is always NULL here
1.15 if ((NULL == myth_handle) || !myth_handle->configured) {
1.16 - myth_handle = g_new0 (MythtvHandle, 1);
1.17 -
1.18 - myth_handle->configured = FALSE;
1.19 -
1.20 - myth_handle->is_livetv = FALSE;
1.21 + myth_handle = g_new0 (MythtvHandle, 1);
1.22 +
1.23 + myth_handle->configured = FALSE;
1.24 + myth_handle->is_livetv = FALSE;
1.25
1.26 /* Initialize mythtv handler */
1.27 - myth_handle->file_transfer = NULL;
1.28 - myth_handle->livetv = NULL;
1.29 - myth_handle->mythtv_version = MYTHTV_VERSION_DEFAULT;
1.30 - myth_handle->bytes_read = 0;
1.31 - myth_handle->content_size = (GnomeVFSFileSize) - 1;
1.32 + myth_handle->file_transfer = NULL;
1.33 + myth_handle->livetv = NULL;
1.34 + myth_handle->mythtv_version = MYTHTV_VERSION_DEFAULT;
1.35 + myth_handle->bytes_read = 0;
1.36 + myth_handle->content_size = (GnomeVFSFileSize) - 1;
1.37 +
1.38 + /* Creates and fills out the backend info structure */
1.39 + tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
1.40 + tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
1.41
1.42 - /* Creates and fills out the backend info structure */
1.43 - backend_info =
1.44 - gmyth_backend_info_new_with_uri
1.45 - (gnome_vfs_unescape_string
1.46 - (gnome_vfs_uri_to_string
1.47 - (uri, GNOME_VFS_URI_HIDE_NONE), ""));
1.48 + backend_info = gmyth_backend_info_new_with_uri (tmp_str2);
1.49
1.50 + g_free (tmp_str1);
1.51 + g_free (tmp_str2);
1.52 +
1.53 /* creates an instance of */
1.54 - gmyth_uri =
1.55 - gmyth_uri_new_with_value (gnome_vfs_unescape_string
1.56 - (gnome_vfs_uri_to_string
1.57 - (uri,
1.58 - GNOME_VFS_URI_HIDE_NONE),
1.59 - ""));
1.60 + tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
1.61 + tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
1.62 +
1.63 + gmyth_uri = gmyth_uri_new_with_value (tmp_str2);
1.64 +
1.65 + g_free (tmp_str1);
1.66 + g_free (tmp_str2);
1.67
1.68 myth_handle->is_livetv = gmyth_uri_is_livetv (gmyth_uri);
1.69
1.70 @@ -167,24 +171,16 @@
1.71
1.72 if (NULL == myth_handle->file_transfer) {
1.73 ret = FALSE;
1.74 - g_debug
1.75 - ("MythTV FileTransfer is NULL!\n");
1.76 + g_debug ("MythTV FileTransfer is NULL!\n");
1.77 return GNOME_VFS_ERROR_NOT_OPEN;
1.78 }
1.79
1.80 - if (!gmyth_file_transfer_open
1.81 - (myth_handle->file_transfer,
1.82 - myth_handle->livetv->uri !=
1.83 - NULL ?
1.84 - gmyth_uri_get_path (myth_handle->
1.85 - livetv->
1.86 - uri) :
1.87 - myth_handle->livetv->proginfo->
1.88 - pathname->str)) {
1.89 - g_debug
1.90 - ("Couldn't open MythTV FileTransfer is NULL!\n");
1.91 - g_object_unref (myth_handle->
1.92 - file_transfer);
1.93 + if (!gmyth_file_transfer_open (myth_handle->file_transfer,
1.94 + myth_handle->livetv->uri != NULL ?
1.95 + gmyth_uri_get_path (myth_handle->livetv->uri) :
1.96 + myth_handle->livetv->proginfo->pathname->str)) {
1.97 + g_debug ("Couldn't open MythTV FileTransfer is NULL!\n");
1.98 + g_object_unref (myth_handle->file_transfer);
1.99 myth_handle->file_transfer = NULL;
1.100 ret = FALSE;
1.101 }
1.102 @@ -196,20 +192,15 @@
1.103 gmyth_file_transfer_new (backend_info);
1.104
1.105 /* Verifies if the file exists */
1.106 - if (!gmyth_util_file_exists
1.107 - (backend_info,
1.108 - gmyth_uri_get_path (gmyth_uri))) {
1.109 + if (!gmyth_util_file_exists (backend_info,
1.110 + gmyth_uri_get_path (gmyth_uri))) {
1.111 g_object_unref (backend_info);
1.112 ret = FALSE;
1.113 }
1.114
1.115 /* sets the Playback monitor connection */
1.116 - ret =
1.117 - gmyth_file_transfer_open (myth_handle->
1.118 - file_transfer,
1.119 - gmyth_uri_get_path
1.120 - (gmyth_uri));
1.121 -
1.122 + ret = gmyth_file_transfer_open (myth_handle->file_transfer,
1.123 + gmyth_uri_get_path (gmyth_uri));
1.124 }
1.125 } /* if - LiveTV or not? */
1.126
1.127 @@ -283,12 +274,9 @@
1.128
1.129 while (MYTHTV_BUFFER_SIZE != myth_handle->buffer_remain) {
1.130 /* resize buffer length request to no more than MYTHTV_MAX_REQUEST_SIZE */
1.131 - if ((MYTHTV_BUFFER_SIZE -
1.132 - myth_handle->buffer_remain) <=
1.133 - MYTHTV_MAX_REQUEST_SIZE)
1.134 - buffer_size =
1.135 - MYTHTV_BUFFER_SIZE -
1.136 - myth_handle->buffer_remain;
1.137 + if ((MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain) <=
1.138 + MYTHTV_MAX_REQUEST_SIZE)
1.139 + buffer_size = MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain;
1.140 else
1.141 buffer_size = MYTHTV_MAX_REQUEST_SIZE;
1.142
1.143 @@ -297,11 +285,9 @@
1.144 g_debug ("Asking %d bytes (there is %d bytes in the buffer)\n",
1.145 buffer_size, myth_handle->buffer_remain);
1.146
1.147 - gint len =
1.148 - gmyth_file_transfer_read (myth_handle->
1.149 - file_transfer,
1.150 - tmp_buffer,
1.151 - buffer_size, TRUE);
1.152 + gint len = gmyth_file_transfer_read (myth_handle->file_transfer,
1.153 + tmp_buffer,
1.154 + buffer_size, TRUE);
1.155
1.156 if ( !myth_handle->is_livetv ) {
1.157 if ( len < 0 ) {
1.158 @@ -330,10 +316,8 @@
1.159 }
1.160
1.161 /* if - got from the network, or not */
1.162 - bytes_to_read =
1.163 - (bytes_to_read >
1.164 - myth_handle->buffer_remain) ? myth_handle->
1.165 - buffer_remain : bytes_to_read;
1.166 + bytes_to_read = (bytes_to_read > myth_handle->buffer_remain) ?
1.167 + myth_handle->buffer_remain : bytes_to_read;
1.168 /* gets the first buffer_size bytes from the byte array buffer variable */
1.169
1.170 g_memmove (buffer, myth_handle->buffer->data, bytes_to_read);
1.171 @@ -406,23 +390,27 @@
1.172 GMythURI *gmyth_uri = NULL;
1.173 GMythSocket *socket = NULL;
1.174 gboolean is_livetv = FALSE;
1.175 + gchar *tmp_str1;
1.176 + gchar *tmp_str2;
1.177 +
1.178 gboolean ret = TRUE;
1.179 gboolean res = TRUE;
1.180
1.181 - /* Creates and fills out the backend info structure */
1.182 - backend_info =
1.183 - gmyth_backend_info_new_with_uri (gnome_vfs_unescape_string
1.184 - (gnome_vfs_uri_to_string
1.185 - (uri,
1.186 - GNOME_VFS_URI_HIDE_NONE),
1.187 - ""));
1.188 + /* Creates and fills out the backend info structure */
1.189 + tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
1.190 + tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
1.191 +
1.192 + backend_info = gmyth_backend_info_new_with_uri (tmp_str2);
1.193 + g_free (tmp_str1);
1.194 + g_free (tmp_str2);
1.195
1.196 /* creates an instance of */
1.197 - gmyth_uri =
1.198 - gmyth_uri_new_with_value (gnome_vfs_unescape_string
1.199 - (gnome_vfs_uri_to_string
1.200 - (uri, GNOME_VFS_URI_HIDE_NONE),
1.201 - ""));
1.202 + tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
1.203 + tmp_str2 = gnome_vfs_unescape_string (tmp_str1, "");
1.204 +
1.205 + gmyth_uri = gmyth_uri_new_with_value (tmp_str2);
1.206 + g_free (tmp_str1);
1.207 + g_free (tmp_str2);
1.208
1.209 is_livetv = gmyth_uri_is_livetv (gmyth_uri);
1.210