[polari/wip/fmuellner/tracker: 88/90] chatView: Replace TpLogger with tracker



commit b40a6d6e48a2204a33ff674381ca367633f35190
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jan 8 16:10:17 2016 +0100

    chatView: Replace TpLogger with tracker

 configure.ac    |    2 +-
 src/chatView.js |   33 +++++++++++++--------------------
 2 files changed, 14 insertions(+), 21 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6473c74..cc744d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,7 +52,7 @@ AX_CHECK_GIRS_GJS([PangoCairo], [1.0])
 AX_CHECK_GIRS_GJS([Secret], [1])
 AX_CHECK_GIRS_GJS([Soup], [2.4])
 AX_CHECK_GIRS_GJS([TelepathyGLib], [0.12])
-AX_CHECK_GIRS_GJS([TelepathyLogger], [0.2])
+AX_CHECK_GIRS_GJS([Tracker], [1.0])
 
 AC_PROG_LN_S
 
diff --git a/src/chatView.js b/src/chatView.js
index 33e9f42..bd1776e 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -7,9 +7,9 @@ const Pango = imports.gi.Pango;
 const PangoCairo = imports.gi.PangoCairo;
 const Polari = imports.gi.Polari;
 const Tp = imports.gi.TelepathyGLib;
-const Tpl = imports.gi.TelepathyLogger;
 
 const Lang = imports.lang;
+const LogManager = imports.logManager;
 const Mainloop = imports.mainloop;
 const PasteManager = imports.pasteManager;
 const Signals = imports.signals;
@@ -299,18 +299,12 @@ const ChatView = new Lang.Class({
             }));
         this._updateMaxNickChars(this._room.account.nickname.length);
 
-        let isRoom = room.type == Tp.HandleType.ROOM;
-        let target = new Tpl.Entity({ type: isRoom ? Tpl.EntityType.ROOM
-                                                   : Tpl.EntityType.CONTACT,
-                                      identifier: room.channel_name });
-        let logManager = Tpl.LogManager.dup_singleton();
-        this._logWalker =
-            logManager.walk_filtered_events(room.account, target,
-                                            Tpl.EventTypeMask.TEXT, null);
+        let logManager = LogManager.getDefault();
+        this._logWalker = logManager.walkEvents(room);
 
         this._fetchingBacklog = true;
-        this._logWalker.get_events_async(NUM_INITIAL_LOG_EVENTS,
-                                         Lang.bind(this, this._onLogEventsReady));
+        this._logWalker.getEvents(NUM_INITIAL_LOG_EVENTS,
+                                  Lang.bind(this, this._onLogEventsReady));
 
         this._autoscroll = true;
 
@@ -464,11 +458,10 @@ const ChatView = new Lang.Class({
         this._roomSignals = [];
     },
 
-    _onLogEventsReady: function(lw, res) {
+    _onLogEventsReady: function(events) {
         this._hideLoadingIndicator();
         this._fetchingBacklog = false;
 
-        let [, events] = lw.get_events_finish(res);
         let messages = events.map(e => this._createMessage(e));
         this._pendingLogs = messages.concat(this._pendingLogs);
         this._insertPendingLogs();
@@ -484,18 +477,18 @@ const ChatView = new Lang.Class({
                                 source.get_received_timestamp(),
                      messageType: source.get_message_type(),
                      pendingId: valid ? id : undefined };
-        } else if (source instanceof Tpl.Event) {
-            return { nick: source.sender.alias,
+        } else {
+            return { nick: source.sender,
                      text: source.message,
                      timestamp: source.timestamp,
-                     messageType: source.get_message_type() };
+                     messageType: source.messageType };
         }
 
         throw new Error('Cannot create message from source ' + source);
     },
 
     _getReadyLogs: function() {
-        if (this._logWalker.is_end())
+        if (this._logWalker.isEnd())
             return this._pendingLogs.splice(0);
 
         let nick = this._pendingLogs[0].nick;
@@ -656,7 +649,7 @@ const ChatView = new Lang.Class({
 
     _fetchBacklog: function() {
         if (this.vadjustment.value != 0 ||
-            this._logWalker.is_end())
+            this._logWalker.isEnd())
             return Gdk.EVENT_PROPAGATE;
 
         if (this._fetchingBacklog)
@@ -666,8 +659,8 @@ const ChatView = new Lang.Class({
         this._showLoadingIndicator();
         Mainloop.timeout_add(500, Lang.bind(this,
             function() {
-                this._logWalker.get_events_async(NUM_LOG_EVENTS,
-                                                 Lang.bind(this, this._onLogEventsReady));
+                this._logWalker.getEvents(NUM_LOG_EVENTS,
+                                          Lang.bind(this, this._onLogEventsReady));
                 return GLib.SOURCE_REMOVE;
             }));
         return Gdk.EVENT_STOP;


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