diff -r 0bf798c3f17e -r 7f0a3066f6ab gmyth-stream/libgnomevfs2/modules/gmythstream-method.c --- a/gmyth-stream/libgnomevfs2/modules/gmythstream-method.c Thu Apr 12 22:38:44 2007 +0100 +++ b/gmyth-stream/libgnomevfs2/modules/gmythstream-method.c Fri Apr 13 20:07:32 2007 +0100 @@ -155,60 +155,52 @@ return; } +char* _parse_opt(char* opt) +{ + char** list = g_strsplit(opt, "opt=", 2); + char** opts = g_strsplit(list[1], "+", 32); + char* value = ""; + char* aux; + gint i = 0; + + for (aux = opts[0]; aux != NULL; aux = opts[++i]) + value = g_strdup_printf("%s %s", value, aux); + + g_free(aux); + g_strfreev(list); + g_strfreev(opts); + return value; +} + static UriArgs * _uri_parse_args (const GnomeVFSURI *uri) { + gchar *file = gnome_vfs_unescape_string (uri->text, NULL); - gchar *file; + gchar **list = g_strsplit(file, "\'", 3); + gchar **prefix = g_strsplit_set(list[0], "/=", 3); + gchar **lst = g_strsplit (list[2], "?", 0); + UriArgs *info = g_new0 (UriArgs, 1); - GSList *args = NULL; - gchar *c; - GString *entry; - gboolean open = FALSE; - gchar **prop; - GSList* walk; - gchar *uri_str = gnome_vfs_uri_to_string (uri, - GNOME_VFS_URI_HIDE_USER_NAME | - GNOME_VFS_URI_HIDE_PASSWORD | - GNOME_VFS_URI_HIDE_HOST_NAME | - GNOME_VFS_URI_HIDE_HOST_PORT | - GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD); + gint i = 1; - file = gnome_vfs_unescape_string (uri_str, ""); - c = file; - entry = g_string_new (""); - c = c + 1; - do { - if ((*c == '\"') || (*c == '\'')) { - open = !open; - } + gchar** prop = NULL; + prop = g_strsplit_set(lst[0], "/=", 3); - if (((*c == '?') || (c[1] == '\0')) && !open) { - if (*c != '?') - g_string_append_c (entry, *c); - args = g_slist_append (args, g_strdup (entry->str)); - entry = g_string_assign (entry, ""); - } else { - if (*c == '+') - g_string_append_c (entry, "//"); - else - g_string_append_c (entry, *c); - } - c = c + 1; - } while (*c != '\0'); + info->file_name = g_strdup_printf ("%s://%s",\ + prefix[1],list[1]); - g_string_free (entry, TRUE); + //g_debug("FILENAME: [%s]", info->file_name); - for (walk = args; walk != NULL; walk = walk->next) + g_strfreev(prop); + + gchar* walk; + for (walk = lst[1]; walk != NULL; walk = lst[++i]) { - gchar *arg = (gchar *) walk->data; - prop = g_strsplit(arg, "=", 2); - g_debug ("arg = %s", arg); + prop = g_strsplit(walk, "=", 2); if (g_strv_length (prop) == 2) { - if (strcmp (prop[0], "file") == 0) { - info->file_name = g_strdup (prop[1]); - } else if (strcmp (prop[0], "mux") == 0) { + if (strcmp (prop[0], "mux") == 0) { info->mux = g_strdup (prop[1]); } else if (strcmp (prop[0], "vcodec") == 0) { info->vcodec = g_strdup (prop[1]); @@ -225,16 +217,16 @@ } else if (strcmp (prop[0], "height") == 0) { info->height = atoi (prop[1]); } else if (strcmp (prop[0], "opt") == 0) { - g_debug("DENTRO DE OPT: %s", arg); - //char* v = _parse_opt(walk); - info->opt = g_strdup (arg); + info->opt = g_strdup (_parse_opt(walk)); } } g_strfreev (prop); - g_free (arg); } + g_free (file); - g_slist_free (args); + g_strfreev (list); + g_strfreev (prefix); + g_strfreev (lst); return info; } @@ -248,8 +240,6 @@ gmsHandle *handle = gmsHandle_new(uri); UriArgs *args; - args = _uri_parse_args (uri); - if (!gmyth_stream_client_connect (handle->stream, gnome_vfs_uri_get_host_name (uri), gnome_vfs_uri_get_host_port (uri))) { @@ -301,9 +291,14 @@ gint64 total_read = 0; gmsHandle *handle = (gmsHandle *) method_handle; + //g_debug("waiting something"); + total_read = recv(handle->fd, buffer, BUFFER_SIZE, 0); + //g_debug("COULD READ: %d bytes", total_read); *bytes_read = (GnomeVFSFileSize) total_read; + //if (total_read < 0) g_debug("ERROR!!!!!!!!!!!!!!!!"); + if (total_read < 0) return GNOME_VFS_ERROR_INTERNAL; else return GNOME_VFS_OK; @@ -316,6 +311,8 @@ { gmsHandle *handle = (gmsHandle *) method_handle; + g_debug("close close close"); + gmyth_stream_client_close_stream (handle->stream); gmyth_stream_client_disconnect (handle->stream);