[polari/wip/fmuellner/tracker: 323/335] lib: Add utility method to get tracker connection



commit afd0427cc598b7b6957e29ce102341d1533dd13b
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jul 25 02:41:04 2017 +0200

    lib: Add utility method to get tracker connection

 meson.build           |  1 +
 src/lib/polari-util.c | 33 +++++++++++++++++++++++++++++++++
 src/lib/polari-util.h |  3 +++
 src/meson.build       | 13 ++++++++++---
 4 files changed, 47 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 1409298..6ff3f80 100644
--- a/meson.build
+++ b/meson.build
@@ -37,6 +37,7 @@ gio = dependency('gio-2.0', version: '>= 2.43.4')
 gtk3 = dependency('gtk+-3.0', version: '>= 3.21.6')
 telepathy_glib = dependency('telepathy-glib')
 telepathy_logger = dependency('telepathy-logger-0.2')
+tracker = dependency('tracker-sparql-2.0')
 girepository = dependency('gobject-introspection-1.0')
 gjs = dependency('gjs-1.0', version: '>= 1.53.90')
 
diff --git a/src/lib/polari-util.c b/src/lib/polari-util.c
index fc82474..deb4a80 100644
--- a/src/lib/polari-util.c
+++ b/src/lib/polari-util.c
@@ -133,3 +133,36 @@ polari_util_match_identify_message (const char  *message,
 
   return matched;
 }
+
+/**
+ * polari_util_get_tracker_connection:
+ *
+ * Returns: (transfer none):
+ */
+TrackerSparqlConnection *
+polari_util_get_tracker_connection (GError **error)
+{
+  static TrackerSparqlConnection *connection = NULL;
+
+  if (connection == NULL)
+    {
+      g_autoptr(GFile) store, ontology;
+      g_autofree char *store_path;
+
+      store_path = g_build_filename (g_get_user_data_dir (),
+                                     "polari",
+                                     "chatlogs.v1",
+                                     NULL);
+      store = g_file_new_for_path (store_path);
+      ontology = g_file_new_for_uri ("resource:///org/gnome/Polari/ontologies/");
+
+      connection = tracker_sparql_connection_local_new (TRACKER_SPARQL_CONNECTION_FLAGS_NONE,
+                                                        store,
+                                                        NULL,
+                                                        ontology,
+                                                        NULL,
+                                                        error);
+    }
+
+  return connection;
+}
diff --git a/src/lib/polari-util.h b/src/lib/polari-util.h
index 0ece7a3..b321bb2 100644
--- a/src/lib/polari-util.h
+++ b/src/lib/polari-util.h
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <glib.h>
+#include <libtracker-sparql/tracker-sparql.h>
 
 char *polari_util_get_basenick (const char *nick);
 
@@ -29,3 +30,5 @@ gboolean polari_util_match_identify_message (const char  *message,
                                              char       **command,
                                              char       **username,
                                              char       **password);
+
+TrackerSparqlConnection *polari_util_get_tracker_connection (GError **error);
diff --git a/src/meson.build b/src/meson.build
index 1769f77..c71156b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -5,6 +5,13 @@ data_resources = gnome.compile_resources(
   c_name: 'data_resources'
 )
 
+lib_resources = gnome.compile_resources(
+  'lib-resources',
+  '../data/@0  lib gresource xml'.format(app_id),
+  source_dir: '../data',
+  c_name: 'lib_resources'
+)
+
 js_sources = [
   'accountsMonitor.js',
   'application.js',
@@ -85,8 +92,8 @@ libargs = [
   '-DG_LOG_USE_STRUCTURED',
   '-DG_LOG_DOMAIN="Polari"'
 ]
-libpolari = shared_library('polari-1.0', libsources + lib_nongir_sources,
-  dependencies: [gio, gtk3, telepathy_glib, telepathy_logger],
+libpolari = shared_library('polari-1.0', libsources + lib_nongir_sources + lib_resources,
+  dependencies: [gio, gtk3, telepathy_glib, telepathy_logger, tracker],
   c_args: libargs,
   install: true,
   install_dir: pkglibdir
@@ -104,7 +111,7 @@ gnome.generate_gir(libpolari,
   namespace: 'Polari',
   symbol_prefix: 'polari',
   identifier_prefix: 'Polari',
-  includes: ['Gio-2.0', 'Gtk-3.0', 'TelepathyGLib-0.12', 'TelepathyLogger-0.2'],
+  includes: ['Gio-2.0', 'Gtk-3.0', 'TelepathyGLib-0.12', 'TelepathyLogger-0.2', 'Tracker-2.0'],
   extra_args: '--quiet',
   install_dir_gir: girdir,
   install_dir_typelib: typelibdir,


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