[tracker/wip/carlosg/sparql-parser-ng: 279/306] libtracker-data: Implement SHA384



commit de4b355966a29c94550138eae89074660869d8c7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Apr 6 00:32:37 2018 +0200

    libtracker-data: Implement SHA384
    
    If glib >= 2.51.0 is available, we can implement this.

 src/libtracker-data/tracker-db-interface-sqlite.c | 4 ++++
 src/libtracker-data/tracker-sparql.c              | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 80c1eee8b..6faeb79ed 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1325,6 +1325,10 @@ function_sparql_checksum (sqlite3_context *context,
                checksum = G_CHECKSUM_SHA1;
        else if (g_ascii_strcasecmp (checksumstr, "sha256") == 0)
                checksum = G_CHECKSUM_SHA256;
+#if GLIB_CHECK_VERSION (2, 51, 0)
+       else if (g_ascii_strcasecmp (checksumstr, "sha384") == 0)
+               checksum = G_CHECKSUM_SHA384;
+#endif
        else if (g_ascii_strcasecmp (checksumstr, "sha512") == 0)
                checksum = G_CHECKSUM_SHA512;
        else {
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 4107991de..ad0c756bc 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -4921,7 +4921,12 @@ translate_BuiltInCall (TrackerSparql  *sparql,
                _append_string (sparql, ", \"sha256\") ");
                sparql->current_state.expression_type = TRACKER_PROPERTY_TYPE_STRING;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_SHA384)) {
-               _unimplemented ("SHA384");
+               _expect (sparql, RULE_TYPE_LITERAL, LITERAL_OPEN_PARENS);
+               _append_string (sparql, "SparqlChecksum (");
+               _call_rule (sparql, NAMED_RULE_Expression, error);
+               _expect (sparql, RULE_TYPE_LITERAL, LITERAL_CLOSE_PARENS);
+               _append_string (sparql, ", \"sha384\") ");
+               sparql->current_state.expression_type = TRACKER_PROPERTY_TYPE_STRING;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_SHA512)) {
                _expect (sparql, RULE_TYPE_LITERAL, LITERAL_OPEN_PARENS);
                _append_string (sparql, "SparqlChecksum (");


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