[grilo-plugins/wip/carlosg/tracker3: 32/39] tracker3: Clean up no longer used code



commit 4fd741c966975f6dbe5440aad7edfd20fb16c7e5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 24 18:18:19 2020 +0200

    tracker3: Clean up no longer used code
    
    The utils code to create sparql queries is no unused, this can
    be removed.

 src/tracker3/grl-tracker-utils.c | 223 ---------------------------------------
 src/tracker3/grl-tracker-utils.h |  12 ---
 2 files changed, 235 deletions(-)
---
diff --git a/src/tracker3/grl-tracker-utils.c b/src/tracker3/grl-tracker-utils.c
index 48f4c2ed..f0fbd5a9 100644
--- a/src/tracker3/grl-tracker-utils.c
+++ b/src/tracker3/grl-tracker-utils.c
@@ -543,229 +543,6 @@ grl_tracker_key_is_supported (const GrlKeyID key)
 
 /**/
 
-gchar *
-grl_tracker_source_get_select_string (const GList *keys)
-{
-  const GList *key = keys;
-  GString *gstr = g_string_new ("");
-  GList *assoc_list;
-  tracker_grl_sparql_t *assoc;
-
-  assoc_list = get_mapping_from_grl (grl_metadata_key_tracker_urn);
-  assoc = (tracker_grl_sparql_t *) assoc_list->data;
-  g_string_append_printf (gstr, "%s AS ?%s ",
-                          assoc->sparql_key_attr_call,
-                          assoc->sparql_key_name);
-
-  while (key != NULL) {
-    assoc_list = get_mapping_from_grl (GRLPOINTER_TO_KEYID (key->data));
-    while (assoc_list != NULL) {
-      assoc = (tracker_grl_sparql_t *) assoc_list->data;
-      if (assoc != NULL) {
-        g_string_append_printf (gstr, "%s AS ?%s ",
-                                assoc->sparql_key_attr_call,
-                                assoc->sparql_key_name);
-      }
-      assoc_list = assoc_list->next;
-    }
-    key = key->next;
-  }
-
-  return g_string_free (gstr, FALSE);
-}
-
-static void
-gen_prop_insert_string (GString *gstr,
-                        tracker_grl_sparql_t *assoc,
-                        GrlData *data)
-{
-  gchar *tmp;
-  GType type = GRL_METADATA_KEY_GET_TYPE (assoc->grl_key);
-
-  switch (type) {
-  case G_TYPE_STRING:
-    tmp = g_strescape (grl_data_get_string (data, assoc->grl_key), NULL);
-    g_string_append_printf (gstr, "%s \"%s\"",
-                            assoc->sparql_key_attr, tmp);
-    g_free (tmp);
-    break;
-
-  case G_TYPE_INT:
-    g_string_append_printf (gstr, "%s %i",
-                            assoc->sparql_key_attr,
-                            grl_data_get_int (data, assoc->grl_key));
-    break;
-
-  case G_TYPE_FLOAT:
-    g_string_append_printf (gstr, "%s %f",
-                            assoc->sparql_key_attr,
-                            grl_data_get_float (data, assoc->grl_key));
-    break;
-
-  case G_TYPE_BOOLEAN:
-    /* Special case for favourite tag, see comment in
-     * grl_tracker_tracker_get_insert_string for more details.
-     */
-    if (assoc->grl_key == GRL_METADATA_KEY_FAVOURITE) {
-      g_string_append_printf (gstr, "%s nao:predefined-tag-favorite",
-                              assoc->sparql_key_attr);
-    }
-    break;
-
-  default:
-    if (type == G_TYPE_DATE_TIME) {
-      tmp = g_date_time_format (grl_data_get_boxed (data, assoc->grl_key),
-                                "%FT%T%:z");
-      g_string_append_printf (gstr, "%s '%s'",
-                              assoc->sparql_key_attr,
-                              tmp);
-
-      g_free (tmp);
-    }
-    break;
-  }
-}
-
-gchar *
-grl_tracker_tracker_get_insert_string (GrlMedia *media, const GList *keys)
-{
-  gboolean first = TRUE;
-  const GList *key;
-  GString *gstr = g_string_new ("");
-
-  for (key = keys; key != NULL; key = key->next) {
-    const GList *assoc_list;
-    GrlKeyID key_id = GRLPOINTER_TO_KEYID (key->data);
-
-    for (assoc_list = get_mapping_from_grl (key_id);
-         assoc_list != NULL;
-         assoc_list = assoc_list->next) {
-      tracker_grl_sparql_t *assoc = assoc_list->data;
-
-      if (assoc == NULL)
-        continue;
-
-      /* The favourite key is really setting or deleting a tag
-       * in tracker, so in the case of setting it to false skip
-       * the insert string creation step for this key completely.
-       */
-      if (assoc->grl_key == GRL_METADATA_KEY_FAVOURITE &&
-          !grl_media_get_favourite (media))
-        continue;
-
-      if (!grl_data_has_key (GRL_DATA (media), key_id))
-        continue;
-
-      /* Special case for key title, nfo:fileName is read-only.
-       * It cannot be modified.
-       */
-      if (assoc->grl_key == GRL_METADATA_KEY_TITLE &&
-          g_strcmp0 (assoc->sparql_key_attr, "nfo:fileName") == 0) {
-        continue;
-      }
-
-      if (!first)
-        g_string_append (gstr, " ; ");
-
-      gen_prop_insert_string (gstr, assoc, GRL_DATA (media));
-      first = FALSE;
-    }
-  }
-
-  return g_string_free (gstr, FALSE);
-}
-
-gchar *
-grl_tracker_get_delete_string (const GList *keys)
-{
-  gboolean first = TRUE;
-  const GList *key = keys, *assoc_list;
-  tracker_grl_sparql_t *assoc;
-  GString *gstr = g_string_new ("");
-  gchar *ret;
-  gint var_n = 0;
-
-  while (key != NULL) {
-    assoc_list = get_mapping_from_grl (GRLPOINTER_TO_KEYID (key->data));
-    while (assoc_list != NULL) {
-      assoc = (tracker_grl_sparql_t *) assoc_list->data;
-      if (assoc != NULL) {
-        /* Special case for key title, nfo:fileName is read-only.
-         * It cannot be modified.
-         */
-        if (assoc->grl_key == GRL_METADATA_KEY_TITLE &&
-            g_strcmp0 (assoc->sparql_key_attr, "nfo:fileName") == 0) {
-          assoc_list = assoc_list->next;
-          continue;
-        }
-
-        if (first) {
-          g_string_append_printf (gstr, "%s ?v%i",
-                                  assoc->sparql_key_attr, var_n);
-          first = FALSE;
-        } else {
-          g_string_append_printf (gstr, " ; %s ?v%i",
-                                  assoc->sparql_key_attr, var_n);
-        }
-        var_n++;
-      }
-      assoc_list = assoc_list->next;
-    }
-    key = key->next;
-  }
-
-  ret = gstr->str;
-  g_string_free (gstr, FALSE);
-
-  return ret;
-}
-
-gchar *
-grl_tracker_get_delete_conditional_string (const gchar *urn,
-                                           const GList *keys)
-{
-  gboolean first = TRUE;
-  const GList *key = keys, *assoc_list;
-  tracker_grl_sparql_t *assoc;
-  GString *gstr = g_string_new ("");
-  gchar *ret;
-  gint var_n = 0;
-
-  while (key != NULL) {
-    assoc_list = get_mapping_from_grl (GRLPOINTER_TO_KEYID (key->data));
-    while (assoc_list != NULL) {
-      assoc = (tracker_grl_sparql_t *) assoc_list->data;
-      if (assoc != NULL) {
-        /* Special case for key title, nfo:fileName is read-only.
-         * It cannot be modified.
-         */
-        if (assoc->grl_key == GRL_METADATA_KEY_TITLE &&
-            g_strcmp0 (assoc->sparql_key_attr, "nfo:fileName") == 0) {
-          assoc_list = assoc_list->next;
-          continue;
-        }
-
-        if (first) {
-          g_string_append_printf (gstr, "OPTIONAL { <%s>  %s ?v%i }",
-                                  urn,  assoc->sparql_key_attr, var_n);
-          first = FALSE;
-        } else {
-          g_string_append_printf (gstr, " . OPTIONAL { <%s> %s ?v%i }",
-                                  urn, assoc->sparql_key_attr, var_n);
-        }
-        var_n++;
-      }
-      assoc_list = assoc_list->next;
-    }
-    key = key->next;
-  }
-
-  ret = gstr->str;
-  g_string_free (gstr, FALSE);
-
-  return ret;
-}
-
 static GrlMedia *
 grl_tracker_build_grilo_media_default (GHashTable *ht)
 {
diff --git a/src/tracker3/grl-tracker-utils.h b/src/tracker3/grl-tracker-utils.h
index e4a5a99e..74e2989f 100644
--- a/src/tracker3/grl-tracker-utils.h
+++ b/src/tracker3/grl-tracker-utils.h
@@ -83,16 +83,4 @@ tracker_grl_sparql_t *grl_tracker_get_mapping_from_sparql (const gchar *key);
 GrlMedia *grl_tracker_build_grilo_media (const gchar   *rdf_type,
                                          GrlTypeFilter  type_filter);
 
-gchar *grl_tracker_source_get_device_constraint (GrlTrackerSourcePriv *priv);
-
-gchar *grl_tracker_source_get_select_string (const GList *keys);
-
-gchar *grl_tracker_tracker_get_insert_string (GrlMedia *media,
-                                              const GList *keys);
-
-gchar *grl_tracker_get_delete_string (const GList *keys);
-
-gchar *grl_tracker_get_delete_conditional_string (const gchar *urn,
-                                                  const GList *keys);
-
 #endif /* _GRL_TRACKER_UTILS_H_ */


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