[gnome-photos/wip/uajain/de_dup: 4/5] temp2



commit c47ce13b83518a2de8329d4326c182e2142e3aac
Author: Umang Jain <mailumangjain gmail com>
Date:   Fri Aug 26 03:21:27 2016 +0530

    temp2

 src/photos-base-item.c          |   50 +++++++++++++++++++++------------------
 src/photos-base-item.h          |    4 +--
 src/photos-share-point-google.c |    7 ++++-
 3 files changed, 33 insertions(+), 28 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 473fdc1..660f889 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -3439,44 +3439,48 @@ photos_base_item_trash (PhotosBaseItem *self)
 
 
 gboolean
-photos_base_item_add_metadata_to_local (PhotosBaseItem *item, const gchar *tag, const gchar *id)
+photos_base_item_add_metadata_to_local (PhotosBaseItem *item, const gchar *tag, gchar *id)
 {
   GExiv2Metadata *meta;
   GFile *file;
   const gchar *uri;
-  gchar *identifier;
+  const gchar *mime_type;
   gchar *path;
   GError *error = NULL;
   gboolean ret_val = FALSE;
 
-  meta = gexiv2_metadata_new ();
-
-  /*Can we do something better to get path ?*/
-  uri = photos_base_item_get_uri (item);
-  file = g_file_new_for_uri (uri);
-  path = g_file_get_path (file);
-  gexiv2_metadata_open_path (meta, path, &error);
-  if (error != NULL)
-    goto out;
-  else
+  mime_type = photos_base_item_get_mime_type (item);
+  if ((g_strcmp0 (mime_type, "image/png") == 0) ||
+      (g_strcmp0 (mime_type, "image/jpeg") == 0)||
+      (g_strcmp0 (mime_type, "image/jpg") == 0))
     {
-      if (gexiv2_metadata_has_tag (meta, tag))
-       gexiv2_metadata_clear_tag (meta, tag);
+      meta = gexiv2_metadata_new ();
 
-      identifier = g_strconcat ("google:picasaweb:", id, NULL);
-      gexiv2_metadata_set_tag_string (meta, tag, identifier);
-      gexiv2_metadata_save_file (meta, path, &error);
+      /*Can we do something better to get path ?*/
+      uri = photos_base_item_get_uri (item);
+      file = g_file_new_for_uri (uri);
+      path = g_file_get_path (file);
+      gexiv2_metadata_open_path (meta, path, &error);
+      if (error != NULL)
+        goto out;
+      else
+        {
+          if (gexiv2_metadata_has_tag (meta, tag))
+            gexiv2_metadata_clear_tag (meta, tag);
 
-      if (error)
-       goto out;
-      }
+          gexiv2_metadata_set_tag_string (meta, tag, id);
+          gexiv2_metadata_save_file (meta, path, &error);
 
-  ret_val = TRUE;
-  g_print("Metadata embedded successfully\n");
+          if (error)
+      goto out;
+          }
+
+      ret_val = TRUE;
+      g_print("Metadata embedded successfully\n");
+    }
 
 out:
   gexiv2_metadata_free (meta);
-  g_free (identifier);
   g_free (path);
   g_object_unref (file);
   g_object_unref (item);
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 2e00cc1..8d99414 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -101,9 +101,7 @@ struct _PhotosBaseItemClass
 
 GType               photos_base_item_get_type                (void) G_GNUC_CONST;
 
-gboolean           photos_base_item_add_metadata_to_local   (PhotosBaseItem *item,
-                                                             const gchar    *tag,
-                                                             const gchar    *id);
+gboolean photos_base_item_add_metadata_to_local (PhotosBaseItem *item, const gchar *tag, gchar *id);
 
 
 gboolean            photos_base_item_can_edit                (PhotosBaseItem *self);
diff --git a/src/photos-share-point-google.c b/src/photos-share-point-google.c
index f9a6389..1a1a5f2 100644
--- a/src/photos-share-point-google.c
+++ b/src/photos-share-point-google.c
@@ -300,6 +300,7 @@ photos_google_share_point_tracker_entry_created (GObject *source_object, GAsyncR
                                NULL,
                                NULL);
 
+  /*Not sure how to do this with Equipment*/
   make = gdata_picasaweb_file_get_make (data->file_entry);
   query = photos_query_builder_insert_or_replace (state, remote_urn, "nfo:manufacturer", make);
   photos_tracker_queue_update (self->queue,
@@ -354,7 +355,6 @@ photos_google_share_point_tracker_entry_created (GObject *source_object, GAsyncR
   photos_query_free (query);
 
   item_urn = photos_filterable_get_id (PHOTOS_FILTERABLE (data->item));
-  printf("Remote urn %s\n", remote_urn);
   photos_share_point_google_relate_objects (self, cancellable, remote_urn, item_urn);
 }
 
@@ -370,6 +370,7 @@ photos_share_point_google_create_tracker_entry (PhotosSharePointGoogle *self,
   GApplication *app;
   GCancellable *cancellable;
   const gchar *id;
+  gchar *identifier;
 
   app = g_application_get_default ();
   state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
@@ -388,7 +389,9 @@ photos_share_point_google_create_tracker_entry (PhotosSharePointGoogle *self,
   photos_query_free (query);
 
   data->item = PHOTOS_BASE_ITEM (g_object_ref (data->item));
-  photos_base_item_add_metadata_to_local (data->item, "Xmp.xmp.gnome-photos.google.identifier", id);
+  identifier = g_strconcat ("google:picasaweb:", id, NULL);
+  photos_base_item_add_metadata_to_local (data->item, "Xmp.xmp.gnome-photos.google.identifier", identifier);
+  g_free (identifier);
 }
 
 


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