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 731865 - Make it easier to support new sources
Make it easier to support new sources
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-06-18 15:57 UTC by Debarshi Ray
Modified: 2014-09-26 09:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
base-item: Mark it as an abstract type (1.25 KB, patch)
2014-06-18 16:11 UTC, Debarshi Ray
committed Details | Review
Turn the PhotosBaseItem sub-classes into extensions (6.50 KB, patch)
2014-06-18 16:12 UTC, Debarshi Ray
committed Details | Review
item-manager: Make use of extensions to create item (4.58 KB, patch)
2014-06-19 11:04 UTC, Pranav Kant
needs-work Details | Review
item-manager: Make use of extensions to create item (6.67 KB, patch)
2014-06-23 13:17 UTC, Pranav Kant
none Details | Review
item-manager: Make use of extensions to create items (6.53 KB, patch)
2014-06-23 14:06 UTC, Debarshi Ray
committed Details | Review
properties-dialog: do item related tasks in respective subclasses. (8.68 KB, patch)
2014-06-23 15:27 UTC, Pranav Kant
committed Details | Review
Use ProviderName from the GoaObject whenever applicable (5.65 KB, patch)
2014-07-01 12:32 UTC, Debarshi Ray
committed Details | Review
src: Cleanup unnecessary inclusion of header files (1.93 KB, patch)
2014-07-10 10:47 UTC, Saurav Agarwalla
committed Details | Review
application: Make use of extensions to run the miners (10.69 KB, patch)
2014-09-09 17:51 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2014-06-18 15:57:43 UTC
Currently we have to sprinkle code all over the place (start the miners, properties dialog, item manager, search provider, etc.) in order to add support for a new content source. Instead it should be possible to do bulk of that by just writing a new PhotosBaseItem subclass.
Comment 1 Debarshi Ray 2014-06-18 16:11:45 UTC
Created attachment 278699 [details] [review]
base-item: Mark it as an abstract type
Comment 2 Debarshi Ray 2014-06-18 16:12:16 UTC
Created attachment 278700 [details] [review]
Turn the PhotosBaseItem sub-classes into extensions
Comment 3 Pranav Kant 2014-06-19 11:04:35 UTC
Created attachment 278755 [details] [review]
item-manager: Make use of extensions to create item

Fixes: https://bugzilla.gnome.org/731865
Comment 4 Pranav Kant 2014-06-19 11:19:33 UTC
Review of attachment 278700 [details] [review]:

What if we provide the macro for extension point names instead of hard coding the string ?
Comment 5 Debarshi Ray 2014-06-23 12:00:44 UTC
(In reply to comment #4)
> Review of attachment 278700 [details] [review]:
> 
> What if we provide the macro for extension point names instead of hard coding
> the string ?

Yes, we should eventually do something about that. The reason I did not do it now is that we use strings like "flickr" all over the codebase for all sorts of reasons, and I was not sure what would be the best way to do it that would address most of these cases.

Maybe you have some ideas.

Otherwise we can do that once we have addressed the bigger issues one by one.
Comment 6 Pranav Kant 2014-06-23 12:04:16 UTC
Review of attachment 278699 [details] [review]:

OK
Comment 7 Debarshi Ray 2014-06-23 12:07:03 UTC
Comment on attachment 278699 [details] [review]
base-item: Mark it as an abstract type

Thanks for the review, Pranav.
Comment 8 Pranav Kant 2014-06-23 12:35:27 UTC
Review of attachment 278700 [details] [review]:

look ok.
Comment 9 Debarshi Ray 2014-06-23 12:49:47 UTC
Review of attachment 278755 [details] [review]:

Thanks for the patch, Pranav. This is exactly what I had in mind. Some minor comments.

::: src/photos-facebook-item.c
@@ -279,3 @@
-                       "failed-thumbnailing", FALSE,
-                       NULL);
-}

You should also remove the function prototypes from the headers.

::: src/photos-flickr-item.c
@@ -381,3 @@
-                       "failed-thumbnailing", FALSE,
-                       NULL);
-}

Ditto.

::: src/photos-item-manager.c
@@ +38,3 @@
 #include "photos-tracker-change-event.h"
 #include "photos-tracker-change-monitor.h"
+#include "photos-utils.h"

You removed an extra newline.

@@ +310,3 @@
   gchar *identifier = NULL;
+  gchar **split_identifier = NULL;
+  gchar *extension_name = NULL;

extension_name should be a 'const gchar *' because it is not supposed to be freed. Nothing wrong with what you have done. It is just a matter of convention in GLib code / API.

@@ +316,2 @@
   identifier = g_strdup (tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_IDENTIFIER, NULL));
+  extension_name = "local";

You could just initialize it to "local" instead of NULL in the definition above.

@@ +334,3 @@
 
+ final:
+  extension_point = g_io_extension_point_lookup (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME);

Instead of doing it here, I think it would be better to have a priv->extension_point which is assigned to in photos_item_manager_init. Even though g_io_extension_point_lookup is only as expensive as a hashtable lookup, photos_item_manager_create_item will be called for each item in the application. So it is better to keep it as lean as possible.

@@ +335,3 @@
+ final:
+  extension_point = g_io_extension_point_lookup (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME);
+  extension = g_io_extension_point_get_extension_by_name (extension_point, extension_name);

I think that it would be better to have a g_warning for the 'if (G_UNLIKELY (extension == NULL))' case. It shouldn't happen, unless say local items start having identifiers like 'foo:bar:baz:...' for some reason. Would be good to have some indication in the logs if that occurs.

@@ +337,3 @@
+  extension = g_io_extension_point_get_extension_by_name (extension_point, extension_name);
+  if (extension != NULL)
+    ret_val = PHOTOS_BASE_ITEM (g_object_new (g_io_extension_get_type (extension),

Can you please split the g_io_extension_get_type into a separate statement?
Comment 10 Pranav Kant 2014-06-23 13:17:49 UTC
Created attachment 279000 [details] [review]
item-manager: Make use of extensions to create item

Fixes: https://bugzilla.gnome.org/731865
Comment 11 Debarshi Ray 2014-06-23 14:06:03 UTC
Created attachment 279022 [details] [review]
item-manager: Make use of extensions to create items

Committed after tweaking the error message to contain the name of the extension and the identifier.
Comment 12 Pranav Kant 2014-06-23 15:27:58 UTC
Created attachment 279044 [details] [review]
properties-dialog: do item related tasks in respective subclasses.
Comment 13 Debarshi Ray 2014-06-23 16:50:47 UTC
Review of attachment 279044 [details] [review]:

Perfect.
Comment 14 Debarshi Ray 2014-07-01 12:32:46 UTC
Created attachment 279673 [details] [review]
Use ProviderName from the GoaObject whenever applicable
Comment 15 Pranav Kant 2014-07-02 11:49:21 UTC
Review of attachment 279673 [details] [review]:

looks OK.
Comment 16 Debarshi Ray 2014-07-03 11:31:33 UTC
Comment on attachment 279673 [details] [review]
Use ProviderName from the GoaObject whenever applicable

Thanks for the review, Pranav.
Comment 17 Saurav Agarwalla 2014-07-10 10:47:31 UTC
Created attachment 280381 [details] [review]
src: Cleanup unnecessary inclusion of header files
Comment 18 Debarshi Ray 2014-07-10 13:11:51 UTC
Review of attachment 280381 [details] [review]:

Thanks for the patch, Saurav. Perfect!
Comment 19 Debarshi Ray 2014-09-09 17:51:01 UTC
Created attachment 285760 [details] [review]
application: Make use of extensions to run the miners
Comment 20 Debarshi Ray 2014-09-26 09:27:04 UTC
We have taken care of most of the big issues here. We can use separate bugs for further adjustments.