Fixing BR #374 (hide marked as away messages when using away on detach)
authorMarcus Eggenberger <egs@quassel-irc.org>
Sat, 1 Nov 2008 16:00:14 +0000 (17:00 +0100)
committerMarcus Eggenberger <egs@quassel-irc.org>
Sat, 1 Nov 2008 16:00:14 +0000 (17:00 +0100)
src/common/network.cpp
src/common/network.h
src/core/coresession.cpp
src/core/ircserverhandler.cpp

index 1098b0a..6c0d252 100644 (file)
@@ -51,7 +51,8 @@ Network::Network(const NetworkId &networkid, QObject *parent)
     _unlimitedReconnectRetries(false),
     _codecForServer(0),
     _codecForEncoding(0),
-    _codecForDecoding(0)
+    _codecForDecoding(0),
+    _autoAwayActive(false)
 {
   setObjectName(QString::number(networkid.toInt()));
 }
index dbc5f35..4bbd984 100644 (file)
@@ -18,8 +18,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef NETWORK_H_
-#define NETWORK_H_
+#ifndef NETWORK_H
+#define NETWORK_H
 
 #include <QString>
 #include <QStringList>
@@ -176,6 +176,9 @@ public:
   static void setDefaultCodecForEncoding(const QByteArray &name);
   static void setDefaultCodecForDecoding(const QByteArray &name);
 
+  bool autoAwayActive() const { return _autoAwayActive; }
+  void setAutoAwayActive(bool active) { _autoAwayActive = active; }
+
 public slots:
   void setNetworkName(const QString &networkName);
   void setCurrentServer(const QString &currentServer);
@@ -338,6 +341,8 @@ private:
   static QTextCodec *_defaultCodecForServer;
   static QTextCodec *_defaultCodecForEncoding;
   static QTextCodec *_defaultCodecForDecoding;
+
+  bool _autoAwayActive; // when this is active handle305 and handle306 don't trigger any output
 };
 
 //! Stores all editable information about a network (as opposed to runtime state).
index acb9aa2..bb4b3dd 100644 (file)
@@ -560,6 +560,7 @@ void CoreSession::clientsDisconnected() {
        awayReason = identity->detachAwayReason();
       else
        awayReason = identity->awayReason();
+      network->setAutoAwayActive(true);
       con->userInputHandler()->handleAway(BufferInfo(), awayReason);
     }
   }
index 25e5c44..ea0d695 100644 (file)
@@ -572,8 +572,12 @@ void IrcServerHandler::handle305(const QString &prefix, const QList<QByteArray>
   if(me)
     me->setAway(false);
 
-  if(!params.isEmpty())
-    emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0]));
+  if(!network()->autoAwayActive()) {
+    if(!params.isEmpty())
+      emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0]));
+  } else {
+    network()->setAutoAwayActive(false);
+  }
 }
 
 // 306  RPL_NOWAWAY
@@ -584,7 +588,7 @@ void IrcServerHandler::handle306(const QString &prefix, const QList<QByteArray>
   if(me)
     me->setAway(true);
 
-  if(!params.isEmpty())
+  if(!params.isEmpty() && !network()->autoAwayActive())
     emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", serverDecode(params[0]));
 }