Add support for chghost
authorShane Synan <digitalcircuit36939@gmail.com>
Fri, 20 May 2016 22:26:11 +0000 (18:26 -0400)
committerShane Synan <digitalcircuit36939@gmail.com>
Mon, 13 Jun 2016 21:00:49 +0000 (17:00 -0400)
Add support for chghost to be notified of user/hostmask changes.  On
newer servers, this should fix all cases of outdated information
resulting from away-notify disabling WHO polling.

See http://ircv3.net/specs/extensions/chghost-3.2.html

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

index 3701743..2d88143 100644 (file)
@@ -91,6 +91,7 @@ public :
         IrcEventAccount,
         IrcEventAway,
         IrcEventCap,
         IrcEventAccount,
         IrcEventAway,
         IrcEventCap,
+        IrcEventChghost,
         IrcEventInvite,
         IrcEventJoin,
         IrcEventKick,
         IrcEventInvite,
         IrcEventJoin,
         IrcEventKick,
index 3398ada..61dac32 100644 (file)
@@ -58,6 +58,13 @@ namespace IrcCap {
      */
     const QString CAP_NOTIFY = "cap-notify";
 
      */
     const QString CAP_NOTIFY = "cap-notify";
 
+    /**
+     * Hostname/user changed notification.
+     *
+     * http://ircv3.net/specs/extensions/chghost-3.2.html
+     */
+    const QString CHGHOST = "chghost";
+
     /**
      * Extended join information.
      *
     /**
      * Extended join information.
      *
@@ -93,6 +100,7 @@ namespace IrcCap {
             ACCOUNT_NOTIFY,
             AWAY_NOTIFY,
             CAP_NOTIFY,
             ACCOUNT_NOTIFY,
             AWAY_NOTIFY,
             CAP_NOTIFY,
+            CHGHOST,
             EXTENDED_JOIN,
             MULTI_PREFIX,
             SASL,
             EXTENDED_JOIN,
             MULTI_PREFIX,
             SASL,
index ade8c3b..fd8a97c 100644 (file)
@@ -277,6 +277,23 @@ void CoreSessionEventProcessor::processIrcEventAway(IrcEvent *e)
     }
 }
 
     }
 }
 
+/* IRCv3 chghost - ":nick!user@host CHGHOST newuser new.host.goes.here" */
+void CoreSessionEventProcessor::processIrcEventChghost(IrcEvent *e)
+{
+    if (!checkParamCount(e, 2))
+        return;
+
+    IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
+    if (ircuser) {
+        // Update with new user/hostname information.  setUser/setHost handles checking what
+        // actually changed.
+        ircuser->setUser(e->params().at(0));
+        ircuser->setHost(e->params().at(1));
+    } else {
+        qDebug() << "Received chghost data for unknown user" << e->prefix();
+    }
+}
+
 void CoreSessionEventProcessor::processIrcEventInvite(IrcEvent *e)
 {
     if (checkParamCount(e, 2)) {
 void CoreSessionEventProcessor::processIrcEventInvite(IrcEvent *e)
 {
     if (checkParamCount(e, 2)) {
index ff16729..5612424 100644 (file)
@@ -50,6 +50,7 @@ public:
     Q_INVOKABLE void processIrcEventCap(IrcEvent *event);          /// CAP framework negotiation
     Q_INVOKABLE void processIrcEventAccount(IrcEvent *event);      /// account-notify received
     Q_INVOKABLE void processIrcEventAway(IrcEvent *event);         /// away-notify received
     Q_INVOKABLE void processIrcEventCap(IrcEvent *event);          /// CAP framework negotiation
     Q_INVOKABLE void processIrcEventAccount(IrcEvent *event);      /// account-notify received
     Q_INVOKABLE void processIrcEventAway(IrcEvent *event);         /// away-notify received
+    Q_INVOKABLE void processIrcEventChghost(IrcEvent *event);      /// chghost received
     Q_INVOKABLE void processIrcEventInvite(IrcEvent *event);
     Q_INVOKABLE void processIrcEventJoin(IrcEvent *event);
     Q_INVOKABLE void lateProcessIrcEventKick(IrcEvent *event);
     Q_INVOKABLE void processIrcEventInvite(IrcEvent *event);
     Q_INVOKABLE void processIrcEventJoin(IrcEvent *event);
     Q_INVOKABLE void lateProcessIrcEventKick(IrcEvent *event);