melunko@38: /* melunko@38: * @author Hallyson Melo melunko@38: * melunko@38: * This program is free software; you can redistribute it and/or modify melunko@38: * it under the terms of the GNU Lesser General Public License as published by melunko@38: * the Free Software Foundation; either version 2 of the License, or melunko@38: * (at your option) any later version. melunko@38: * melunko@38: * This program is distributed in the hope that it will be useful, melunko@38: * but WITHOUT ANY WARRANTY; without even the implied warranty of melunko@38: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the melunko@38: * GNU General Public License for more details. melunko@38: * melunko@38: * You should have received a copy of the GNU Lesser General Public License melunko@38: * along with this program; if not, write to the Free Software melunko@38: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA melunko@38: */ melunko@38: melunko@38: #ifdef HAVE_CONFIG_H melunko@38: #include melunko@38: #endif melunko@38: melunko@38: #include melunko@38: #include leo_sobral@441: #include leo_sobral@441: #include melunko@38: #include melunko@38: melunko@38: #include melunko@38: #include melunko@38: rosfran@277: #include rosfran@277: #include rosfran@277: #include rosfran@277: #include rosfran@277: #include rosfran@277: #include rosfran@332: #include rosfran@332: #include rosfran@357: #include melunko@38: melunko@38: #define GST_MYTHTV_ID_NUM 1 melunko@38: #define MYTHTV_VERSION_DEFAULT 30 rosfran@277: #define MYTHTV_TRANSFER_MAX_WAITS 100 melunko@38: rosfran@361: /* internal GnomeVFS plug-in buffer size ( 120 Kbytes ) */ leo_sobral@441: #define MYTHTV_BUFFER_SIZE 80*1024 rosfran@361: /* internally sized GnomeVFS plug-in buffer ( 4 Kbytes ) */ leo_sobral@441: #define MYTHTV_MAX_VFS_BUFFER_SIZE 4096 rosfran@361: /* maximum number of bytes to be requested to the MythTV backend ( 64 Kbytes ) */ leo_sobral@441: #define MYTHTV_MAX_REQUEST_SIZE 64*1024 melunko@111: renatofilho@367: static GnomeVFSResult do_read (GnomeVFSMethod * method, renatofilho@367: GnomeVFSMethodHandle * method_handle, renatofilho@367: gpointer buffer, renatofilho@367: GnomeVFSFileSize num_bytes, renatofilho@367: GnomeVFSFileSize * bytes_read, renatofilho@367: GnomeVFSContext * context); melunko@38: melunko@38: typedef struct { renatofilho@367: GMythFileTransfer *file_transfer; renatofilho@367: GMythLiveTV *livetv; renatofilho@367: gchar *channel_name; melunko@111: renatofilho@367: gint mythtv_version; renatofilho@367: gint64 content_size; renatofilho@367: guint64 bytes_read; renatofilho@367: renatofilho@367: GByteArray *buffer; renatofilho@367: gsize buffer_remain; renatofilho@367: gboolean is_livetv; renatofilho@367: renatofilho@367: gboolean configured; renatofilho@367: melunko@38: } MythtvHandle; melunko@38: rosfran@357: //static MythtvHandle *myth_handle = NULL; leo_sobral@441: #ifdef DEBUG leo_sobral@441: static FILE *fpout = NULL; leo_sobral@441: static gboolean first = TRUE; leo_sobral@441: #endif rosfran@357: melunko@38: static GnomeVFSResult renatofilho@367: do_open (GnomeVFSMethod * method, renatofilho@367: GnomeVFSMethodHandle ** method_handle, renatofilho@367: GnomeVFSURI * uri, renatofilho@367: GnomeVFSOpenMode mode, GnomeVFSContext * context) renatofilho@367: { renatofilho@367: MythtvHandle *myth_handle = NULL; renatofilho@367: GMythBackendInfo *backend_info = NULL; renatofilho@367: GMythURI *gmyth_uri = NULL; renatofilho@367: gboolean ret = TRUE; leo_sobral@447: gchar *tmp_str1; leo_sobral@447: gchar *tmp_str2; melunko@38: renatofilho@367: _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL); renatofilho@367: _GNOME_VFS_METHOD_PARAM_CHECK (uri != NULL); melunko@38: renatofilho@367: if (mode & GNOME_VFS_OPEN_WRITE) { renatofilho@367: return GNOME_VFS_ERROR_NOT_PERMITTED; renatofilho@367: } melunko@38: renatofilho@367: if (gnome_vfs_uri_get_host_name (uri) == NULL) { renatofilho@367: return GNOME_VFS_ERROR_INVALID_HOST_NAME; renatofilho@367: } renatofilho@367: leo_sobral@441: // FIXME: myth_handle is always NULL here renatofilho@367: if ((NULL == myth_handle) || !myth_handle->configured) { leo_sobral@447: myth_handle = g_new0 (MythtvHandle, 1); leo_sobral@447: leo_sobral@447: myth_handle->configured = FALSE; leo_sobral@447: myth_handle->is_livetv = FALSE; renatofilho@367: renatofilho@367: /* Initialize mythtv handler */ leo_sobral@447: myth_handle->file_transfer = NULL; leo_sobral@447: myth_handle->livetv = NULL; leo_sobral@447: myth_handle->mythtv_version = MYTHTV_VERSION_DEFAULT; leo_sobral@447: myth_handle->bytes_read = 0; leo_sobral@447: myth_handle->content_size = (GnomeVFSFileSize) - 1; leo_sobral@447: leo_sobral@447: /* Creates and fills out the backend info structure */ leo_sobral@447: tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); leo_sobral@447: tmp_str2 = gnome_vfs_unescape_string (tmp_str1, ""); renatofilho@367: leo_sobral@447: backend_info = gmyth_backend_info_new_with_uri (tmp_str2); renatofilho@367: leo_sobral@447: g_free (tmp_str1); leo_sobral@447: g_free (tmp_str2); leo_sobral@447: renatofilho@367: /* creates an instance of */ leo_sobral@447: tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); leo_sobral@447: tmp_str2 = gnome_vfs_unescape_string (tmp_str1, ""); leo_sobral@447: leo_sobral@447: gmyth_uri = gmyth_uri_new_with_value (tmp_str2); leo_sobral@447: leo_sobral@447: g_free (tmp_str1); leo_sobral@447: g_free (tmp_str2); renatofilho@367: renatofilho@367: myth_handle->is_livetv = gmyth_uri_is_livetv (gmyth_uri); renatofilho@367: renatofilho@367: /* Connect to the backend */ renatofilho@367: if (gmyth_uri != NULL && myth_handle->is_livetv == TRUE) { renatofilho@367: renatofilho@367: if (NULL == myth_handle->livetv) { leo_sobral@441: myth_handle->livetv = gmyth_livetv_new (backend_info); renatofilho@367: renatofilho@367: myth_handle->channel_name = renatofilho@367: gmyth_uri_get_channel_name (gmyth_uri); renatofilho@367: renatofilho@367: g_debug ("[%s] Channel name = %s\n", renatofilho@367: __FUNCTION__, renatofilho@367: myth_handle->channel_name); renatofilho@367: renatofilho@367: if (myth_handle->channel_name != NULL) { leo_sobral@441: if (gmyth_livetv_channel_name_setup (myth_handle->livetv, leo_sobral@441: myth_handle->channel_name) == FALSE) { renatofilho@367: g_object_unref (gmyth_uri); rosfran@357: ret = FALSE; rosfran@357: } renatofilho@367: } else { leo_sobral@441: if (gmyth_livetv_setup (myth_handle->livetv) == FALSE) { renatofilho@367: g_object_unref (gmyth_uri); renatofilho@367: ret = FALSE; renatofilho@367: } renatofilho@367: } renatofilho@367: } melunko@38: renatofilho@367: if (NULL == myth_handle->file_transfer) { renatofilho@367: myth_handle->file_transfer = leo_sobral@441: gmyth_livetv_create_file_transfer (myth_handle->livetv); renatofilho@367: renatofilho@367: if (NULL == myth_handle->file_transfer) { renatofilho@367: ret = FALSE; leo_sobral@447: g_debug ("MythTV FileTransfer is NULL!\n"); renatofilho@367: return GNOME_VFS_ERROR_NOT_OPEN; renatofilho@367: } renatofilho@367: leo_sobral@447: if (!gmyth_file_transfer_open (myth_handle->file_transfer, leo_sobral@447: myth_handle->livetv->uri != NULL ? leo_sobral@447: gmyth_uri_get_path (myth_handle->livetv->uri) : leo_sobral@447: myth_handle->livetv->proginfo->pathname->str)) { leo_sobral@447: g_debug ("Couldn't open MythTV FileTransfer is NULL!\n"); leo_sobral@447: g_object_unref (myth_handle->file_transfer); renatofilho@367: myth_handle->file_transfer = NULL; renatofilho@367: ret = FALSE; renatofilho@367: } leo_sobral@441: } /* if - FileTransfer is NULL, or not */ renatofilho@367: } else { renatofilho@367: if (NULL == myth_handle->file_transfer) { renatofilho@367: renatofilho@367: myth_handle->file_transfer = renatofilho@367: gmyth_file_transfer_new (backend_info); renatofilho@367: renatofilho@367: /* Verifies if the file exists */ leo_sobral@447: if (!gmyth_util_file_exists (backend_info, leo_sobral@447: gmyth_uri_get_path (gmyth_uri))) { renatofilho@367: g_object_unref (backend_info); renatofilho@367: ret = FALSE; renatofilho@367: } renatofilho@367: renatofilho@367: /* sets the Playback monitor connection */ leo_sobral@447: ret = gmyth_file_transfer_open (myth_handle->file_transfer, leo_sobral@447: gmyth_uri_get_path (gmyth_uri)); renatofilho@367: } leo_sobral@441: } /* if - LiveTV or not? */ renatofilho@367: renatofilho@367: if (ret == FALSE) { renatofilho@367: g_debug ("MythTV FileTransfer open error.\n"); renatofilho@367: return GNOME_VFS_ERROR_NOT_OPEN; renatofilho@367: } renatofilho@367: renatofilho@367: myth_handle->configured = TRUE; renatofilho@367: renatofilho@367: g_object_unref (backend_info); renatofilho@367: renatofilho@367: if (gmyth_uri != NULL) renatofilho@367: g_object_unref (gmyth_uri); renatofilho@367: renatofilho@367: myth_handle->buffer = renatofilho@367: g_byte_array_sized_new (MYTHTV_BUFFER_SIZE); renatofilho@367: myth_handle->buffer_remain = 0; renatofilho@367: renatofilho@367: g_return_val_if_fail (myth_handle->file_transfer != NULL, renatofilho@367: GNOME_VFS_ERROR_NOT_OPEN); renatofilho@367: renatofilho@367: if ( /*myth_handle->file_transfer->filesize <= 0 && */ renatofilho@367: myth_handle->is_livetv) { renatofilho@367: myth_handle->content_size = leo_sobral@441: gmyth_recorder_get_file_position (myth_handle->livetv->recorder); renatofilho@367: } else { renatofilho@367: myth_handle->content_size = renatofilho@367: myth_handle->file_transfer->filesize; renatofilho@367: } renatofilho@367: renatofilho@367: } renatofilho@367: /* if - configured or not? */ renatofilho@367: *method_handle = (GnomeVFSMethodHandle *) myth_handle; renatofilho@367: renatofilho@367: return GNOME_VFS_OK; melunko@38: } melunko@38: melunko@38: static GnomeVFSResult renatofilho@367: do_read (GnomeVFSMethod * method, renatofilho@367: GnomeVFSMethodHandle * method_handle, renatofilho@367: gpointer buffer, renatofilho@367: GnomeVFSFileSize num_bytes, leo_sobral@441: GnomeVFSFileSize * bytes_read, leo_sobral@441: GnomeVFSContext * context) melunko@38: { renatofilho@367: MythtvHandle *myth_handle = (MythtvHandle *) method_handle; renatofilho@367: GnomeVFSFileSize bytes_to_read = num_bytes; melunko@38: renatofilho@367: if (!myth_handle->is_livetv renatofilho@367: && (myth_handle->bytes_read >= myth_handle->content_size)) renatofilho@367: return GNOME_VFS_ERROR_EOF; melunko@38: renatofilho@367: /* fixme: change this to min math function */ renatofilho@367: if ((myth_handle->content_size > 0)) { renatofilho@367: if (!myth_handle->is_livetv && renatofilho@367: (num_bytes > renatofilho@367: (myth_handle->content_size - renatofilho@367: myth_handle->bytes_read))) { renatofilho@367: bytes_to_read = renatofilho@367: myth_handle->content_size - renatofilho@367: myth_handle->bytes_read; renatofilho@367: } renatofilho@367: } melunko@38: renatofilho@367: /* Loop sending the Myth File Transfer request: renatofilho@367: * Retry whilst authentication fails and we supply it. */ renatofilho@367: if ((myth_handle->buffer_remain = renatofilho@367: myth_handle->buffer->len) < bytes_to_read) { renatofilho@367: gint buffer_size; renatofilho@367: renatofilho@367: while (MYTHTV_BUFFER_SIZE != myth_handle->buffer_remain) { renatofilho@367: /* resize buffer length request to no more than MYTHTV_MAX_REQUEST_SIZE */ leo_sobral@447: if ((MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain) <= leo_sobral@447: MYTHTV_MAX_REQUEST_SIZE) leo_sobral@447: buffer_size = MYTHTV_BUFFER_SIZE - myth_handle->buffer_remain; renatofilho@367: else renatofilho@367: buffer_size = MYTHTV_MAX_REQUEST_SIZE; renatofilho@367: renatofilho@367: GByteArray *tmp_buffer = g_byte_array_new (); renatofilho@367: leo_sobral@441: g_debug ("Asking %d bytes (there is %d bytes in the buffer)\n", renatofilho@367: buffer_size, myth_handle->buffer_remain); renatofilho@367: leo_sobral@447: gint len = gmyth_file_transfer_read (myth_handle->file_transfer, leo_sobral@447: tmp_buffer, leo_sobral@447: buffer_size, TRUE); renatofilho@367: rosfran@408: if ( !myth_handle->is_livetv ) { rosfran@408: if ( len < 0 ) { rosfran@408: g_byte_array_free (tmp_buffer, TRUE); rosfran@408: g_debug ("Fail to read bytes"); rosfran@408: return GNOME_VFS_ERROR_IO; rosfran@408: } else if ( len == 0 ) { rosfran@408: g_byte_array_free (tmp_buffer, TRUE); rosfran@408: g_warning ("End of file probably achieved"); rosfran@408: return GNOME_VFS_ERROR_EOF; rosfran@408: } rosfran@408: } /* if */ rosfran@408: renatofilho@367: myth_handle->buffer = renatofilho@367: g_byte_array_append (myth_handle->buffer, renatofilho@367: tmp_buffer->data, len); renatofilho@367: rosfran@327: myth_handle->buffer_remain += len; melunko@111: renatofilho@367: if (tmp_buffer != NULL) { renatofilho@367: g_byte_array_free (tmp_buffer, TRUE); renatofilho@367: tmp_buffer = NULL; rosfran@354: } renatofilho@367: } /* while - iterates until fills the internal buffer */ rosfran@116: renatofilho@367: } leo_sobral@441: renatofilho@367: /* if - got from the network, or not */ leo_sobral@447: bytes_to_read = (bytes_to_read > myth_handle->buffer_remain) ? leo_sobral@447: myth_handle->buffer_remain : bytes_to_read; renatofilho@367: /* gets the first buffer_size bytes from the byte array buffer variable */ rosfran@116: renatofilho@367: g_memmove (buffer, myth_handle->buffer->data, bytes_to_read); renatofilho@367: renatofilho@367: myth_handle->bytes_read += bytes_to_read; renatofilho@367: myth_handle->buffer_remain -= bytes_to_read; rosfran@116: rosfran@355: /* flushs the newly buffer got from byte array */ renatofilho@367: myth_handle->buffer = renatofilho@367: g_byte_array_remove_range (myth_handle->buffer, 0, renatofilho@367: bytes_to_read); renatofilho@367: g_debug renatofilho@367: ("Got from %llu bytes from internal buffer. (there are %d bytes in the buffer, from a total of %llu dispatched.)\n", renatofilho@367: bytes_to_read, myth_handle->buffer_remain, renatofilho@367: myth_handle->bytes_read); rosfran@355: renatofilho@367: *bytes_read = bytes_to_read; renatofilho@367: renatofilho@367: return GNOME_VFS_OK; melunko@38: } melunko@38: melunko@38: static GnomeVFSResult renatofilho@367: do_close (GnomeVFSMethod * method, renatofilho@367: GnomeVFSMethodHandle * method_handle, GnomeVFSContext * context) melunko@38: { melunko@111: renatofilho@367: MythtvHandle *myth_handle = (MythtvHandle *) method_handle; renatofilho@367: renatofilho@367: //if ( NULL == myth_handle || myth_handle->configured ) { renatofilho@367: leo_sobral@441: if (myth_handle->is_livetv && myth_handle->livetv != NULL) { leo_sobral@441: g_object_unref (myth_handle->livetv); leo_sobral@441: myth_handle->livetv = NULL; leo_sobral@441: } leo_sobral@441: renatofilho@367: if (myth_handle->file_transfer != NULL) { renatofilho@367: g_object_unref (myth_handle->file_transfer); renatofilho@367: myth_handle->file_transfer = NULL; renatofilho@367: } renatofilho@367: renatofilho@367: if (myth_handle->buffer) { renatofilho@367: g_byte_array_free (myth_handle->buffer, TRUE); renatofilho@367: myth_handle->buffer = NULL; renatofilho@367: } renatofilho@367: renatofilho@367: myth_handle->configured = FALSE; renatofilho@367: leo_sobral@441: g_free (myth_handle->channel_name); leo_sobral@441: renatofilho@367: g_free (myth_handle); renatofilho@367: renatofilho@367: myth_handle = NULL; renatofilho@367: renatofilho@367: // } renatofilho@367: renatofilho@367: return GNOME_VFS_OK; melunko@38: } melunko@38: melunko@38: static GnomeVFSResult renatofilho@367: do_get_file_info (GnomeVFSMethod * method, renatofilho@367: GnomeVFSURI * uri, renatofilho@367: GnomeVFSFileInfo * file_info, renatofilho@367: GnomeVFSFileInfoOptions options, renatofilho@367: GnomeVFSContext * context) melunko@38: { renatofilho@367: GMythFileTransfer *file_transfer = NULL; renatofilho@367: GMythRecorder *recorder = NULL; renatofilho@367: GMythTVChain *tvchain = NULL; renatofilho@367: GMythBackendInfo *backend_info = NULL; renatofilho@367: GMythURI *gmyth_uri = NULL; renatofilho@367: GMythSocket *socket = NULL; renatofilho@367: gboolean is_livetv = FALSE; leo_sobral@447: gchar *tmp_str1; leo_sobral@447: gchar *tmp_str2; leo_sobral@447: renatofilho@367: gboolean ret = TRUE; renatofilho@367: gboolean res = TRUE; renatofilho@188: leo_sobral@447: /* Creates and fills out the backend info structure */ leo_sobral@447: tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); leo_sobral@447: tmp_str2 = gnome_vfs_unescape_string (tmp_str1, ""); leo_sobral@447: leo_sobral@447: backend_info = gmyth_backend_info_new_with_uri (tmp_str2); leo_sobral@447: g_free (tmp_str1); leo_sobral@447: g_free (tmp_str2); rosfran@297: renatofilho@367: /* creates an instance of */ leo_sobral@447: tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); leo_sobral@447: tmp_str2 = gnome_vfs_unescape_string (tmp_str1, ""); leo_sobral@447: leo_sobral@447: gmyth_uri = gmyth_uri_new_with_value (tmp_str2); leo_sobral@447: g_free (tmp_str1); leo_sobral@447: g_free (tmp_str2); melunko@38: renatofilho@367: is_livetv = gmyth_uri_is_livetv (gmyth_uri); rosfran@332: leo_sobral@441: file_info->valid_fields = 0; renatofilho@367: file_info->valid_fields = file_info->valid_fields renatofilho@367: | GNOME_VFS_FILE_INFO_FIELDS_TYPE renatofilho@367: | GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE renatofilho@367: | GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS; renatofilho@367: file_info->type = GNOME_VFS_FILE_TYPE_REGULAR; renatofilho@367: /* fixme: get from file extension? */ renatofilho@367: file_info->mime_type = g_strdup ("video/x-nuv"); renatofilho@367: file_info->permissions = renatofilho@367: GNOME_VFS_PERM_USER_READ | renatofilho@367: GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_GROUP_READ; rosfran@346: rosfran@368: g_debug ("gnome_vfs_uri == %s | gmyth_uri == %s.\n", renatofilho@367: gnome_vfs_uri_get_path (uri), renatofilho@367: gmyth_uri_get_path (gmyth_uri)); rosfran@331: renatofilho@367: /* Connect to the backend */ renatofilho@367: if (gmyth_uri != NULL && is_livetv == TRUE) { rosfran@338: renatofilho@367: /* start to get file info from LiveTV remote encoder */ renatofilho@367: socket = gmyth_socket_new (); rosfran@301: renatofilho@367: /* FIME: Implement this at gmyth_socket */ renatofilho@367: res = renatofilho@367: gmyth_socket_connect_to_backend (socket, leo_sobral@441: backend_info->hostname, renatofilho@367: backend_info->port, renatofilho@367: TRUE); renatofilho@367: if (!res) { leo_sobral@441: g_debug ("[%s] LiveTV can not connect to backend", __FUNCTION__); renatofilho@367: res = FALSE; renatofilho@367: goto error; renatofilho@367: } renatofilho@367: leo_sobral@441: if (gmyth_remote_util_get_free_recorder_count (socket) <= 0) { rosfran@368: g_debug ("No free remote encoder available."); renatofilho@367: res = FALSE; renatofilho@367: goto error; renatofilho@367: } renatofilho@367: renatofilho@367: /* Gets the recorder num */ renatofilho@367: recorder = remote_request_next_free_recorder (socket, -1); renatofilho@367: leo_sobral@441: if (socket != NULL) rosfran@368: g_object_unref (socket); renatofilho@367: renatofilho@367: if (recorder == NULL) { leo_sobral@441: g_debug ("[%s] None remote encoder available", __FUNCTION__); renatofilho@367: res = FALSE; renatofilho@367: goto error; renatofilho@367: } renatofilho@367: renatofilho@367: /* Init remote encoder. Opens its control socket. */ renatofilho@367: res = gmyth_recorder_setup (recorder); renatofilho@367: if (!res) { leo_sobral@441: g_debug ("[%s] Fail while setting remote encoder\n", __FUNCTION__); renatofilho@367: res = FALSE; renatofilho@367: goto error; renatofilho@367: } renatofilho@367: renatofilho@367: /* Creates livetv chain handler */ renatofilho@367: tvchain = gmyth_tvchain_new (); renatofilho@367: gmyth_tvchain_initialize (tvchain, backend_info); renatofilho@367: renatofilho@367: if (tvchain == NULL || tvchain->tvchain_id == NULL) { renatofilho@367: res = FALSE; renatofilho@367: goto error; renatofilho@367: } rosfran@368: /* Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly) */ leo_sobral@441: res = gmyth_recorder_spawntv (recorder, gmyth_tvchain_get_id(tvchain)); renatofilho@367: if (!res) { renatofilho@367: g_warning ("[%s] Fail while spawn tv\n", renatofilho@367: __FUNCTION__); renatofilho@367: res = FALSE; renatofilho@367: goto error; renatofilho@367: } rosfran@372: rosfran@372: sleep(1); renatofilho@367: renatofilho@367: /* DEBUG message */ renatofilho@367: GMythProgramInfo *prog_info = renatofilho@367: gmyth_recorder_get_current_program_info (recorder); renatofilho@367: renatofilho@367: if (prog_info != NULL) { renatofilho@367: rosfran@368: g_debug ("path = %s", prog_info->pathname->str); renatofilho@367: renatofilho@367: file_info->name = renatofilho@367: g_strdup (g_strrstr renatofilho@367: (prog_info->pathname->str, "/")); renatofilho@367: renatofilho@367: } else { renatofilho@367: file_info->name = g_strdup ("LiveTV.nuv"); leo_sobral@441: /* Size being overrided below ... */ leo_sobral@441: //file_info->size = gmyth_recorder_get_file_position (recorder); renatofilho@367: } renatofilho@367: renatofilho@367: if (recorder != NULL) renatofilho@367: g_object_unref (recorder); renatofilho@367: renatofilho@367: if (prog_info != NULL) renatofilho@367: g_object_unref (prog_info); renatofilho@367: renatofilho@367: if (tvchain != NULL) renatofilho@367: g_object_unref (tvchain); renatofilho@367: leo_sobral@441: //file_info->size = (GnomeVFSFileSize) - 1; renatofilho@367: renatofilho@367: } else { renatofilho@367: leo_sobral@441: /* start to get file info from remote file encoder */ leo_sobral@441: file_transfer = gmyth_file_transfer_new (backend_info); renatofilho@367: renatofilho@367: /* Verifies if the file exists */ leo_sobral@441: if (!gmyth_util_file_exists (backend_info, gmyth_uri_get_path (gmyth_uri))) { leo_sobral@441: g_object_unref (backend_info); leo_sobral@441: return GNOME_VFS_ERROR_NOT_FOUND; renatofilho@367: } renatofilho@367: renatofilho@367: /* sets the Playback monitor connection */ leo_sobral@441: ret = gmyth_file_transfer_open (file_transfer, leo_sobral@441: gmyth_uri_get_path (gmyth_uri)); renatofilho@367: renatofilho@367: file_info->name = g_strdup (gnome_vfs_uri_get_path (uri)); renatofilho@367: leo_sobral@441: } /* if - LiveTV or not? */ renatofilho@367: renatofilho@367: if (ret == FALSE) { renatofilho@367: g_debug ("MythTV FileTransfer open error\n"); renatofilho@367: return GNOME_VFS_ERROR_NOT_OPEN; renatofilho@367: } renatofilho@367: leo_sobral@441: /* Just for recorded content */ renatofilho@367: if (ret == TRUE && file_transfer != NULL) { renatofilho@367: file_info->size = renatofilho@367: gmyth_file_transfer_get_filesize (file_transfer); leo_sobral@441: leo_sobral@441: file_info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_SIZE; leo_sobral@441: renatofilho@367: if (file_transfer) renatofilho@367: g_object_unref (file_transfer); renatofilho@367: } renatofilho@367: leo_sobral@441: error: renatofilho@367: if (backend_info) renatofilho@367: g_object_unref (backend_info); renatofilho@367: renatofilho@367: if (!res) renatofilho@367: return GNOME_VFS_ERROR_IO; renatofilho@367: renatofilho@367: return GNOME_VFS_OK; melunko@38: } melunko@38: melunko@38: static gboolean renatofilho@367: do_is_local (GnomeVFSMethod * method, const GnomeVFSURI * uri) melunko@38: { melunko@38: return FALSE; melunko@38: } melunko@38: melunko@38: static GnomeVFSMethod method = { melunko@38: sizeof (GnomeVFSMethod), melunko@38: do_open, melunko@38: NULL, melunko@38: do_close, melunko@38: do_read, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: do_get_file_info, melunko@38: NULL, melunko@38: do_is_local, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: NULL, melunko@38: }; melunko@38: melunko@38: melunko@38: GnomeVFSMethod * melunko@38: vfs_module_init (const char *method_name, const char *args) melunko@38: { melunko@38: return &method; melunko@38: } melunko@38: melunko@38: void renatofilho@367: vfs_module_shutdown (GnomeVFSMethod * method) melunko@38: { melunko@38: }