[gnome-logs/wip/gl-journal: 6/20] Handle matches in gl_journal_query()



commit 906db1a7c9683cfb48338c2f1bf4b418b0399b7f
Author: David King <davidk gnome org>
Date:   Wed Oct 2 20:04:54 2013 +0100

    Handle matches in gl_journal_query()

 src/gl-journal.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/gl-journal.c b/src/gl-journal.c
index 58f8e9a..cc09d8c 100644
--- a/src/gl-journal.c
+++ b/src/gl-journal.c
@@ -138,8 +138,8 @@ gl_journal_query (GlJournal *self, const GlJournalQuery *query)
 {
     GlJournalPrivate *priv;
     sd_journal *journal;
-    gint ret;
     gsize i;
+    gint ret;
     GList *results = NULL;
 
     g_return_val_if_fail (GL_JOURNAL (self), NULL);
@@ -148,6 +148,23 @@ gl_journal_query (GlJournal *self, const GlJournalQuery *query)
     priv = gl_journal_get_instance_private (self);
     journal = priv->journal;
 
+    if (query->matches)
+    {
+        const gchar *match;
+
+        for (i = 0, match = query->matches[i]; match;
+             match = query->matches[++i])
+        {
+            ret = sd_journal_add_match (journal, match, 0);
+
+            if (ret < 0)
+            {
+                g_warning ("Error adding match '%s': %s", match,
+                           g_strerror (-ret));
+            }
+        }
+    }
+
     ret = sd_journal_seek_tail (journal);
 
     if (ret < 0)
@@ -158,7 +175,6 @@ gl_journal_query (GlJournal *self, const GlJournalQuery *query)
 
     for (i = 0; i < query->n_results; i++)
     {
-        /* TODO: Handle matches. */
         GlJournalResult *result;
 
         const gchar *message;


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