1 #ifndef _KVI_IRCCONNECTIONUSERINFO_H_
2 #define _KVI_IRCCONNECTIONUSERINFO_H_
3 //=============================================================================
4 //
5 //   File : KviIrcConnectionUserInfo.h
6 //   Creation date : Sun 20 Jun 2004 01:45:42 by Szymon Stefanek
7 //
8 //   This file is part of the KVIrc IRC client distribution
9 //   Copyright (C) 2004-2010 Szymon Stefanek <pragma at kvirc dot net>
10 //
11 //   This program is FREE software. You can redistribute it and/or
12 //   modify it under the terms of the GNU General Public License
13 //   as published by the Free Software Foundation; either version 2
14 //   of the License, or (at your option) any later version.
15 //
16 //   This program is distributed in the HOPE that it will be USEFUL,
17 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
18 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 //   See the GNU General Public License for more details.
20 //
21 //   You should have received a copy of the GNU General Public License
22 //   along with this program. If not, write to the Free Software Foundation,
23 //   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "kvi_settings.h"
28 #include "KviTimeUtils.h"
29 
30 #include <QString>
31 
32 class KVIRC_API KviIrcConnectionUserInfo
33 {
34 	friend class KviIrcConnection;
35 	friend class KviIrcServerParser;
36 	friend class KviConsoleWindow;
37 
38 protected:
39 	KviIrcConnectionUserInfo();
40 	~KviIrcConnectionUserInfo() = default;
41 
42 private:
43 	QString m_szRealName;    // the actual real name sent from the server
44 	QString m_szNickName;    // the actual nick name acknowledged by the server
45 	QString m_szPassword;    // the password used connecting to the server
46 	QString m_szUserMode;    // the actual user mode
47 	QString m_szUserName;    // user name with ident char
48 	QString m_szLocalHostIp; // the local host ip as found by resolveLocalHost() at connection startup
49 	QString m_szHostName;    // the local host name that the server reports
50 	QString m_szHostIp;      // the host name above resolved, if possible
51 	QString m_szAwayReason;
52 	bool m_bAway = false;       // is the user away ?
53 	kvi_time_t m_tAway;         // time at that the user went away
54 	QString m_szNickBeforeAway; // the nickname that the user had just before going away
55 	// From bugtrack:
56 	// On many IRC networks the host is masked or hashed, and if one also is connected through a LAN,
57 	// it is basically impossible to initiate DCC transfers, as 192.168.0.13 or similar will be sent as IP.
58 	// But IRC servers usually (at least in my experience) send the unmasked host in the 001 raw event
59 	// with something like ":Welcome to the Internet Relay Chat network, nick!ident@host". I think
60 	// it'd be a good idea to just grab the IP from that event and use it for DCC transfers by default.
61 	QString m_szUnmaskedHostName;
62 
63 public:
realName()64 	const QString & realName() const { return m_szRealName; }
nickName()65 	const QString & nickName() const { return m_szNickName; }
userMode()66 	const QString & userMode() const { return m_szUserMode; }
userName()67 	const QString & userName() const { return m_szUserName; }
password()68 	const QString & password() const { return m_szPassword; }
localHostIp()69 	const QString & localHostIp() const { return m_szLocalHostIp; }
hostName()70 	const QString & hostName() const { return m_szHostName; }
unmaskedHostName()71 	const QString & unmaskedHostName() const { return m_szUnmaskedHostName; }
hostIp()72 	const QString & hostIp() const { return m_szHostIp; }
awayReason()73 	const QString & awayReason() const { return m_szAwayReason; }
74 	bool hasUserMode(const QChar & m);
isAway()75 	bool isAway() const { return m_bAway; }
awayTime()76 	kvi_time_t awayTime() const { return m_tAway; }
nickNameBeforeAway()77 	const QString & nickNameBeforeAway() const { return m_szNickBeforeAway; }
78 protected:
setRealName(const QString & szRealName)79 	void setRealName(const QString & szRealName) { m_szRealName = szRealName; }
setNickName(const QString & szNickName)80 	void setNickName(const QString & szNickName) { m_szNickName = szNickName; }
setUserMode(const QString & szUserMode)81 	void setUserMode(const QString & szUserMode) { m_szUserMode = szUserMode; }
setUserName(const QString & szUserName)82 	void setUserName(const QString & szUserName) { m_szUserName = szUserName; }
setPassword(const QString & szPassword)83 	void setPassword(const QString & szPassword) { m_szPassword = szPassword; }
setHostName(const QString & szHostName)84 	void setHostName(const QString & szHostName) { m_szHostName = szHostName; }
setUnmaskedHostName(const QString & szHostName)85 	void setUnmaskedHostName(const QString & szHostName) { m_szUnmaskedHostName = szHostName; }
setHostIp(const QString & szHostIp)86 	void setHostIp(const QString & szHostIp) { m_szHostIp = szHostIp; }
setLocalHostIp(const QString & szLocalHostIp)87 	void setLocalHostIp(const QString & szLocalHostIp) { m_szLocalHostIp = szLocalHostIp; }
88 	bool addUserMode(const QChar & m);    // returns false if the mode was already there
89 	bool removeUserMode(const QChar & m); // returns fales if the mode was not there
setAwayReason(const QString & szReazon)90 	void setAwayReason(const QString & szReazon) { m_szAwayReason = szReazon; }
91 	void setAway();
92 	void setBack();
93 };
94 
95 #endif //!_KVI_IRCCONNECTIONUSERINFO_H_
96