23 #include "ircuserinfo.h" 25 #include "irc/entities/ircuserprefix.h" 26 #include "irc/ircglobal.h" 27 #include "irc/ircnetworkadapter.h" 32 this->parentNetwork = NULL;
39 this->parentNetwork = parentNetwork;
41 if (nickname.isEmpty() || parentNetwork == NULL)
46 this->userName = parentNetwork->
userPrefixes().cleanNickname(nickname);
47 this->userModes << parentNetwork->
userPrefixes().modeFromNickname(nickname);
52 return prefixes().cleanNickname(userName);
60 QString IRCUserInfo::extractHostnameFromFullSignature()
const 66 hostName.remove(0, indexOfDelimiterChar + 1);
74 bool IRCUserInfo::isOp()
const 76 return modes().contains(
'o');
81 return ((*
this) == otherUser);
90 bool IRCUserInfo::isValid()
const 92 return !userName.isEmpty() && parentNetwork != NULL;
95 const QList<char> &IRCUserInfo::modes()
const 102 return parentNetwork;
105 void IRCUserInfo::setPrefixedNickname(
const QString &nickname)
107 this->userName = prefixes().cleanNickname(nickname);
108 if (prefixes().modeFromNickname(nickname) != 0)
110 setMode(prefixes().modeFromNickname(nickname));
114 bool IRCUserInfo::operator==(
const IRCUserInfo& otherUser)
const 119 return (thisNickname.compare(otherNickname) == 0);
124 assert(parentNetwork != NULL);
126 char mode2 = prefixes().
topMostMode(otherUser.modes());
127 if (prefixes().compare(mode1, mode2) != 0)
129 return prefixes().compare(mode1, mode2) < 0;
135 bool bIsThisAlphabeticallySmaller = (thisNickname.compare(otherNickname) <= 0);
136 return bIsThisAlphabeticallySmaller;
141 assert(parentNetwork != NULL);
145 return QString(
"%1%2").arg(prefixes().prefixForMode(mode))
164 void IRCUserInfo::setModes(
const QList<char> &modes)
166 this->userModes = modes;
169 void IRCUserInfo::setMode(
char mode)
171 if (!userModes.contains(mode))
177 void IRCUserInfo::unsetMode(
char mode)
179 userModes.removeAll(mode);
QString fullSignature
Full user signature with nickname and hostname.
Interprets communication between the client and the IRC server.
char topMostMode(const QList< char > &candidates) const
Out of list of possible modes picks mode with highest priority.
QString cleanNickname() const
Returns nickname with no prefixes, contrary to the prefixedName() .
QString prefixedName() const
Will generate prefix based on the user flags.
bool isSameNickname(const IRCUserInfo &otherUser) const
Check if this user and user specified as parameter are the same user.
QString cleanNicknameLowerCase() const
Returns cleanNickname() with a call to IRCGlobal::toIrcLower() .
static QString toIrcLower(const QString &str)
RFC 1459 compliant toLower() method.
Holds information flags about given nickname.
const IRCUserPrefix & userPrefixes() const
All allowed modes with their nickname prefixes for this network.
QString prefixedNameLowerCase() const
Returns prefixedName() with a call to IRCGlobal::toIrcLower() .
One-to-one association of visible prefixes to user mode.
IRCUserInfo()
Creates invalid IRCUserInfo.
bool operator<=(const IRCUserInfo &otherUser) const
This operator can be used for sorting.