[gnome-photos/wip/foo: 4/13] query-builder: Add photos_query_builder_create_collection_query



commit 2649c290c6407f7d5d01cce8ab0e7e6019807eaa
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Mar 29 01:22:43 2013 +0100

    query-builder: Add photos_query_builder_create_collection_query

 src/photos-query-builder.c |   29 ++++++++++++++++++++++++++++-
 src/photos-query-builder.h |    4 +++-
 2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index cc2cc18..b0586f7 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -34,6 +34,9 @@
 #include "photos-search-type-manager.h"
 
 
+static const gchar * LOCAL_COLLECTIONS_IDENTIFIER = "photos:collection:local:";
+
+
 static gchar *
 photos_query_builder_convert_path_to_uri (const gchar *path)
 {
@@ -162,6 +165,30 @@ photos_query_builder_query (gboolean global, gint flags)
 
 
 PhotosQuery *
+photos_query_builder_create_collection_query (const gchar *name)
+{
+  GTimeVal tv;
+  gchar *sparql;
+  gchar *time;
+  gint64 timestamp;
+
+  timestamp = g_get_real_time () / G_USEC_PER_SEC;
+  tv.tv_sec = timestamp;
+  tv.tv_usec = 0;
+  time = g_time_val_to_iso8601 (&tv);
+
+  sparql = g_strconcat ("INSERT { _:res a nfo:DataContainer ; a nie:DataObject ; ",
+                        "nie:contentLastModified \"", time, "\" ; ",
+                        "nie:title \"", name, "\" ; ",
+                        "nao:identifier \"", LOCAL_COLLECTIONS_IDENTIFIER, name, "\" }",
+                        NULL);
+  g_free (time);
+
+  return photos_query_new (sparql);
+}
+
+
+PhotosQuery *
 photos_query_builder_count_favorites_query (void)
 {
   gchar *filter;
diff --git a/src/photos-query-builder.h b/src/photos-query-builder.h
index 46ae8aa..e92ff24 100644
--- a/src/photos-query-builder.h
+++ b/src/photos-query-builder.h
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 2013 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -31,6 +31,8 @@
 
 G_BEGIN_DECLS
 
+PhotosQuery  *photos_query_builder_create_collection_query (const gchar *name);
+
 PhotosQuery  *photos_query_builder_count_favorites_query (void);
 
 PhotosQuery  *photos_query_builder_count_query         (void);


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