[smuxi/experiments/tag_messages: 30/41] Engine-XMPP: refactored XmppProtocolManager.OnGroupChatPresenceError()



commit 0cd49d3eed38f8c5efa8fa03dc6b574e44cb9029
Author: Mirco Bauer <meebey meebey net>
Date:   Sat Feb 13 14:00:16 2016 +0100

    Engine-XMPP: refactored XmppProtocolManager.OnGroupChatPresenceError()
    
    CS: avoid nesting by failing early

 .../Protocols/Xmpp/XmppProtocolManager.cs          |   24 +++++--------------
 1 files changed, 7 insertions(+), 17 deletions(-)
---
diff --git a/src/Engine-XMPP/Protocols/Xmpp/XmppProtocolManager.cs 
b/src/Engine-XMPP/Protocols/Xmpp/XmppProtocolManager.cs
index 8006c3c..2088846 100644
--- a/src/Engine-XMPP/Protocols/Xmpp/XmppProtocolManager.cs
+++ b/src/Engine-XMPP/Protocols/Xmpp/XmppProtocolManager.cs
@@ -1,7 +1,7 @@
 /*
  * Smuxi - Smart MUltipleXed Irc
  *
- * Copyright (c) 2005-2014 Mirco Bauer <meebey meebey net>
+ * Copyright (c) 2005-2016 Mirco Bauer <meebey meebey net>
  * Copyright (c) 2011 Tuukka Hastrup <Tuukka Hastrup iki fi>
  * Copyright (c) 2013-2014 Oliver Schneider <smuxi oli-obk de>
  *
@@ -1916,25 +1916,15 @@ namespace Smuxi.Engine
 
         void OnGroupChatPresenceError(XmppGroupChatModel chat, Presence pres)
         {
-            var msg = CreateGroupChatPresenceErrorMessage(pres);
-            if (pres.Error == null) {
-                Session.AddMessageToChat(NetworkChat, msg);
-                Session.RemoveChat(chat);
+            if (pres.Error != null &&
+                pres.Error.Type == ErrorType.cancel &&
+                pres.Error.Condition == ErrorCondition.Conflict) {
+                // nickname already in use; autorejoin with _ appended
+                JoinRoom(chat.ID, chat.OwnNickname + "_", chat.Password);
                 return;
             }
-            // is there an action we can do silently?
-            switch (pres.Error.Type) {
-                case ErrorType.cancel:
-                    switch (pres.Error.Condition) {
-                        case ErrorCondition.Conflict:
-                            // nickname already in use
-                            // autorejoin with _ appended to nickname
-                            JoinRoom(chat.ID, chat.OwnNickname + "_", chat.Password);
-                            return;
-                    }
-                    break;
-            }
 
+            var msg = CreateGroupChatPresenceErrorMessage(pres);
             Session.AddMessageToChat(NetworkChat, msg);
             Session.RemoveChat(chat);
         }


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