[gnome-photos/wip/flickr: 4/4] flickr



commit b37990ddc7cf6e5dcac80c270a85be2ae53ec11a
Author: Marek Chalupa <mchalupa redhat com>
Date:   Mon Jul 1 11:35:15 2013 +0200

    flickr

 src/photos-item-manager.c   |   18 +++++++++++++++++-
 src/photos-query-builder.c  |    8 ++++++++
 src/photos-query.c          |    1 +
 src/photos-query.h          |    1 +
 src/photos-source-manager.c |    7 +++----
 src/photos-source.c         |    6 ++++--
 6 files changed, 34 insertions(+), 7 deletions(-)
---
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index b20943a..e9b361c 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -30,6 +30,7 @@
 #include "photos-collection-manager.h"
 #include "photos-item-manager.h"
 #include "photos-local-item.h"
+#include "photos-flickr-item.h"
 #include "photos-query.h"
 #include "photos-single-item-job.h"
 #include "photos-tracker-change-event.h"
@@ -265,5 +266,20 @@ photos_item_manager_add_item (PhotosItemManager *self, TrackerSparqlCursor *curs
 PhotosBaseItem *
 photos_item_manager_create_item (PhotosItemManager *self, TrackerSparqlCursor *cursor)
 {
-  return photos_local_item_new (cursor);
+  PhotosBaseItem *ret_val = NULL;
+  gchar *identifier = NULL;
+
+  identifier = g_strdup (tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_IDENTIFIER, NULL));
+  g_message ("%s", identifier);
+
+  if (identifier != NULL)
+    {
+      if (g_str_has_prefix (identifier, "flickr:"))
+        ret_val = photos_flickr_item_new (cursor);
+    }
+  else
+    ret_val = photos_local_item_new (cursor);
+
+  g_free (identifier);
+  return ret_val;
 }
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 44f9cfe..914eb8e 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -385,3 +385,11 @@ photos_query_builder_filter_local (void)
 
   return filter;
 }
+
+gchar *
+photos_query_builder_filter_flickr (void)
+{
+  return g_strdup_printf ("(fn:starts-with (nao:identifier (?urn), \"%s\"))"
+                          "|| (fn:starts-with (nao:identifier (?urn), \"flickr:\"))",
+                          PHOTOS_QUERY_FLICKR_COLLECTIONS_IDENTIFIER);
+}
diff --git a/src/photos-query.c b/src/photos-query.c
index 06d9b2e..58c9173 100644
--- a/src/photos-query.c
+++ b/src/photos-query.c
@@ -31,6 +31,7 @@
 
 const gchar *PHOTOS_QUERY_COLLECTIONS_IDENTIFIER = "photos:collection:";
 const gchar *PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER = "photos:collection:local:";
+const gchar *PHOTOS_QUERY_FLICKR_COLLECTIONS_IDENTIFIER = "photos:collection:flickr:";
 
 
 PhotosQuery *
diff --git a/src/photos-query.h b/src/photos-query.h
index 7d5f7c9..67141ba 100644
--- a/src/photos-query.h
+++ b/src/photos-query.h
@@ -59,6 +59,7 @@ typedef enum
 
 extern const gchar *PHOTOS_QUERY_COLLECTIONS_IDENTIFIER;
 extern const gchar *PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER;
+extern const gchar *PHOTOS_QUERY_FLICKR_COLLECTIONS_IDENTIFIER;
 
 typedef struct _PhotosQuery PhotosQuery;
 
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index 9651aab..b1b2346 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -91,10 +91,9 @@ photos_source_manager_refresh_accounts (PhotosSourceManager *self)
       if (goa_object_peek_account (GOA_OBJECT (l->data)) == NULL)
         continue;
 
-      /* TODO: uncomment when we start supporting online providers */
-      /* source = photos_source_new_from_goa_object (GOA_OBJECT (l->data)); */
-      /* photos_base_manager_add_object (PHOTOS_BASE_MANAGER (self), G_OBJECT (source)); */
-      /* g_object_unref (source); */
+      source = photos_source_new_from_goa_object (GOA_OBJECT (l->data));
+      photos_base_manager_add_object (PHOTOS_BASE_MANAGER (self), G_OBJECT (source));
+      g_object_unref (source);
     }
 
   g_list_free_full (accounts, g_object_unref);
diff --git a/src/photos-source.c b/src/photos-source.c
index b93f246..2795416 100644
--- a/src/photos-source.c
+++ b/src/photos-source.c
@@ -31,7 +31,6 @@
 #include "photos-query-builder.h"
 #include "photos-source.h"
 
-
 struct _PhotosSourcePrivate
 {
   GIcon *icon;
@@ -82,7 +81,10 @@ photos_source_get_filter (PhotosFilterable *iface)
     return photos_query_builder_filter_local ();
 
   if (g_strcmp0 (priv->id, PHOTOS_SOURCE_STOCK_ALL) == 0)
-    return photos_query_builder_filter_local (); /* TODO: Add non local query */
+    return photos_query_builder_filter_local ();
+
+  /* if (g_strcmp0 (priv->id, PHOTOS_SOURCE_STOCK_FLICKR) == 0) */
+  /*   return photos_query_builder_filter_flickr (); */
 
   return photos_source_build_filter_resource (self);
 }


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