Add support for account-notify, extended-join
authorShane Synan <digitalcircuit36939@gmail.com>
Wed, 17 Feb 2016 19:49:48 +0000 (13:49 -0600)
committerShane Synan <digitalcircuit36939@gmail.com>
Wed, 17 Feb 2016 20:08:15 +0000 (14:08 -0600)
Add support for account-notify to track account changes and
extended-join to get account information on join.  For now, this only
updates user/hostname information.  In the future it will track
logged in accounts in ircuser, pending a new feature flag and
inclusion of WHOX support.

See http://ircv3.net/specs/extensions/account-notify-3.1.html
And http://ircv3.net/specs/extensions/extended-join-3.1.html

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

index 79b37ff..16b83bc 100644 (file)
@@ -88,6 +88,7 @@ public :
 
         IrcEvent                    = 0x00030000,
         IrcEventAuthenticate,
+        IrcEventAccount,
         IrcEventAway,
         IrcEventCap,
         IrcEventInvite,
index 88ea9bd..cc41309 100644 (file)
@@ -150,6 +150,24 @@ public:
      */
     inline bool useCapAwayNotify() const { return capEnabled("away-notify"); }
 
+    /**
+     * Gets the status of the account-notify capability.
+     *
+     * http://ircv3.net/specs/extensions/account-notify-3.1.html
+     *
+     * @returns True if account-notify is enabled, otherwise false
+     */
+    inline bool useCapAccountNotify() const { return capEnabled("account-notify"); }
+
+    /**
+     * Gets the status of the extended-join capability.
+     *
+     * http://ircv3.net/specs/extensions/extended-join-3.1.html
+     *
+     * @returns True if extended-join is enabled, otherwise false
+     */
+    inline bool useCapExtendedJoin() const { return capEnabled("extended-join"); }
+
 public slots:
     virtual void setMyNick(const QString &mynick);
 
index e553e86..0cee244 100644 (file)
@@ -191,7 +191,9 @@ void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e)
                     // Only request SASL if it's enabled
                     if (coreNet->networkInfo().useSasl)
                         queueCurrentCap = true;
-                } else if (availableCapPair.at(0).startsWith("away-notify")) {
+                } else if (availableCapPair.at(0).startsWith("away-notify") ||
+                           availableCapPair.at(0).startsWith("account-notify") ||
+                           availableCapPair.at(0).startsWith("extended-join")) {
                     // Always request these capabilities if available
                     queueCurrentCap = true;
                 }
@@ -252,6 +254,30 @@ void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e)
     }
 }
 
+/* IRCv3 account-notify
+ * Log in:  ":nick!user@host ACCOUNT accountname"
+ * Log out: ":nick!user@host ACCOUNT *" */
+void CoreSessionEventProcessor::processIrcEventAccount(IrcEvent *e)
+{
+    if (!checkParamCount(e, 1))
+        return;
+
+    IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
+    if (ircuser) {
+        // FIXME Keep track of authed user account, requires adding support to ircuser.h/cpp
+        /*
+        if (e->params().at(0) != "*") {
+            // Account logged in
+            qDebug() << "account-notify:" << ircuser->nick() << "logged in to" << e->params().at(0);
+        } else {
+            // Account logged out
+            qDebug() << "account-notify:" << ircuser->nick() << "logged out";
+        }
+        */
+    } else {
+        qDebug() << "Received account-notify data for unknown user" << e->prefix();
+    }
+}
 
 /* IRCv3 away-notify - ":nick!user@host AWAY [:message]" */
 void CoreSessionEventProcessor::processIrcEventAway(IrcEvent *e)
@@ -293,6 +319,17 @@ void CoreSessionEventProcessor::processIrcEventJoin(IrcEvent *e)
     QString channel = e->params()[0];
     IrcUser *ircuser = net->updateNickFromMask(e->prefix());
 
+    if (net->useCapExtendedJoin()) {
+        if (!checkParamCount(e, 3))
+            return;
+        // If logged in, :nick!user@host JOIN #channelname accountname :Real Name
+        // If logged out, :nick!user@host JOIN #channelname * :Real Name
+        // See:  http://ircv3.net/specs/extensions/extended-join-3.1.html
+        // FIXME Keep track of authed user account, requires adding support to ircuser.h/cpp
+        ircuser->setRealName(e->params()[2]);
+    }
+    // Else :nick!user@host JOIN #channelname
+
     bool handledByNetsplit = false;
     foreach(Netsplit* n, _netsplits.value(e->network())) {
         handledByNetsplit = n->userJoined(e->prefix(), channel);
index 2053db8..0fd0c9e 100644 (file)
@@ -48,6 +48,7 @@ public:
 
     Q_INVOKABLE void processIrcEventAuthenticate(IrcEvent *event); /// SASL authentication
     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 processIrcEventInvite(IrcEvent *event);
     Q_INVOKABLE void processIrcEventJoin(IrcEvent *event);