Introduce a flag EventManager::Silent
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 7 Oct 2010 07:04:31 +0000 (09:04 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 13 Oct 2010 23:06:32 +0000 (01:06 +0200)
If this is set, the EventStringifier won't generate a MessageEvent for this event.
This is thought for the CoreSessionEventProcessor (and possibly scripts) to hide
messages in certain cases, without circumventing further processing of the event.
Example would be suppressing WHO messages on autowho.

src/common/eventmanager.h
src/core/coresessioneventprocessor.cpp
src/core/eventstringifier.cpp
src/core/eventstringifier.h

index a41dbe5..4030cff 100644 (file)
@@ -46,7 +46,8 @@ public:
   };
 
   enum EventFlag {
-    Backlog = 0x40,
+    Backlog = 0x20,
+    Silent  = 0x40, ///< Don't generate a MessageEvent
     Stopped = 0x80
   };
   Q_DECLARE_FLAGS(EventFlags, EventFlag)
index fb9f903..bc7d1fb 100644 (file)
@@ -222,8 +222,10 @@ void CoreSessionEventProcessor::processIrcEvent305(IrcEvent *e) {
   if(me)
     me->setAway(false);
 
-  if(e->network()->autoAwayActive())
+  if(e->network()->autoAwayActive()) {
     e->network()->setAutoAwayActive(false);
+    e->setFlag(EventManager::Silent);
+  }
 }
 
 /* RPL_NOWAWAY - ":You have been marked as being away" */
index 64e7003..c29a457 100644 (file)
@@ -32,6 +32,9 @@ EventStringifier::EventStringifier(CoreSession *parent) : QObject(parent),
 
 void EventStringifier::displayMsg(NetworkEvent *event, Message::Type msgType, const QString &msg, const QString &sender,
                                   const QString &target, Message::Flags msgFlags) {
+  if(event->flags().testFlag(EventManager::Silent))
+    return;
+
   MessageEvent *msgEvent = createMessageEvent(event, msgType, msg, sender, target, msgFlags);
   sendMessageEvent(msgEvent);
 }
@@ -194,10 +197,8 @@ void EventStringifier::processIrcEvent301(IrcEvent *e) {
 }
 
 /* RPL_UNAWAY */
-void EventStringifier::earlyProcessIrcEvent305(IrcEvent *e) {
-  // needs to be called early so we still get the old autoAwayActive state!
-  if(!e->network()->autoAwayActive())
-    displayMsg(e, Message::Server, tr("You are no longer marked as being away"));
+void EventStringifier::processIrcEvent305(IrcEvent *e) {
+  displayMsg(e, Message::Server, tr("You are no longer marked as being away"));
 }
 
 /* RPL_NOWAWAY */
index 6dbfc0f..fd7a2f5 100644 (file)
@@ -58,7 +58,7 @@ public:
   Q_INVOKABLE void processIrcEventTopic(IrcEvent *event);
 
   Q_INVOKABLE void processIrcEvent301(IrcEvent *event);      // RPL_AWAY
-  Q_INVOKABLE void earlyProcessIrcEvent305(IrcEvent *event); // RPL_UNAWAY
+  Q_INVOKABLE void processIrcEvent305(IrcEvent *event);      // RPL_UNAWAY
   Q_INVOKABLE void processIrcEvent306(IrcEvent *event);      // RPL_NOWAWAY
 
   // Q_INVOKABLE void processIrcEvent(IrcEvent *event);