summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Schulman <rebecka@eazel.com>2001-01-26 23:16:59 +0000
committerRebecca Schulman <rebecka@src.gnome.org>2001-01-26 23:16:59 +0000
commit5dfee0c35d7091873a30c0c63cfcb0b5cec3e6cf (patch)
treedb251215f92aa9ba2d8c49977164757d5d3168f0
parent2717a5cdd36e86d5c90ecd56ebecc4f9d79dbdbb (diff)
downloadnautilus-5dfee0c35d7091873a30c0c63cfcb0b5cec3e6cf.tar.gz
Fix bugs 4094, 4425, 5201 and 4106 about inappopriate applications being
2001-01-27 Rebecca Schulman <rebecka@eazel.com> Fix bugs 4094, 4425, 5201 and 4106 about inappopriate applications being offered to view remote files. This change filters applications that don't support a uri scheme from a file's short list. reviewed by: Pavel Cisler <pavel@eazel.com> * libnautilus-extensions/nautilus-mime-actions.c: (nautilus_mime_actions_get_minimum_file_attributes), (nautilus_mime_get_short_list_applications_for_file), (application_supports_uri_scheme): Filter out applications from the short list that do not support the uri scheme for the file in question. * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application): Change "can_open_uris" to "expects_uris" to go along with the gnome vfs change * test/test-nautilus-mime-actions.c: (append_comma_and_scheme), (format_supported_uri_schemes_for_display), (print_application): update the tests similarly to the way the gnome-vfs tests were updated, so that all of the fields of the GnomeVFSMimeApplication structure are correctly printed. * libnautilus-extensions/nautilus-glib-extensions.c: Correct spelling and naming error in a comment
-rw-r--r--ChangeLog26
-rw-r--r--libnautilus-extensions/nautilus-glib-extensions.c2
-rw-r--r--libnautilus-extensions/nautilus-mime-actions.c43
-rw-r--r--libnautilus-extensions/nautilus-program-choosing.c2
-rw-r--r--libnautilus-private/nautilus-glib-extensions.c2
-rw-r--r--libnautilus-private/nautilus-mime-actions.c43
-rw-r--r--libnautilus-private/nautilus-program-choosing.c2
-rw-r--r--test/test-nautilus-mime-actions.c34
8 files changed, 136 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index a1bd74e3b..1ae21d34d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2001-01-27 Rebecca Schulman <rebecka@eazel.com>
+ Fix bugs 4094, 4425, 5201 and 4106 about inappopriate
+ applications being offered to view remote files.
+ This change filters applications that don't support
+ a uri scheme from a file's short list.
+
+ reviewed by: Pavel Cisler <pavel@eazel.com>
+
+ * libnautilus-extensions/nautilus-mime-actions.c:
+ (nautilus_mime_actions_get_minimum_file_attributes),
+ (nautilus_mime_get_short_list_applications_for_file),
+ (application_supports_uri_scheme):
+ Filter out applications from the short list that do not
+ support the uri scheme for the file in question.
+ * libnautilus-extensions/nautilus-program-choosing.c:
+ (nautilus_launch_application):
+ Change "can_open_uris" to "expects_uris" to go along with
+ the gnome vfs change
+ * test/test-nautilus-mime-actions.c: (append_comma_and_scheme),
+ (format_supported_uri_schemes_for_display), (print_application):
+ update the tests similarly to the way the gnome-vfs tests were
+ updated, so that all of the fields of the GnomeVFSMimeApplication
+ structure are correctly printed.
+
+ * libnautilus-extensions/nautilus-glib-extensions.c:
+ Correct spelling and naming error in a comment
2001-01-25 Darin Adler <darin@eazel.com>
reviewed by: John Sullivan <sullivan@eazel.com>
diff --git a/libnautilus-extensions/nautilus-glib-extensions.c b/libnautilus-extensions/nautilus-glib-extensions.c
index ea4b45dbb..c0660dbec 100644
--- a/libnautilus-extensions/nautilus-glib-extensions.c
+++ b/libnautilus-extensions/nautilus-glib-extensions.c
@@ -513,7 +513,7 @@ nautilus_g_list_safe_for_each (GList *list, GFunc function, gpointer user_data)
* @list: List to partition.
* @predicate: Function to call on each element.
* @user_data: Data to pass to function.
- * @removed: The GList * variable pinted to by this argument will be
+ * @failed: The GList * variable pointed to by this argument will be
* set to the list of elements for which the predicate returned
* false. */
diff --git a/libnautilus-extensions/nautilus-mime-actions.c b/libnautilus-extensions/nautilus-mime-actions.c
index eb137ac3b..7651fed3a 100644
--- a/libnautilus-extensions/nautilus-mime-actions.c
+++ b/libnautilus-extensions/nautilus-mime-actions.c
@@ -47,6 +47,8 @@ static gboolean string_not_in_list (const char
static char *mime_type_get_supertype (const char *mime_type);
static GList *get_explicit_content_view_iids_from_metafile (NautilusFile *file);
static gboolean server_has_content_requirements (OAF_ServerInfo *server);
+static gboolean application_supports_uri_scheme (gpointer data,
+ gpointer uri_scheme);
static GList *nautilus_do_component_query (const char *mime_type,
const char *uri_scheme,
GList *content_mime_types,
@@ -107,6 +109,7 @@ nautilus_mime_actions_get_minimum_file_attributes (void)
GList *attributes;
attributes = NULL;
+ attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA);
attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
@@ -333,8 +336,6 @@ nautilus_mime_get_default_component_sort_conditions (NautilusFile *file, char *d
return sort_conditions;
}
-
-
static OAF_ServerInfo *
nautilus_mime_get_default_component_for_file_internal (NautilusFile *file,
gboolean *user_chosen)
@@ -470,6 +471,7 @@ GList *
nautilus_mime_get_short_list_applications_for_file (NautilusFile *file)
{
char *mime_type;
+ char *uri_scheme;
GList *result;
GList *removed;
GList *metadata_application_add_ids;
@@ -482,6 +484,17 @@ nautilus_mime_get_short_list_applications_for_file (NautilusFile *file)
return NULL;
}
+ mime_type = nautilus_file_get_mime_type (file);
+ result = gnome_vfs_mime_get_short_list_applications (mime_type);
+ g_free (mime_type);
+
+ /* First remove applications that cannot support this location */
+ uri_scheme = nautilus_file_get_uri_scheme (file);
+ g_assert (uri_scheme != NULL);
+ result = nautilus_g_list_partition (result, application_supports_uri_scheme,
+ uri_scheme, &removed);
+ gnome_vfs_mime_application_list_free (removed);
+
CORBA_exception_init (&ev);
metadata_application_add_ids = nautilus_file_get_metadata_list
@@ -493,13 +506,10 @@ nautilus_mime_get_short_list_applications_for_file (NautilusFile *file)
NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE,
NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
- mime_type = nautilus_file_get_mime_type (file);
- result = gnome_vfs_mime_get_short_list_applications (mime_type);
- g_free (mime_type);
result = nautilus_g_list_partition (result, (NautilusPredicateFunction) gnome_vfs_mime_application_has_id_not_in_list,
metadata_application_remove_ids, &removed);
-
+
gnome_vfs_mime_application_list_free (removed);
for (p = metadata_application_add_ids; p != NULL; p = p->next) {
@@ -1630,3 +1640,24 @@ strv_concat (char **a,
return result;
}
+
+static gboolean
+application_supports_uri_scheme (gpointer data,
+ gpointer uri_scheme)
+{
+ GnomeVFSMimeApplication *application;
+
+ g_assert (data != NULL);
+ application = (GnomeVFSMimeApplication *) data;
+
+ /* The default supported uri scheme is "file" */
+ if (application->supported_uri_schemes == NULL &&
+ strcmp (uri_scheme, "file") == 0) {
+ return TRUE;
+ }
+ return (g_list_find_custom (application->supported_uri_schemes,
+ uri_scheme,
+ (GCompareFunc) strcmp) != NULL);
+
+
+}
diff --git a/libnautilus-extensions/nautilus-program-choosing.c b/libnautilus-extensions/nautilus-program-choosing.c
index 17ef8a5b4..e8143ed6b 100644
--- a/libnautilus-extensions/nautilus-program-choosing.c
+++ b/libnautilus-extensions/nautilus-program-choosing.c
@@ -429,7 +429,7 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
* prevents any possible ambiguity for cases where a path
* would looks like a URI.
*/
- if (application->can_open_uris) {
+ if (application->expects_uris) {
parameter = g_strdup (uri);
} else {
parameter = gnome_vfs_get_local_path_from_uri (uri);
diff --git a/libnautilus-private/nautilus-glib-extensions.c b/libnautilus-private/nautilus-glib-extensions.c
index ea4b45dbb..c0660dbec 100644
--- a/libnautilus-private/nautilus-glib-extensions.c
+++ b/libnautilus-private/nautilus-glib-extensions.c
@@ -513,7 +513,7 @@ nautilus_g_list_safe_for_each (GList *list, GFunc function, gpointer user_data)
* @list: List to partition.
* @predicate: Function to call on each element.
* @user_data: Data to pass to function.
- * @removed: The GList * variable pinted to by this argument will be
+ * @failed: The GList * variable pointed to by this argument will be
* set to the list of elements for which the predicate returned
* false. */
diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c
index eb137ac3b..7651fed3a 100644
--- a/libnautilus-private/nautilus-mime-actions.c
+++ b/libnautilus-private/nautilus-mime-actions.c
@@ -47,6 +47,8 @@ static gboolean string_not_in_list (const char
static char *mime_type_get_supertype (const char *mime_type);
static GList *get_explicit_content_view_iids_from_metafile (NautilusFile *file);
static gboolean server_has_content_requirements (OAF_ServerInfo *server);
+static gboolean application_supports_uri_scheme (gpointer data,
+ gpointer uri_scheme);
static GList *nautilus_do_component_query (const char *mime_type,
const char *uri_scheme,
GList *content_mime_types,
@@ -107,6 +109,7 @@ nautilus_mime_actions_get_minimum_file_attributes (void)
GList *attributes;
attributes = NULL;
+ attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA);
attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE);
@@ -333,8 +336,6 @@ nautilus_mime_get_default_component_sort_conditions (NautilusFile *file, char *d
return sort_conditions;
}
-
-
static OAF_ServerInfo *
nautilus_mime_get_default_component_for_file_internal (NautilusFile *file,
gboolean *user_chosen)
@@ -470,6 +471,7 @@ GList *
nautilus_mime_get_short_list_applications_for_file (NautilusFile *file)
{
char *mime_type;
+ char *uri_scheme;
GList *result;
GList *removed;
GList *metadata_application_add_ids;
@@ -482,6 +484,17 @@ nautilus_mime_get_short_list_applications_for_file (NautilusFile *file)
return NULL;
}
+ mime_type = nautilus_file_get_mime_type (file);
+ result = gnome_vfs_mime_get_short_list_applications (mime_type);
+ g_free (mime_type);
+
+ /* First remove applications that cannot support this location */
+ uri_scheme = nautilus_file_get_uri_scheme (file);
+ g_assert (uri_scheme != NULL);
+ result = nautilus_g_list_partition (result, application_supports_uri_scheme,
+ uri_scheme, &removed);
+ gnome_vfs_mime_application_list_free (removed);
+
CORBA_exception_init (&ev);
metadata_application_add_ids = nautilus_file_get_metadata_list
@@ -493,13 +506,10 @@ nautilus_mime_get_short_list_applications_for_file (NautilusFile *file)
NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE,
NAUTILUS_METADATA_SUBKEY_APPLICATION_ID);
- mime_type = nautilus_file_get_mime_type (file);
- result = gnome_vfs_mime_get_short_list_applications (mime_type);
- g_free (mime_type);
result = nautilus_g_list_partition (result, (NautilusPredicateFunction) gnome_vfs_mime_application_has_id_not_in_list,
metadata_application_remove_ids, &removed);
-
+
gnome_vfs_mime_application_list_free (removed);
for (p = metadata_application_add_ids; p != NULL; p = p->next) {
@@ -1630,3 +1640,24 @@ strv_concat (char **a,
return result;
}
+
+static gboolean
+application_supports_uri_scheme (gpointer data,
+ gpointer uri_scheme)
+{
+ GnomeVFSMimeApplication *application;
+
+ g_assert (data != NULL);
+ application = (GnomeVFSMimeApplication *) data;
+
+ /* The default supported uri scheme is "file" */
+ if (application->supported_uri_schemes == NULL &&
+ strcmp (uri_scheme, "file") == 0) {
+ return TRUE;
+ }
+ return (g_list_find_custom (application->supported_uri_schemes,
+ uri_scheme,
+ (GCompareFunc) strcmp) != NULL);
+
+
+}
diff --git a/libnautilus-private/nautilus-program-choosing.c b/libnautilus-private/nautilus-program-choosing.c
index 17ef8a5b4..e8143ed6b 100644
--- a/libnautilus-private/nautilus-program-choosing.c
+++ b/libnautilus-private/nautilus-program-choosing.c
@@ -429,7 +429,7 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
* prevents any possible ambiguity for cases where a path
* would looks like a URI.
*/
- if (application->can_open_uris) {
+ if (application->expects_uris) {
parameter = g_strdup (uri);
} else {
parameter = gnome_vfs_get_local_path_from_uri (uri);
diff --git a/test/test-nautilus-mime-actions.c b/test/test-nautilus-mime-actions.c
index 0b6adc1ca..3a4a7866e 100644
--- a/test/test-nautilus-mime-actions.c
+++ b/test/test-nautilus-mime-actions.c
@@ -32,16 +32,46 @@
static gboolean ready = FALSE;
+
+static void
+append_comma_and_scheme (gpointer scheme,
+ gpointer user_data)
+{
+ char **string;
+
+ string = (char **) user_data;
+ if (strlen (*string) > 0) {
+ *string = g_strconcat (*string, ", ", scheme, NULL);
+ }
+ else {
+ *string = g_strdup (scheme);
+ }
+}
+
+
+static char *
+format_supported_uri_schemes_for_display (GList *supported_uri_schemes)
+{
+ char *string;
+
+ string = g_strdup ("");
+ g_list_foreach (supported_uri_schemes,
+ append_comma_and_scheme,
+ &string);
+ return string;
+}
+
static void
print_application (GnomeVFSMimeApplication *application)
{
if (application == NULL) {
puts ("(none)");
} else {
- printf ("name: %s\ncommand: %s\ncan_open_multiple_files: %s\ncan_open_uris: %s\nrequires_terminal: %s\n",
+ printf ("name: %s\ncommand: %s\ncan_open_multiple_files: %s\nexpects_uris: %s\nsupported_uri_schemes: %s\nrequires_terminal: %s\n",
application->name, application->command,
(application->can_open_multiple_files ? "TRUE" : "FALSE"),
- (application->can_open_uris ? "TRUE" : "FALSE"),
+ (application->expects_uris ? "TRUE" : "FALSE"),
+ format_supported_uri_schemes_for_display (application->supported_uri_schemes),
(application->requires_terminal ? "TRUE" : "FALSE"));
}
}