[smuxi: 54/111] Engine-JabbR: raise on-message-received/sent hook events



commit cb57106e7703837873f107a9eb9e44e172d6a992
Author: Mirco Bauer <meebey meebey net>
Date:   Thu Jan 9 08:49:49 2014 +0100

    Engine-JabbR: raise on-message-received/sent hook events

 src/Engine-JabbR/JabbrProtocolManager.cs |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/Engine-JabbR/JabbrProtocolManager.cs b/src/Engine-JabbR/JabbrProtocolManager.cs
index a32874c..59ac27c 100644
--- a/src/Engine-JabbR/JabbrProtocolManager.cs
+++ b/src/Engine-JabbR/JabbrProtocolManager.cs
@@ -1,6 +1,6 @@
 // Smuxi - Smart MUltipleXed Irc
 // 
-// Copyright (c) 2012-2013 Mirco Bauer <meebey meebey net>
+// Copyright (c) 2012-2014 Mirco Bauer <meebey meebey net>
 // 
 // Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
 // 
@@ -465,7 +465,19 @@ namespace Smuxi.Engine
             if (sender != Me) {
                 builder.MarkHighlights();
             }
-            Session.AddMessageToChat(chat, builder.ToMessage());
+            var message = builder.ToMessage();
+            Session.AddMessageToChat(chat, message);
+
+            if (sender == Me) {
+                // server echos our sent messages for us
+                OnMessageSent(
+                    new MessageEventArgs(chat, message, null, chat.ID)
+                );
+            } else {
+                OnMessageReceived(
+                    new MessageEventArgs(chat, message, name, chat.ID)
+                );
+            }
         }
 
         void OnMeMessageReceived(string userName, string content, string roomName)
@@ -483,6 +495,10 @@ namespace Smuxi.Engine
             }
             var msg = builder.ToMessage();
             Session.AddMessageToChat(chat, msg);
+
+            OnMessageReceived(
+                new MessageEventArgs(chat, msg, userName, roomName)
+            );
         }
 
         void OnUserJoined(User user, string room, bool isOwner)


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