[gnome-autoar] Revert "mime-types: use g_content_type_is_a for mime support"
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-autoar] Revert "mime-types: use g_content_type_is_a for mime support"
- Date: Tue, 21 Mar 2017 12:11:36 +0000 (UTC)
commit 578aeeceaa22bd75482f7ae14555655ba0fa8e7e
Author: Carlos Soriano <csoriano gnome org>
Date: Tue Mar 21 12:50:21 2017 +0100
Revert "mime-types: use g_content_type_is_a for mime support"
This reverts d7e45a2627d026b86aa518984fad48b5ff76ffb8
It gives more problems than it solves. For example docx is a subtype of zip,
which makes autoar report it as supported, when it's not.
So it's better to use the subtypes that autoar supports directly.
https://bugzilla.gnome.org/show_bug.cgi?id=780214
gnome-autoar/autoar-mime-types.c | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/gnome-autoar/autoar-mime-types.c b/gnome-autoar/autoar-mime-types.c
index fd86bdb..9c8c46f 100644
--- a/gnome-autoar/autoar-mime-types.c
+++ b/gnome-autoar/autoar-mime-types.c
@@ -37,8 +37,25 @@ static gchar *supported_mime_types[] = {
"application/x-xz",
"application/zip",
"application/gzip",
+ NULL
};
+static GHashTable *supported_mime_types_table = NULL;
+
+static void
+initialize_supported_mime_types_table (void)
+{
+ int i;
+
+ supported_mime_types_table = g_hash_table_new (g_str_hash,
+ g_str_equal);
+
+ for (i = 0; supported_mime_types[i] != NULL; ++i) {
+ g_hash_table_add (supported_mime_types_table,
+ supported_mime_types[i]);
+ }
+}
+
/**
* autoar_check_mime_type_supported:
* @mime_type: a string representing the mime type
@@ -51,17 +68,11 @@ static gchar *supported_mime_types[] = {
gboolean
autoar_check_mime_type_supported (const gchar *mime_type)
{
- gint i;
- gboolean supported = FALSE;
-
- for (i = 0; i < G_N_ELEMENTS (supported_mime_types); i++) {
- if (g_content_type_is_a (mime_type, supported_mime_types[i])) {
- supported = TRUE;
- break;
- }
+ if (supported_mime_types_table == NULL) {
+ initialize_supported_mime_types_table ();
}
- return supported;
+ return g_hash_table_contains (supported_mime_types_table, mime_type);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]