[tracker/wip/carlosg/local-connection-mapping: 5/8] libtracker-data: Add private API to map local connections
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/local-connection-mapping: 5/8] libtracker-data: Add private API to map local connections
- Date: Sun, 12 Dec 2021 16:37:53 +0000 (UTC)
commit 768bc3d8bf275d2928fa36e2041328bd89f9b86e
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Apr 3 15:43:16 2021 +0200
libtracker-data: Add private API to map local connections
These will be available via special private:$handle_name URIs.
src/libtracker-data/tracker-data-manager.c | 24 ++++++++++++++++++------
src/libtracker-data/tracker-data-manager.h | 3 +++
2 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index ee06c93db..a29862dcc 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -150,6 +150,9 @@ static void
tracker_data_manager_init (TrackerDataManager *manager)
{
manager->generation = 1;
+ manager->cached_connections =
+ g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_object_unref);
g_mutex_init (&manager->connections_lock);
g_mutex_init (&manager->graphs_lock);
}
@@ -5270,12 +5273,6 @@ tracker_data_manager_get_remote_connection (TrackerDataManager *data_manager,
g_mutex_lock (&data_manager->connections_lock);
- if (!data_manager->cached_connections) {
- data_manager->cached_connections =
- g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, g_object_unref);
- }
-
connection = g_hash_table_lookup (data_manager->cached_connections, uri);
if (!connection) {
@@ -5344,3 +5341,18 @@ fail:
return connection;
}
+
+void
+tracker_data_manager_map_connection (TrackerDataManager *data_manager,
+ const gchar *handle_name,
+ TrackerSparqlConnection *connection)
+{
+ gchar *uri;
+
+ uri = g_strdup_printf ("private:%s", handle_name);
+
+ g_mutex_lock (&data_manager->connections_lock);
+ g_hash_table_insert (data_manager->cached_connections,
+ uri, g_object_ref (connection));
+ g_mutex_unlock (&data_manager->connections_lock);
+}
diff --git a/src/libtracker-data/tracker-data-manager.h b/src/libtracker-data/tracker-data-manager.h
index 47f8c07f9..bb4a30e3b 100644
--- a/src/libtracker-data/tracker-data-manager.h
+++ b/src/libtracker-data/tracker-data-manager.h
@@ -116,6 +116,9 @@ gboolean tracker_data_manager_expand_prefix (TrackerDataManager *ma
TrackerSparqlConnection * tracker_data_manager_get_remote_connection (TrackerDataManager *data_manager,
const gchar *uri,
GError **error);
+void tracker_data_manager_map_connection (TrackerDataManager *data_manager,
+ const gchar *handle_name,
+ TrackerSparqlConnection *connection);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]