[polari/wip/carlosg/tracker] lib: Export function to get SPARQL string



commit c179e6378ed9bbe88d64ad438c70ff4263ec582f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 24 23:56:57 2019 +0100

    lib: Export function to get SPARQL string
    
    This is a bit of a hack, the ownership of the namespace manager is
    broken in Tracker gir, so move this piece of code into C domain.

 src/lib/polari-message.c | 22 ++++++++++++++++++++++
 src/lib/polari-message.h |  5 +++++
 src/telepathyClient.js   |  5 +----
 3 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/lib/polari-message.c b/src/lib/polari-message.c
index 5737a88..4bc2ad3 100644
--- a/src/lib/polari-message.c
+++ b/src/lib/polari-message.c
@@ -228,3 +228,25 @@ polari_message_to_tracker_resource (PolariMessage *message,
 
   return res;
 }
+
+/**
+ * polari_message_to_sparql:
+ *
+ * Returns: (transfer full):
+ */
+gchar *
+polari_message_to_sparql (PolariMessage           *message,
+                          TrackerSparqlConnection *connection,
+                          const char              *account_id,
+                          const char              *channel_name,
+                          gboolean                 is_room)
+{
+  TrackerNamespaceManager *ns_manager;
+  TrackerResource *res;
+
+  res = polari_message_to_tracker_resource (message, account_id,
+                                            channel_name, is_room);
+  ns_manager = tracker_sparql_connection_get_namespace_manager (connection);
+
+  return tracker_resource_print_sparql_update (res, ns_manager, NULL);
+}
diff --git a/src/lib/polari-message.h b/src/lib/polari-message.h
index dc4c096..88eec14 100644
--- a/src/lib/polari-message.h
+++ b/src/lib/polari-message.h
@@ -49,6 +49,11 @@ TrackerResource *polari_message_to_tracker_resource (PolariMessage *message,
                                                      const char    *account_id,
                                                      const char    *channel_name,
                                                      gboolean       is_room);
+gchar * polari_message_to_sparql (PolariMessage           *message,
+                                  TrackerSparqlConnection *connection,
+                                  const char              *account_id,
+                                  const char              *channel_name,
+                                  gboolean                 is_room);
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (PolariMessage, polari_message_free)
 
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 0201092..db53304 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -601,10 +601,7 @@ class TelepathyClient extends Tp.BaseClient {
         let channelName = channel.identifier;
 
         let message = Polari.Message.new_from_tp_message (tpMessage);
-        let res = message.to_tracker_resource(accountId, channelName, isRoom);
-
-        let nsManager = connection.get_namespace_manager();
-        let sparql = res.print_sparql_update(nsManager, null);
+        let sparql = message.to_sparql(connection, accountId, channelName, isRoom);
         connection.update_async(sparql, 0, null, (o, res) => {
             try {
                 connection.update_finish(res);


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