[tracker/wip/carlosg/domain-ontologies: 53/124] libtracker-data: Add API to attach user data to TrackerDBInterfaces
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/domain-ontologies: 53/124] libtracker-data: Add API to attach user data to TrackerDBInterfaces
- Date: Thu, 29 Jun 2017 18:43:34 +0000 (UTC)
commit 99c9934a30b1fd0bde2946de9fdc87904acc0cf0
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jun 9 23:23:42 2017 +0200
libtracker-data: Add API to attach user data to TrackerDBInterfaces
This will be used to attach the data manager.
src/libtracker-data/tracker-db-interface-sqlite.c | 26 +++++++++++++++++++++
src/libtracker-data/tracker-db-interface.h | 6 +++++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c
b/src/libtracker-data/tracker-db-interface-sqlite.c
index fd2c0d4..ff5298e 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -101,6 +101,10 @@ struct TrackerDBInterface {
/* Wal */
TrackerDBWalCallback wal_hook;
+
+ /* User data */
+ gpointer user_data;
+ GDestroyNotify user_data_destroy_notify;
};
struct TrackerDBInterfaceClass {
@@ -1910,6 +1914,9 @@ tracker_db_interface_sqlite_finalize (GObject *object)
g_free (db_interface->filename);
g_free (db_interface->busy_status);
+ if (db_interface->user_data && db_interface->user_data_destroy_notify)
+ db_interface->user_data_destroy_notify (db_interface->user_data);
+
G_OBJECT_CLASS (tracker_db_interface_parent_class)->finalize (object);
}
@@ -2947,3 +2954,22 @@ tracker_db_statement_sqlite_reset (TrackerDBStatement *stmt)
sqlite3_reset (stmt->stmt);
sqlite3_clear_bindings (stmt->stmt);
}
+
+
+void
+tracker_db_interface_set_user_data (TrackerDBInterface *db_interface,
+ gpointer user_data,
+ GDestroyNotify destroy_notify)
+{
+ if (db_interface->user_data && db_interface->user_data_destroy_notify)
+ db_interface->user_data_destroy_notify (db_interface->user_data);
+
+ db_interface->user_data = user_data;
+ db_interface->user_data_destroy_notify = destroy_notify;
+}
+
+gpointer
+tracker_db_interface_get_user_data (TrackerDBInterface *db_interface)
+{
+ return db_interface->user_data;
+}
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index 0422f2b..16041cc 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -91,6 +91,12 @@ void tracker_db_interface_set_max_stmt_cache_size (TrackerDBI
TrackerDBStatementCacheType cache_type,
guint max_size);
+/* User data functions, mainly to attach the data manager */
+void tracker_db_interface_set_user_data (TrackerDBInterface *interface,
+ gpointer user_data,
+ GDestroyNotify
destroy_notify);
+gpointer tracker_db_interface_get_user_data (TrackerDBInterface *interface);
+
/* Functions to create queries/procedures */
TrackerDBStatement * tracker_db_interface_create_statement (TrackerDBInterface *interface,
TrackerDBStatementCacheType
cache_type,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]