[libgdata/wip/rishi/drive: 2/4] core: Add internal helper API for adding query strings



commit f7bb939c355c94ba4a2ae317f2f736a8b9b29946
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Apr 24 11:31:16 2015 +0200

    core: Add internal helper API for adding query strings
    
    In the Drive v2 API, certain GDataDocumentsQuery properties like
    show-deleted and show-folders no longer have their own parameters, but
    have to be specified as a search clause in the query string. This will
    be used internally by child classes of GDataQuery to add search clauses
    that represent service-specific query properties.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684920

 gdata/gdata-private.h |    2 ++
 gdata/gdata-query.c   |   42 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/gdata/gdata-private.h b/gdata/gdata-private.h
index 53d0bd5..483c1a4 100644
--- a/gdata/gdata-private.h
+++ b/gdata/gdata-private.h
@@ -71,6 +71,8 @@ G_GNUC_INTERNAL GDataSecureString _gdata_service_secure_strndup (const gchar *st
 G_GNUC_INTERNAL void _gdata_service_secure_strfree (GDataSecureString str);
 
 #include "gdata-query.h"
+G_GNUC_INTERNAL void _gdata_query_add_q_internal (GDataQuery *self, const gchar *q);
+G_GNUC_INTERNAL void _gdata_query_clear_q_internal (GDataQuery *self);
 G_GNUC_INTERNAL void _gdata_query_set_next_uri (GDataQuery *self, const gchar *next_uri);
 G_GNUC_INTERNAL void _gdata_query_set_next_uri_end (GDataQuery *self);
 G_GNUC_INTERNAL gboolean _gdata_query_is_finished (GDataQuery *self);
diff --git a/gdata/gdata-query.c b/gdata/gdata-query.c
index a2a7cd8..4302f87 100644
--- a/gdata/gdata-query.c
+++ b/gdata/gdata-query.c
@@ -2,6 +2,7 @@
 /*
  * GData Client
  * Copyright (C) Philip Withnall 2009–2010 <philip tecnocode co uk>
+ * Copyright (C) Red Hat, Inc. 2015
  *
  * GData Client is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -56,6 +57,7 @@ static void get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *que
 struct _GDataQueryPrivate {
        /* Standard query parameters (see: http://code.google.com/apis/gdata/docs/2.0/reference.html#Queries) 
*/
        gchar *q;
+       gchar *q_internal;
        gchar *categories;
        gchar *author;
        gint64 updated_min;
@@ -301,6 +303,7 @@ gdata_query_finalize (GObject *object)
        GDataQueryPrivate *priv = GDATA_QUERY (object)->priv;
 
        g_free (priv->q);
+       g_free (priv->q_internal);
        g_free (priv->categories);
        g_free (priv->author);
        g_free (priv->next_uri);
@@ -417,10 +420,14 @@ get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboo
        }
 
        /* q param */
-       if (priv->q != NULL) {
+       if (priv->q != NULL || priv->q_internal != NULL) {
                APPEND_SEP
                g_string_append (query_uri, "q=");
-               g_string_append_uri_escaped (query_uri, priv->q, NULL, FALSE);
+
+               if (priv->q != NULL)
+                       g_string_append_uri_escaped (query_uri, priv->q, NULL, FALSE);
+               if (priv->q_internal != NULL)
+                       g_string_append_uri_escaped (query_uri, priv->q_internal, NULL, FALSE);
        }
 
        if (priv->author != NULL) {
@@ -561,6 +568,37 @@ gdata_query_get_query_uri (GDataQuery *self, const gchar *feed_uri)
        return g_string_free (query_uri, FALSE);
 }
 
+void
+_gdata_query_add_q_internal (GDataQuery *self, const gchar *q)
+{
+       GDataQueryPrivate *priv = self->priv;
+       GString *str;
+
+       g_return_if_fail (GDATA_IS_QUERY (self));
+       g_return_if_fail (q != NULL && q[0] != '\0');
+
+       str = g_string_new (priv->q_internal);
+
+       if (priv->q_internal != NULL && priv->q_internal[0] != '\0')
+               g_string_append (str, " and ");
+
+       g_string_append (str, q);
+
+       g_free (priv->q_internal);
+       priv->q_internal = g_string_free (str, FALSE);
+}
+
+void
+_gdata_query_clear_q_internal (GDataQuery *self)
+{
+       GDataQueryPrivate *priv = self->priv;
+
+       g_return_if_fail (GDATA_IS_QUERY (self));
+
+       g_free (priv->q_internal);
+       priv->q_internal = NULL;
+}
+
 /**
  * gdata_query_get_q:
  * @self: a #GDataQuery


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