[polari/wip/fmuellner/tracker: 9/15] chatView: Replace TpLogger with tracker



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

    chatView: Replace TpLogger with tracker

 src/chatView.js | 34 ++++++++++------------------------
 src/main.js     |  1 -
 2 files changed, 10 insertions(+), 25 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 95720cb..08ec695 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 Logger = imports.logger;
 const Mainloop = imports.mainloop;
 const PasteManager = imports.pasteManager;
 const Signals = imports.signals;
@@ -370,18 +370,11 @@ var 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);
+        this._logWalker = new Logger.LogWalker(this._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;
 
@@ -543,17 +536,14 @@ var ChatView = new Lang.Class({
             Mainloop.source_remove(this._backlogTimeoutId);
         this._backlogTimeoutId = 0;
 
-        this._logWalker.run_dispose();
         this._logWalker = null;
     },
 
-    _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._pendingLogs = events.concat(this._pendingLogs);
         this._insertPendingLogs();
     },
 
@@ -563,17 +553,13 @@ var ChatView = new Lang.Class({
             let msg = Polari.Message.new_from_tp_message(source);
             msg.pendingId = valid ? id : undefined;
             return msg;
-        } else if (source instanceof Tpl.Event) {
-            let msg = Polari.Message.new_from_tpl_event(source);
-            msg.pendingId = undefined;
-            return msg;
         }
 
         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].get_sender();
@@ -725,7 +711,7 @@ var 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)
@@ -734,8 +720,8 @@ var ChatView = new Lang.Class({
         this._fetchingBacklog = true;
         this._showLoadingIndicator();
         this._backlogTimeoutId = Mainloop.timeout_add(500, () => {
-            this._logWalker.get_events_async(NUM_LOG_EVENTS,
-                                             Lang.bind(this, this._onLogEventsReady));
+            this._logWalker.getEvents(NUM_LOG_EVENTS,
+                                      Lang.bind(this, this._onLogEventsReady));
             this._backlogTimeoutId = 0;
             return GLib.SOURCE_REMOVE;
         });
diff --git a/src/main.js b/src/main.js
index d92dd16..bbe59e5 100755
--- a/src/main.js
+++ b/src/main.js
@@ -9,7 +9,6 @@ pkg.require({ 'GdkPixbuf': '2.0',
               'Secret': '1',
               'Soup': '2.4',
               'TelepathyGLib': '0.12',
-              'TelepathyLogger': '0.2',
               'Tracker': '2.0' });
 pkg.requireSymbol('Gio', '2.0', 'Application.send_notification');
 pkg.requireSymbol('GLib', '2.0', 'log_variant');


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