KVIrc  4.9.2
DeveloperAPIs
KviIrcUserEntry.h
Go to the documentation of this file.
1 #ifndef _KVI_IRCUSER_ENTRY_H_
2 #define _KVI_IRCUSER_ENTRY_H_
3 
4 //=============================================================================
5 //
6 // File : KviIrcUserEntry.h
7 // Creation date : Tue Jan 04 2010 22:45:12 by Elvio Basello
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
36 #include <memory>
37 
38 #include "kvi_settings.h"
39 #include "KviAvatar.h"
40 
46 {
47  friend class KviIrcUserDataBase;
48 
49 public:
54  enum Gender
55  {
56  Male = 0,
57  Female = 1,
58  Unknown = 3
59  };
60 
65  enum UserMode
66  {
67  UserOp = 1,
68  Voice = 2,
69  HalfOp = 4,
70  Op = 8,
71  ChanAdmin = 16,
72  ChanOwner = 32,
73  ModeMask = UserOp | Voice | HalfOp | Op | ChanAdmin | ChanOwner
74  };
75 
82  KviIrcUserEntry(const QString & user, const QString & host);
83 
84 protected:
85  QString m_szUser;
86  QString m_szHost;
87 
88  QString m_szServer;
89  QString m_szRealName;
90  int m_iHops;
92  QString m_szUserFlags;
93 
94  bool m_bAway;
95  bool m_bIrcOp;
96 
97  std::unique_ptr<KviAvatar> m_upAvatar;
98 
99  int m_nRefs;
100  bool m_bBot;
102 
106 
109 
112 
113 public:
118  int smartNickColor() { return m_iSmartNickColor; };
119 
125  void setSmartNickColor(const int iColor) { m_iSmartNickColor = iColor; };
126 
131  Gender gender() { return m_eGender; };
132 
138  void setBot(bool bIsBot) { m_bBot = bIsBot; };
139 
145  void setGender(Gender g) { m_eGender = g; };
146 
152  void setUser(const QString & szUser) { m_szUser = szUser; };
153 
159  void setServer(const QString & szServ) { m_szServer = szServ; };
160 
166  void setRealName(const QString & szReal);
167 
173  void setHops(int iHops) { m_iHops = iHops; };
174 
180  void setHost(const QString & szHost) { m_szHost = szHost; };
181 
187  void setAway(bool bAway) { m_bAway = bAway; };
188 
194  void setIrcOp(bool bIrcOp) { m_bIrcOp = bIrcOp; };
195 
202  void setAvatar(std::unique_ptr<KviAvatar> upAvatar = nullptr);
203 
211  void setAvatar(KviAvatar * upAvatar = nullptr);
212 
218  void setUserFlags(const QString & szFlags) { m_szUserFlags = szFlags; };
219 
224  bool isBot() { return m_bBot; };
225 
230  bool isAway() const { return m_bAway; };
231 
236  bool isIrcOp() const { return m_bIrcOp; };
237 
242  bool hasUser() { return (!m_szUser.isEmpty()); };
243 
248  bool hasHost() { return (!m_szHost.isEmpty()); };
249 
254  bool hasServer() { return (!m_szServer.isEmpty()); };
255 
260  bool hasRealName() { return (!m_szRealName.isEmpty()); };
261 
266  bool hasHops() { return m_iHops >= 0; };
267 
272  const QString & user() { return m_szUser; };
273 
278  const QString & host() { return m_szHost; };
279 
284  const QString & server() { return m_szServer; };
285 
290  const QString & realName() { return m_szRealName; };
291 
296  const QString & userFlags() { return m_szUserFlags; };
297 
302  int hops() { return m_iHops; };
303 
308  KviAvatar * avatar() { return m_upAvatar.get(); };
309 
314  int nRefs() { return m_nRefs; };
315 
320  std::unique_ptr<KviAvatar> forgetAvatar();
321 
326  bool avatarRequested() const { return m_bAvatarRequested; };
327 
331  void setAvatarRequested() { m_bAvatarRequested = true; };
332 
337  const QString & accountName() { return m_szAccountName; };
338 
342  void setAccountName(const QString & szAccountName) { m_szAccountName = szAccountName; };
343 
348  bool hasAccountName() { return (!m_szAccountName.isEmpty()); };
349 };
350 
351 #endif // _KVI_IRCUSER_ENTRY_H_
const QString & host()
Returns the hostname of the user.
Definition: KviIrcUserEntry.h:278
const QString & accountName()
Returns the account name (if any)
Definition: KviIrcUserEntry.h:337
void setUserFlags(const QString &szFlags)
Sets the user global flags (eg: "G*")
Definition: KviIrcUserEntry.h:218
void setSmartNickColor(const int iColor)
Sets the ircview smart nick color of the user.
Definition: KviIrcUserEntry.h:125
bool hasUser()
Returns true if the user has the username set.
Definition: KviIrcUserEntry.h:242
QString m_szRegisteredUserName
Definition: KviIrcUserEntry.h:104
bool m_bIrcOp
Definition: KviIrcUserEntry.h:95
void setUser(const QString &szUser)
Sets the username of the user.
Definition: KviIrcUserEntry.h:152
std::unique_ptr< KviAvatar > m_upAvatar
Definition: KviIrcUserEntry.h:97
QString m_szUser
Definition: KviIrcUserEntry.h:85
void setIrcOp(bool bIrcOp)
Sets the irc operator state of the user.
Definition: KviIrcUserEntry.h:194
bool m_bAway
Definition: KviIrcUserEntry.h:94
QString m_szHost
Definition: KviIrcUserEntry.h:86
QString m_szAccountName
Definition: KviIrcUserEntry.h:111
void setHost(const QString &szHost)
Sets the hostname of the user.
Definition: KviIrcUserEntry.h:180
bool m_bBot
Definition: KviIrcUserEntry.h:100
int m_nRefs
Definition: KviIrcUserEntry.h:99
bool hasHops()
Returns true if the user has hops set.
Definition: KviIrcUserEntry.h:266
int m_iHops
Definition: KviIrcUserEntry.h:90
QColor m_cachedColor
Definition: KviIrcUserEntry.h:107
const QString & user()
Returns the username of the user.
Definition: KviIrcUserEntry.h:272
QString m_szRealName
Definition: KviIrcUserEntry.h:89
Gender
Defines the gender of the user.
Definition: KviIrcUserEntry.h:54
QString szHost
Definition: libkvisetup.cpp:45
bool hasAccountName()
Returns true if the user has an account name.
Definition: KviIrcUserEntry.h:348
Gender m_eGender
Definition: KviIrcUserEntry.h:91
Avatar class.
Definition: KviAvatar.h:52
const QString & server()
Returns the server of the user.
Definition: KviIrcUserEntry.h:284
int hops()
Returns the number of hops.
Definition: KviIrcUserEntry.h:302
bool hasHost()
Returns true if the user has the hostname set.
Definition: KviIrcUserEntry.h:248
QString m_szServer
Definition: KviIrcUserEntry.h:88
bool hasServer()
Returns true if the user has the server set.
Definition: KviIrcUserEntry.h:254
bool m_bAvatarRequested
Definition: KviIrcUserEntry.h:101
void setServer(const QString &szServ)
Sets the server of the user.
Definition: KviIrcUserEntry.h:159
void setGender(Gender g)
Sets the gender of the user.
Definition: KviIrcUserEntry.h:145
#define g
Definition: detector.cpp:71
KviAvatar * avatar()
Returns the avatar of the user.
Definition: KviIrcUserEntry.h:308
Avatar handling.
bool m_bUseCustomColor
Definition: KviIrcUserEntry.h:108
UserMode
Defines the user mode in a channel.
Definition: KviIrcUserEntry.h:65
int m_iSmartNickColor
Definition: KviIrcUserEntry.h:110
void setBot(bool bIsBot)
Sets the user as a bot.
Definition: KviIrcUserEntry.h:138
void setHops(int iHops)
Sets the number of hops of the user.
Definition: KviIrcUserEntry.h:173
bool isBot()
Returns true if the user is marked as a bot.
Definition: KviIrcUserEntry.h:224
bool isIrcOp() const
Returns true if the user is an irc operator.
Definition: KviIrcUserEntry.h:236
A class to handle the entries of the user database.
Definition: KviIrcUserEntry.h:45
int nRefs()
Returns the number of references of the user in the database.
Definition: KviIrcUserEntry.h:314
void setAway(bool bAway)
Sets the away state of the user.
Definition: KviIrcUserEntry.h:187
The class which manages the user database.
Definition: KviIrcUserDataBase.h:45
const QString & realName()
Returns the realname of the user.
Definition: KviIrcUserEntry.h:290
bool avatarRequested() const
Returns true if kvirc already made an attempt to download user's avatar.
Definition: KviIrcUserEntry.h:326
bool isAway() const
Returns true if the user is in away mode.
Definition: KviIrcUserEntry.h:230
QString m_szLastRegisteredMatchNick
Definition: KviIrcUserEntry.h:105
QString m_szUserFlags
Definition: KviIrcUserEntry.h:92
const QString & userFlags()
Returns the user flags.
Definition: KviIrcUserEntry.h:296
Gender gender()
Returns the gender of the user.
Definition: KviIrcUserEntry.h:131
int smartNickColor()
Returns the ircview smart nick color of the user.
Definition: KviIrcUserEntry.h:118
This file contains compile time settings.
bool hasRealName()
Returns true if the user has the realname set.
Definition: KviIrcUserEntry.h:260
#define KVILIB_API
Definition: kvi_settings.h:125
bool m_bNotFoundRegUserLookup
Definition: KviIrcUserEntry.h:103
void setAccountName(const QString &szAccountName)
Sets the account name for the user.
Definition: KviIrcUserEntry.h:342
void setAvatarRequested()
Mark that kvirc is trying (already tried) to get user's avatar.
Definition: KviIrcUserEntry.h:331