[polari/wip/fmuellner/tracker: 22/36] lib: Add utility method to get tracker connection



commit 9281ca807b8684f1cb8b1adeddd7f199c89e4fd4
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 85665ac..5d07b0f 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')
 
diff --git a/src/lib/polari-util.c b/src/lib/polari-util.c
index c8d2dd0..69bb571 100644
--- a/src/lib/polari-util.c
+++ b/src/lib/polari-util.c
@@ -89,3 +89,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 0475105..dca1390 100644
--- a/src/lib/polari-util.h
+++ b/src/lib/polari-util.h
@@ -20,6 +20,7 @@
 #define __POLARI_UTIL_H__
 
 #include <glib.h>
+#include <libtracker-sparql/tracker-sparql.h>
 
 char *polari_util_get_basenick (const char *nick);
 
@@ -28,4 +29,6 @@ gboolean polari_util_match_identify_message (const char  *message,
                                              char       **username,
                                              char       **password);
 
+TrackerSparqlConnection *polari_util_get_tracker_connection (GError **error);
+
 #endif /* __POLARI_UTIL_H__ */
diff --git a/src/meson.build b/src/meson.build
index a9c8141..7e10e8b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -15,6 +15,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',
@@ -101,8 +108,8 @@ libargs = [
   '-DG_LOG_USE_STRUCTURED',
   '-DG_LOG_DOMAIN="Polari"'
 ]
-libpolari = shared_library('polari-1.0', libsources + libsources_private,
-  dependencies: [gio, gtk3, telepathy_glib, telepathy_logger],
+libpolari = shared_library('polari-1.0', libsources + libsources_private + lib_resources,
+  dependencies: [gio, gtk3, telepathy_glib, telepathy_logger, tracker],
   c_args: libargs,
   install: true,
   install_dir: pkglibdir
@@ -114,7 +121,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]