[polari/wip/fmuellner/tracker: 28/38] telepathyClient: Log messages to tracker
- From: Gitlab Administrative User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/tracker: 28/38] telepathyClient: Log messages to tracker
- Date: Mon, 30 Oct 2017 23:55:33 +0000 (UTC)
commit faa2520e0eed4b763f89783b40c4588c4700779b
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 c1a7264..487f52d 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -3,6 +3,7 @@ const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
+const Tracker = imports.gi.Tracker;
const AccountsMonitor = imports.accountsMonitor;
const Lang = imports.lang;
@@ -492,6 +493,8 @@ class TelepathyClient extends Tp.BaseClient {
return;
}
+ channel.connect('message-sent',
+ Lang.bind(this, this._onMessageSent));
channel.connect('message-received',
Lang.bind(this, this._onMessageReceived));
channel.connect('pending-message-removed',
@@ -579,7 +582,34 @@ class TelepathyClient extends Tp.BaseClient {
this._app.send_notification(this._getIdentifyNotificationID(accountPath), notification);
}
+ _logMessage(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(channel, msg) {
+ this._logMessage(msg, channel);
+ }
+
_onMessageReceived(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]