core: Clean up AutoWho comments, variable names
authorShane Synan <digitalcircuit36939@gmail.com>
Fri, 14 Sep 2018 18:51:40 +0000 (13:51 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 16 Sep 2018 20:37:47 +0000 (22:37 +0200)
Clean up AutoWho variable names using the "name" convention from
RFC 1459.

Clean up AutoWho comments likewise, referring to "name" instead of
"channel" where appropriate.

See https://tools.ietf.org/html/rfc1459#section-4.5.1

src/core/corenetwork.cpp
src/core/corenetwork.h

index 395cb7a..2b73969 100644 (file)
@@ -494,13 +494,13 @@ bool CoreNetwork::cipherUsesCBC(const QString &target)
 }
 #endif /* HAVE_QCA2 */
 
-bool CoreNetwork::setAutoWhoDone(const QString &channel)
+bool CoreNetwork::setAutoWhoDone(const QString &name)
 {
-    QString chan = channel.toLower();
-    if (_autoWhoPending.value(chan, 0) <= 0)
+    QString chanOrNick = name.toLower();
+    if (_autoWhoPending.value(chanOrNick, 0) <= 0)
         return false;
-    if (--_autoWhoPending[chan] <= 0)
-        _autoWhoPending.remove(chan);
+    if (--_autoWhoPending[chanOrNick] <= 0)
+        _autoWhoPending.remove(chanOrNick);
     return true;
 }
 
@@ -1308,12 +1308,12 @@ void CoreNetwork::startAutoWhoCycle()
     _autoWhoQueue = channels();
 }
 
-void CoreNetwork::queueAutoWhoOneshot(const QString &channelOrNick)
+void CoreNetwork::queueAutoWhoOneshot(const QString &name)
 {
     // Prepend so these new channels/nicks are the first to be checked
     // Don't allow duplicates
-    if (!_autoWhoQueue.contains(channelOrNick.toLower())) {
-        _autoWhoQueue.prepend(channelOrNick.toLower());
+    if (!_autoWhoQueue.contains(name.toLower())) {
+        _autoWhoQueue.prepend(name.toLower());
     }
     if (capEnabled(IrcCap::AWAY_NOTIFY)) {
         // When away-notify is active, the timer's stopped.  Start a new cycle to who this channel.
@@ -1322,10 +1322,10 @@ void CoreNetwork::queueAutoWhoOneshot(const QString &channelOrNick)
 }
 
 
-void CoreNetwork::cancelAutoWhoOneshot(const QString &channelOrNick)
+void CoreNetwork::cancelAutoWhoOneshot(const QString &name)
 {
     // Remove channel/nick from queue if it exists
-    _autoWhoQueue.removeAll(channelOrNick);
+    _autoWhoQueue.removeAll(name);
 
     // The AutoWho timer will detect if the queue is empty and automatically stop, no need to
     // manually control it.
index 86fc4ab..740430c 100644 (file)
@@ -90,7 +90,16 @@ public:
     inline QByteArray readChannelCipherKey(const QString &channel) const { return _cipherKeys.value(channel.toLower()); }
     inline void storeChannelCipherKey(const QString &channel, const QByteArray &key) { _cipherKeys[channel.toLower()] = key; }
 
-    inline bool isAutoWhoInProgress(const QString &channel) const { return _autoWhoPending.value(channel.toLower(), 0); }
+    /**
+     * Checks if the given target has an automatic WHO in progress
+     *
+     * @param name Channel or nickname
+     * @return True if an automatic WHO is in progress, otherwise false
+     */
+    inline bool isAutoWhoInProgress(const QString &name) const
+    {
+        return _autoWhoPending.value(name.toLower(), 0);
+    }
 
     inline UserId userId() const { return _coreSession->user(); }
 
@@ -388,23 +397,29 @@ public slots:
      * When 'away-notify' is enabled, this will trigger an immediate AutoWho since regular
      * who-cycles are disabled as per IRCv3 specifications.
      *
-     * @param[in] channelOrNick Channel or nickname to WHO
+     * @param[in] name Channel or nickname
      */
-    void queueAutoWhoOneshot(const QString &channelOrNick);
+    void queueAutoWhoOneshot(const QString &name);
 
     /**
-     * Removes the given channel/nick from AutoWho queue for when it stops existing
+     * Removes the given channel/nick from AutoWho queue
      *
-     * If not already in queue, nothing happens.  This should only be used for nicknames and
-     * channels that have suddenly stopped existing (e.g. nick joins then quits).
+     * This can avoid needlessly WHO'ng nicknames and channels that are no longer of interest, e.g.
+     * if parting a channel right after joining or if a nick joins then quits.
      *
      * For when a periodic channel AutoWho finishes, see CoreNetwork::setAutoWhoDone()
      *
-     * @param channelOrNick Channel or nickname to WHO
+     * @param name Channel or nickname
      */
-    void cancelAutoWhoOneshot(const QString &channelOrNick);
+    void cancelAutoWhoOneshot(const QString &name);
 
-    bool setAutoWhoDone(const QString &channel);
+    /**
+     * Checks if the given target has an automatic WHO in progress, and sets it as done if so
+     *
+     * @param name Channel or nickname
+     * @return True if an automatic WHO is in progress (and should be silenced), otherwise false
+     */
+    bool setAutoWhoDone(const QString &name);
 
     void updateIssuedModes(const QString &requestedModes);
     void updatePersistentModes(QString addModes, QString removeModes);