[gnome-online-miners/wip/owncloud: 3/5] utils: Replace gom_filename_to_mime_type with g_content_type_guess



commit 40e76e546e939b31015f5f6f39556a6d540bf299
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Aug 16 20:24:59 2013 +0200

    utils: Replace gom_filename_to_mime_type with g_content_type_guess
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706157

 src/gom-utils.c     |   16 ----------------
 src/gom-utils.h     |    2 --
 src/gom-zpj-miner.c |    6 ++++--
 3 files changed, 4 insertions(+), 20 deletions(-)
---
diff --git a/src/gom-utils.c b/src/gom-utils.c
index 0d5b042..47df0e7 100644
--- a/src/gom-utils.c
+++ b/src/gom-utils.c
@@ -51,22 +51,6 @@ gom_filename_get_extension_offset (const char *filename)
        return end;
 }
 
-const char *
-gom_filename_to_mime_type (const gchar *filename_with_extension)
-{
-  const gchar *extension;
-  const gchar *type = NULL;
-
-  g_return_val_if_fail (filename_with_extension != NULL, NULL);
-
-  extension = gom_filename_get_extension_offset (filename_with_extension);
-
-  if (g_strcmp0 (extension, ".pdf") == 0)
-    type = "application/pdf";
-
-  return type;
-}
-
 const gchar *
 gom_filename_to_rdf_type (const gchar *filename_with_extension)
 {
diff --git a/src/gom-utils.h b/src/gom-utils.h
index 0d19332..7f77339 100644
--- a/src/gom-utils.h
+++ b/src/gom-utils.h
@@ -28,8 +28,6 @@
 
 G_BEGIN_DECLS
 
-const gchar *gom_filename_to_mime_type (const gchar *filename_with_extension);
-
 const gchar *gom_filename_to_rdf_type (const gchar *filename_with_extension);
 
 gchar *gom_iso8601_from_timestamp (gint64 timestamp);
diff --git a/src/gom-zpj-miner.c b/src/gom-zpj-miner.c
index 097fb3e..8c037d6 100644
--- a/src/gom-zpj-miner.c
+++ b/src/gom-zpj-miner.c
@@ -107,7 +107,8 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
   if (ZPJ_IS_SKYDRIVE_FILE (entry))
     {
       gchar *parent_resource_urn, *parent_identifier;
-      const gchar *parent_id, *mime;
+      gchar *mime;
+      const gchar *parent_id;
 
       parent_id = zpj_skydrive_entry_get_parent_id (entry);
       parent_identifier = g_strconcat ("gd:collection:windows-live:skydrive:", parent_id, NULL);
@@ -131,7 +132,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
       if (*error != NULL)
         goto out;
 
-      mime = gom_filename_to_mime_type (name);
+      mime = g_content_type_guess (name, NULL, 0, NULL);
       if (mime != NULL)
         {
           gom_tracker_sparql_connection_insert_or_replace_triple
@@ -139,6 +140,7 @@ account_miner_job_process_entry (GomAccountMinerJob *job,
              job->cancellable, error,
              job->datasource_urn, resource,
              "nie:mimeType", mime);
+          g_free (mime);
 
           if (*error != NULL)
             goto out;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]