[polari/wip/fmuellner/tracker: 5/15] telepathyClient: Log messages to tracker
- From: Gitlab System User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/tracker: 5/15] telepathyClient: Log messages to tracker
- Date: Thu, 19 Oct 2017 14:28:02 +0000 (UTC)
commit da5077bbb7142c76ef86b433975297ef8a0128f2
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Jul 26 21:32:00 2017 +0200
telepathyClient: Log messages to tracker
src/telepathyClient.js | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
---
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 0b11e9a..10bc5e8 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -2,6 +2,7 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
+const Tracker = imports.gi.Tracker;
const AccountsMonitor = imports.accountsMonitor;
const Lang = imports.lang;
@@ -496,6 +497,8 @@ var TelepathyClient = new Lang.Class({
return;
}
+ channel.connect('message-sent',
+ Lang.bind(this, this._onMessageSent));
channel.connect('message-received',
Lang.bind(this, this._onMessageReceived));
channel.connect('pending-message-removed',
@@ -583,7 +586,34 @@ var TelepathyClient = new Lang.Class({
this._app.send_notification(this._getIdentifyNotificationID(accountPath), notification);
},
+ _logMessage: function(tpMessage, channel) {
+ let connection = Polari.util_get_tracker_connection ();
+
+ let accountId = channel.connection.get_account().get_path_suffix();
+ let isRoom = channel.handle_type == Tp.HandleType.ROOM;
+ 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);
+ connection.update_async(sparql, 0, null, (o, res) => {
+ try {
+ connection.update_finish(res);
+ } catch (e) {
+ log('Failed to log message: ' + e.message);
+ }
+ });
+ },
+
+ _onMessageSent: function(channel, msg) {
+ this._logMessage(msg, channel);
+ },
+
_onMessageReceived: function(channel, msg) {
+ this._logMessage(msg, channel);
+
let [id, ] = msg.get_pending_message_id();
let room = this._roomManager.lookupRoomByChannel(channel);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]