[polari/wip/fmuellner/tracker: 47/61] lib: Add utility method to get tracker connection
- From: Gitlab System User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/tracker: 47/61] lib: Add utility method to get tracker connection
- Date: Mon, 18 Sep 2017 15:30:34 +0000 (UTC)
commit c5a2f070b973eb705a2549c2192496c88fe0e52e
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 df030e9..7c5eb4c 100644
--- a/meson.build
+++ b/meson.build
@@ -36,6 +36,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 c26a5f8..2f658b8 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'
+)
+
src_resources = gnome.compile_resources(
'src-resources',
'@0 src gresource xml'.format(app_id),
@@ -53,8 +60,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
@@ -66,7 +73,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]