mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
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
This commit is contained in:
parent
2717a5cdd3
commit
5dfee0c35d
8 changed files with 136 additions and 18 deletions
26
ChangeLog
26
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>
|
||||
|
|
|
@ -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. */
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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. */
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue