+
+ if (coreNetwork(e)->useCapMultiPrefix()) {
+ // If multi-prefix is enabled, all modes will be sent in WHO replies.
+ // :kenny.chatspike.net 352 guest #test grawity broken.symlink *.chatspike.net grawity H@%+ :0 Mantas M.
+ // See: http://ircv3.net/specs/extensions/multi-prefix-3.1.html
+ QString uncheckedModes = e->params()[5];
+ QString validModes = QString();
+ while (!uncheckedModes.isEmpty()) {
+ // Mode found in 1 left-most character, add it to the list
+ if (e->network()->prefixes().contains(uncheckedModes[0])) {
+ validModes.append(e->network()->prefixToMode(uncheckedModes[0]));
+ }
+ // Remove this mode from the list of unchecked modes
+ uncheckedModes = uncheckedModes.remove(0, 1);
+ }
+
+ // Some IRC servers decide to not follow the spec, returning only -some- of the user
+ // modes in WHO despite listing them all in NAMES. For now, assume it can only add
+ // and not take away. *sigh*
+ if (!validModes.isEmpty()) {
+ if (channel != "*") {
+ // Channel-specific modes received, apply to given channel only
+ IrcChannel *ircChan = e->network()->ircChannel(channel);
+ if (ircChan) {
+ // Do one mode at a time
+ // TODO Better way of syncing this without breaking protocol?
+ for (int i = 0; i < validModes.count(); ++i) {
+ ircChan->addUserMode(ircuser, validModes.at(i));
+ }
+ }
+ } else {
+ // Modes apply to the user everywhere
+ ircuser->addUserModes(validModes);
+ }
+ }
+ }