projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
clang-tidy: Mark several settingspage methods as final
[quassel.git]
/
src
/
common
/
ircchannel.cpp
diff --git
a/src/common/ircchannel.cpp
b/src/common/ircchannel.cpp
index
6673a79
..
92a4944
100644
(file)
--- a/
src/common/ircchannel.cpp
+++ b/
src/common/ircchannel.cpp
@@
-1,5
+1,5
@@
/***************************************************************************
/***************************************************************************
- * Copyright (C) 2005-201
5
by the Quassel Project *
+ * Copyright (C) 2005-201
8
by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-30,7
+30,6
@@
#include <QDebug>
#include <QDebug>
-INIT_SYNCABLE_OBJECT(IrcChannel)
IrcChannel::IrcChannel(const QString &channelname, Network *network)
: SyncableObject(network),
_initialized(false),
IrcChannel::IrcChannel(const QString &channelname, Network *network)
: SyncableObject(network),
_initialized(false),
@@
-61,7
+60,7
@@
bool IrcChannel::isKnownUser(IrcUser *ircuser) const
}
if (!_userModes.contains(ircuser)) {
}
if (!_userModes.contains(ircuser)) {
- qWarning() << "Channel" << name() << "received data for unknown User" << ircuser->nick();
+ // This can happen e.g. when disconnecting from a network, so don't log a warning
return false;
}
return false;
}
@@
-170,6
+169,9
@@
void IrcChannel::joinIrcUsers(const QList<IrcUser *> &users, const QStringList &
return;
}
return;
}
+ // Sort user modes first
+ const QStringList sortedModes = network()->sortPrefixModes(modes);
+
QStringList newNicks;
QStringList newModes;
QList<IrcUser *> newUsers;
QStringList newNicks;
QStringList newModes;
QList<IrcUser *> newUsers;
@@
-177,20
+179,22
@@
void IrcChannel::joinIrcUsers(const QList<IrcUser *> &users, const QStringList &
IrcUser *ircuser;
for (int i = 0; i < users.count(); i++) {
ircuser = users[i];
IrcUser *ircuser;
for (int i = 0; i < users.count(); i++) {
ircuser = users[i];
- if (!ircuser || _userModes.contains(ircuser)) {
- if (modes[i].count() > 1) {
+ if (!ircuser)
+ continue;
+ if (_userModes.contains(ircuser)) {
+ if (sortedModes[i].count() > 1) {
// Multiple modes received, do it one at a time
// TODO Better way of syncing this without breaking protocol?
// Multiple modes received, do it one at a time
// TODO Better way of syncing this without breaking protocol?
- for (int i_m = 0; i_m <
m
odes[i].count(); ++i_m) {
- addUserMode(ircuser,
m
odes[i][i_m]);
+ for (int i_m = 0; i_m <
sortedM
odes[i].count(); ++i_m) {
+ addUserMode(ircuser,
sortedM
odes[i][i_m]);
}
} else {
}
} else {
- addUserMode(ircuser,
m
odes[i]);
+ addUserMode(ircuser,
sortedM
odes[i]);
}
continue;
}
}
continue;
}
- _userModes[ircuser] =
m
odes[i];
+ _userModes[ircuser] =
sortedM
odes[i];
ircuser->joinChannel(this, true);
connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString)));
ircuser->joinChannel(this, true);
connect(ircuser, SIGNAL(nickSet(QString)), this, SLOT(ircUserNickSet(QString)));
@@
-198,11
+202,8
@@
void IrcChannel::joinIrcUsers(const QList<IrcUser *> &users, const QStringList &
// If you wonder why there is no counterpart to ircUserJoined:
// the joins are propagated by the ircuser. The signal ircUserJoined is only for convenience
// If you wonder why there is no counterpart to ircUserJoined:
// the joins are propagated by the ircuser. The signal ircUserJoined is only for convenience
- // Also update the IRC user's record of modes; this allows easier tracking
- ircuser->addUserModes(modes[i]);
-
newNicks << ircuser->nick();
newNicks << ircuser->nick();
- newModes <<
m
odes[i];
+ newModes <<
sortedM
odes[i];
newUsers << ircuser;
}
newUsers << ircuser;
}
@@
-269,7
+270,8
@@
void IrcChannel::part(const QString &nick)
void IrcChannel::setUserModes(IrcUser *ircuser, const QString &modes)
{
if (isKnownUser(ircuser)) {
void IrcChannel::setUserModes(IrcUser *ircuser, const QString &modes)
{
if (isKnownUser(ircuser)) {
- _userModes[ircuser] = modes;
+ // Keep user modes sorted
+ _userModes[ircuser] = network()->sortPrefixModes(modes);
QString nick = ircuser->nick();
SYNC_OTHER(setUserModes, ARG(nick), ARG(modes))
emit ircUserModesSet(ircuser, modes);
QString nick = ircuser->nick();
SYNC_OTHER(setUserModes, ARG(nick), ARG(modes))
emit ircUserModesSet(ircuser, modes);
@@
-290,9
+292,8
@@
void IrcChannel::addUserMode(IrcUser *ircuser, const QString &mode)
return;
if (!_userModes[ircuser].contains(mode)) {
return;
if (!_userModes[ircuser].contains(mode)) {
- _userModes[ircuser] += mode;
- // Also update the IRC user's record of modes; this allows easier tracking
- ircuser->addUserModes(mode);
+ // Keep user modes sorted
+ _userModes[ircuser] = network()->sortPrefixModes(_userModes[ircuser] + mode);
QString nick = ircuser->nick();
SYNC_OTHER(addUserMode, ARG(nick), ARG(mode))
emit ircUserModeAdded(ircuser, mode);
QString nick = ircuser->nick();
SYNC_OTHER(addUserMode, ARG(nick), ARG(mode))
emit ircUserModeAdded(ircuser, mode);
@@
-313,9
+314,8
@@
void IrcChannel::removeUserMode(IrcUser *ircuser, const QString &mode)
return;
if (_userModes[ircuser].contains(mode)) {
return;
if (_userModes[ircuser].contains(mode)) {
+ // Removing modes shouldn't mess up ordering
_userModes[ircuser].remove(mode);
_userModes[ircuser].remove(mode);
- // Also update the IRC user's record of modes; this allows easier tracking
- ircuser->removeUserModes(mode);
QString nick = ircuser->nick();
SYNC_OTHER(removeUserMode, ARG(nick), ARG(mode));
emit ircUserModeRemoved(ircuser, mode);
QString nick = ircuser->nick();
SYNC_OTHER(removeUserMode, ARG(nick), ARG(mode));
emit ircUserModeRemoved(ircuser, mode);
@@
-352,6
+352,7
@@
void IrcChannel::initSetUserModes(const QVariantMap &usermodes)
modes << iter.value().toString();
++iter;
}
modes << iter.value().toString();
++iter;
}
+ // joinIrcUsers handles sorting modes
joinIrcUsers(users, modes);
}
joinIrcUsers(users, modes);
}
@@
-562,9
+563,8
@@
bool IrcChannel::hasMode(const QChar &mode) const
return _C_channelModes.contains(mode);
case Network::D_CHANMODE:
return _D_channelModes.contains(mode);
return _C_channelModes.contains(mode);
case Network::D_CHANMODE:
return _D_channelModes.contains(mode);
- default:
- return false;
}
}
+ return false;
}
}
@@
-597,9
+597,11
@@
QStringList IrcChannel::modeValueList(const QChar &mode) const
case Network::A_CHANMODE:
if (_A_channelModes.contains(mode))
return _A_channelModes[mode];
case Network::A_CHANMODE:
if (_A_channelModes.contains(mode))
return _A_channelModes[mode];
+ break;
default:
default:
-
return QStringList()
;
+ ;
}
}
+ return {};
}
}