After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 726919 - Use o.fd.Tracker1.Extract.Priority interface to prioritize relevant types
Use o.fd.Tracker1.Extract.Priority interface to prioritize relevant types
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
3.11.x
Other All
: Normal enhancement
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-03-23 13:55 UTC by Debarshi Ray
Modified: 2014-04-09 11:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WIP: basic implementation (5.97 KB, patch)
2014-04-03 14:25 UTC, Pranav Kant
needs-work Details | Review
Use o.fd.Tracker1.Extract.Priority interface to prioritize relevant types (9.07 KB, patch)
2014-04-03 22:27 UTC, Pranav Kant
needs-work Details | Review
Use o.fd.Tracker1.Extract.Priority interface to prioritize relevant types (8.48 KB, patch)
2014-04-04 19:52 UTC, Pranav Kant
needs-work Details | Review
application: Prioritize relevant rdf:types (8.58 KB, patch)
2014-04-09 11:27 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2014-03-23 13:55:04 UTC
Recently Tracker grew a feature where applications can specify the RDF types that are relevant to their application, and it will ensure that meta-data for instances of those types would be extracted as early as possible.

This sounds like a nice feature that we can make use of.
Comment 1 Pranav Kant 2014-04-03 14:25:20 UTC
Created attachment 273532 [details] [review]
WIP: basic implementation

this is just a WIP patch, please ignore any coding style issues if any or Makefile issues as I will adjust them once basic implementation goes fine.
Comment 2 Debarshi Ray 2014-04-03 15:40:21 UTC
Review of attachment 273532 [details] [review]:

Thanks for the patch, Pranav. You are moving in the right direction.

::: src/photos-application.c
@@ +834,3 @@
+  tracker_extract_priority_call_clear_rdf_types_sync (priv->trackerProxy,
+                                                      cancellable,
+                                                      &error);

This should not happen during dispose. GApplicationClass has a shutdown virtual method. It should be called asynchronously from there.

@@ +911,3 @@
+                                               cancellable,
+                                               photos_application_set_rdf_types_callback,
+                                               g_object_ref (self));

You got the order in which things happen during startup wrong. _application_startup happens after _application_init, so you can not call tracker_extract_priority_call_set_rdf_types here. It has to happen after tracker_extract_priority_proxy_new_for_bus_finish.
Comment 3 Pranav Kant 2014-04-03 22:27:11 UTC
Created attachment 273554 [details] [review]
Use o.fd.Tracker1.Extract.Priority interface to prioritize  relevant types
Comment 4 Debarshi Ray 2014-04-04 11:40:06 UTC
Review of attachment 273554 [details] [review]:

Thanks for the patch, Pranav!

::: src/photos-application.c
@@ +674,3 @@
+    {
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        g_warning ("Unable to create proxy: %s", error->message);

Nice attention to detail, but we can skip that because we passed a NULL GCancellable to tracker_extract_priority_proxy_new_for_bus.

@@ +680,3 @@
+
+  /* Calling SetRdfTypes on the proxy object. */
+  cancellable = g_cancellable_new ();

We don't need a GCancellable. See below for details.

@@ +681,3 @@
+  /* Calling SetRdfTypes on the proxy object. */
+  cancellable = g_cancellable_new ();
+  const gchar *const arg_rdf_types[] = {"nfo:Image", NULL};

This should go to the top of the block.

@@ +925,3 @@
+    {
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        g_warning ("Unable to call finish ClearRdfTypes: %s", error->message);

Nice attention to detail here, looking out for the operation being cancelled. However, we don't need it here because we don't need a GCancellable in our use-case. See below.

@@ +943,3 @@
+
+  cancellable = g_cancellable_new ();
+  g_object_set_data_full (G_OBJECT (priv->tracker_proxy), "cancellable", cancellable, g_object_unref);

Interesting hack - keeping a reference to the cancellable in the proxy.

However we don't need a GCancellable here because nobody else has a reference to it and we are taking an extra reference to the application (ie. self) while the async operation is going on. That means that there is no one who is going to actually cancel the operation and the application will not be disposed until the async operation finishes. We can just pass NULL as the parameter.

In case we did have to use a GCancellable, the async operation usually keeps a reference to the cancellable for the duration of the operation. So you don't need to worry about it getting disposed while the operation was going on or something.
Comment 5 Pranav Kant 2014-04-04 19:52:53 UTC
Created attachment 273604 [details] [review]
Use o.fd.Tracker1.Extract.Priority interface to prioritize  relevant types
Comment 6 Debarshi Ray 2014-04-09 11:25:11 UTC
Review of attachment 273604 [details] [review]:

Thanks for the patch, Pranav! Looks much better now, apart from a few small issues.

::: src/photos-application.c
@@ +645,3 @@
+  PhotosApplication *self = PHOTOS_APPLICATION (user_data);
+  GError *error = NULL;
+  TrackerExtractPriority *tracker_proxy = TRACKER_EXTRACT_PRIORITY (source_object);

You could just use self->priv->extract_priority instead.

@@ +656,3 @@
+ out:
+  g_object_unref (self);
+  g_object_unref (tracker_proxy);

Don't unref the tracker_proxy. You don't own a reference to this, so if you drop the reference count then the proxy object might get finalized and you will not be able to use priv->tracker_proxy in future.

Instead we should drop the reference count on priv->tracker_proxy in _finalize.

@@ +667,3 @@
+  PhotosApplication *self = PHOTOS_APPLICATION (user_data);
+  PhotosApplicationPrivate *priv = self->priv;
+  

Trailing whitespace alert! You can configure Git to mark them for you.

@@ +936,3 @@
+                                                 NULL,
+                                                 photos_application_tracker_clear_rdf_types_callback,
+                                                 g_object_ref (self));

You should chain up to the parent's shutdown method (like in dispose). Otherwise you get a CRITICAL.
Comment 7 Debarshi Ray 2014-04-09 11:25:59 UTC
Review of attachment 273604 [details] [review]:

One more thing. The Git commit message should not exceed 72 characters per line. See https://wiki.gnome.org/Git/CommitMessages
Comment 8 Debarshi Ray 2014-04-09 11:27:00 UTC
Created attachment 273882 [details] [review]
application: Prioritize relevant rdf:types

I fixed up the issues in the previous patch.
Comment 9 Debarshi Ray 2014-04-09 11:32:38 UTC
Thanks for your work on this.