[polari] app: Add action for initiating a private conversation



commit 0cac918c8dc7af031eff5684f2944c27944b3651
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Sep 6 18:43:17 2013 +0200

    app: Add action for initiating a private conversation
    
    This action works just like 'join-room', but uses Tp.HandleType.CONTACT
    rather than Tp.HandleType.ROOM. Use it to fix the /query command that
    was broken in commit b446c1e4792777.

 src/application.js |   38 ++++++++++++++++++++++++++------------
 src/ircParser.js   |    2 +-
 2 files changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 600c251..d6d5dec 100644
--- a/src/application.js
+++ b/src/application.js
@@ -78,6 +78,9 @@ const Application = new Lang.Class({
           { name: 'join-room',
             activate: Lang.bind(this, this._onJoinRoom),
             parameter_type: GLib.VariantType.new('(ssu)') },
+          { name: 'message-user',
+            activate: Lang.bind(this, this._onMessageUser),
+            parameter_type: GLib.VariantType.new('(ssu)') },
           { name: 'leave-room',
             activate: Lang.bind(this, this._onLeaveRoom),
             parameter_type: GLib.VariantType.new('s') },
@@ -258,6 +261,22 @@ const Application = new Lang.Class({
         account.update_parameters_vardict_async(asv, [], callback);
     },
 
+    _requestChannel: function(accountPath, targetType, targetId, time) {
+        // have this in AccountMonitor?
+        let factory = Tp.AccountManager.dup().get_factory();
+        let account = factory.ensure_account(accountPath, []);
+
+        let requestData = {
+          account: account,
+          targetHandleType: targetType,
+          targetId: targetId,
+          time: time,
+          retry: 0,
+          originalNick: account.nickname };
+
+        this._ensureChannel(requestData);
+    },
+
     _ensureChannel: function(requestData) {
         let account = requestData.account;
 
@@ -306,19 +325,14 @@ const Application = new Lang.Class({
 
     _onJoinRoom: function(action, parameter) {
         let [accountPath, channelName, time] = parameter.deep_unpack();
-        // have this in AccountMonitor?
-        let factory = Tp.AccountManager.dup().get_factory();
-        let account = factory.ensure_account(accountPath, []);
-
-        let requestData = {
-          account: account,
-          targetHandleType: Tp.HandleType.ROOM,
-          targetId: channelName,
-          time: time,
-          retry: 0,
-          originalNick: account.nickname };
+        this._requestChannel(accountPath, Tp.HandleType.ROOM,
+                             channelName, time);
+    },
 
-        this._ensureChannel(requestData);
+    _onMessageUser: function(action, parameter) {
+        let [accountPath, contactName, time] = parameter.deep_unpack();
+        this._requestChannel(accountPath, Tp.HandleType.CONTACT,
+                             contactName, time);
     },
 
     _onLeaveRoom: function(action, parameter) {
diff --git a/src/ircParser.js b/src/ircParser.js
index e9a780b..3380e39 100644
--- a/src/ircParser.js
+++ b/src/ircParser.js
@@ -230,7 +230,7 @@ const IrcParser = new Lang.Class({
                 let account = this._room.channel.connection.get_account();
 
                 let app = Gio.Application.get_default();
-                let action = app.lookup_action('join-room');
+                let action = app.lookup_action('message-user');
                 action.activate(GLib.Variant.new('(ssu)',
                                                  [ account.get_object_path(),
                                                    nick,


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