+ QStringList _capsQueuedIndividual; /// Capabilities to check that require one at a time requests
+ QStringList _capsQueuedBundled; /// Capabilities to check that can be grouped together
+ QStringList _capsQueuedLastBundle; /// Most recent capability bundle requested (no individuals)
+ // Some capabilities, such as SASL, require follow-up messages to be fully enabled. These
+ // capabilities should not be grouped with others to avoid requesting new capabilities while the
+ // previous capability is still being set up.
+ // Additionally, IRC servers can choose to send a 'NAK' to any set of requested capabilities.
+ // If this happens, we need a way to retry each capability individually in order to avoid having
+ // one failing capability (e.g. SASL) block all other capabilities.
+
+ bool _capNegotiationActive; /// Whether or not full capability negotiation was started
+ // Avoid displaying repeat "negotiation finished" messages
+ bool _capInitialNegotiationEnded; /// Whether or not initial capability negotiation finished
+ // Avoid sending repeat "CAP END" replies when registration is already ended
+
+ /**
+ * Gets the next set of capabilities to request, removing them from the queue.
+ *
+ * May return one or multiple space-separated capabilities, depending on queue.
+ *
+ * @returns Space-separated names of capabilities to request, or empty string if none remain
+ */
+ QString takeQueuedCaps();
+
+ /**
+ * Maximum length of a single 'CAP REQ' command.
+ *
+ * To be safe, 100 chars. Higher numbers should be possible; this is following the conservative
+ * minimum number of characters that IRC servers must return in CAP NAK replies. This also
+ * means CAP NAK replies will contain the full list of denied capabilities.
+ *
+ * See: http://ircv3.net/specs/core/capability-negotiation-3.1.html
+ */
+ const int maxCapRequestLength = 100;