4 * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "UserInfoBlock.h"
31 UserInfoBlock::UserInfoBlock()
32 : m_contains_capabilities(false)
35 string
UserInfoBlock::getScreenName() const { return m_screenname
; }
37 unsigned int UserInfoBlock::getUIN() const {
38 return Contact::StringtoUIN(m_screenname
);
41 unsigned int UserInfoBlock::getTimeOnline() const { return m_timeOnline
; }
42 unsigned int UserInfoBlock::getSignupDate() const { return m_signupDate
; }
43 unsigned int UserInfoBlock::getSignonDate() const { return m_signonDate
; }
44 unsigned int UserInfoBlock::getLanIP() const { return m_lan_ip
; }
45 unsigned int UserInfoBlock::getExtIP() const { return m_ext_ip
; }
46 unsigned short UserInfoBlock::getLanPort() const { return m_lan_port
; }
47 unsigned short UserInfoBlock::getExtPort() const { return m_ext_port
; }
48 unsigned short UserInfoBlock::getFirewall() const { return m_firewall
; }
49 unsigned int UserInfoBlock::getDCCookie() const { return m_dc_cookie
; }
50 unsigned char UserInfoBlock::getTCPVersion() const { return m_tcp_version
; }
51 unsigned short UserInfoBlock::getStatus() const { return m_status
; }
52 bool UserInfoBlock::getBirthday() const { return m_birthday
; }
53 bool UserInfoBlock::contains_capabilities() const { return m_contains_capabilities
; }
54 Capabilities
UserInfoBlock::get_capabilities() const { return m_capabilities
; }
56 void UserInfoBlock::Parse(Buffer
& b
) {
57 // (byte)length, string screenname
58 b
.UnpackByteString(m_screenname
);
61 unsigned short no_tlvs
;
65 tlvlist
.Parse(b
, TLV_ParseMode_Channel02
, no_tlvs
);
68 if (tlvlist
.exists(TLV_UserClass
)) {
69 UserClassTLV
*t
= (UserClassTLV
*)tlvlist
[TLV_UserClass
];
70 m_userClass
= t
->Value();
76 if (tlvlist
.exists(TLV_Status
)) {
77 StatusTLV
*t
= (StatusTLV
*)tlvlist
[TLV_Status
];
78 m_allowDirect
= t
->getAllowDirect();
79 m_webAware
= t
->getWebAware();
80 m_status
= t
->getStatus();
81 m_birthday
= t
->getBirthday();
85 if (tlvlist
.exists(TLV_TimeOnline
)) {
86 TimeOnlineTLV
*t
= (TimeOnlineTLV
*)tlvlist
[TLV_TimeOnline
];
87 m_timeOnline
= t
->Value();
91 if (tlvlist
.exists(TLV_SignupDate
)) {
92 SignupDateTLV
*t
= (SignupDateTLV
*)tlvlist
[TLV_SignupDate
];
93 m_signupDate
= t
->Value();
97 if (tlvlist
.exists(TLV_SignonDate
)) {
98 SignonDateTLV
*t
= (SignonDateTLV
*)tlvlist
[TLV_SignonDate
];
99 m_signonDate
= t
->Value();
106 if (tlvlist
.exists(TLV_LANDetails
)) {
107 LANDetailsTLV
*t
= (LANDetailsTLV
*)tlvlist
[TLV_LANDetails
];
108 m_lan_ip
= t
->getLanIP();
109 m_lan_port
= t
->getLanPort();
110 m_firewall
= t
->getFirewall();
111 m_tcp_version
= t
->getTCPVersion();
112 m_dc_cookie
= t
->getDCCookie();
116 if (tlvlist
.exists(TLV_IPAddress
)) {
117 IPAddressTLV
*t
= (IPAddressTLV
*)tlvlist
[TLV_IPAddress
];
118 m_ext_ip
= t
->Value();
122 if (tlvlist
.exists(TLV_Port
)) {
123 PortTLV
*t
= (PortTLV
*)tlvlist
[TLV_Port
];
124 m_ext_port
= t
->Value();
127 if (tlvlist
.exists(TLV_Capabilities
)) {
128 CapabilitiesTLV
*t
= (CapabilitiesTLV
*)tlvlist
[TLV_Capabilities
];
129 m_contains_capabilities
= true;
130 m_capabilities
= t
->get_capabilities();