3 * A contact on the contact list
5 * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <libicq2000/sigslot.h>
31 #include <libicq2000/constants.h>
32 #include <libicq2000/userinfoconstants.h>
34 #include <libicq2000/ref_ptr.h>
38 /* predeclare classes */
41 class StatusChangeEvent
;
42 class UserInfoChangeEvent
;
44 // -- Status Codes Flags --
45 const unsigned short STATUS_FLAG_ONLINE
= 0x0000;
46 const unsigned short STATUS_FLAG_AWAY
= 0x0001;
47 const unsigned short STATUS_FLAG_DND
= 0x0002;
48 const unsigned short STATUS_FLAG_NA
= 0x0004;
49 const unsigned short STATUS_FLAG_OCCUPIED
= 0x0010;
50 const unsigned short STATUS_FLAG_FREEFORCHAT
= 0x0020;
51 const unsigned short STATUS_FLAG_INVISIBLE
= 0x0100;
59 // Inner classes for various sections of Contact details
63 std::string cellular
, normalised_cellular
;
64 // cellular private - access must be through
65 // get/setMobileNo for consistency
67 void normaliseMobileNo();
72 std::string alias
, firstname
, lastname
, email
, city
, state
, phone
, fax
, street
, zip
;
76 Country
getCountry() const;
77 std::string
getMobileNo() const;
78 void setMobileNo(const std::string
& s
);
80 std::string
getNormalisedMobileNo() const;
90 Language lang1
, lang2
, lang3
;
93 unsigned short birth_year
;
94 unsigned char birth_month
, birth_day
;
96 std::string
getBirthDate() const;
97 Language
getLanguage(int l
) const;
103 typedef std::list
<std::string
> EmailList
;
108 void addEmailAddress(const std::string
&);
116 std::string city
, state
, street
, zip
;
117 unsigned short country
;
118 std::string company_name
, company_dept
, company_position
, company_web
;
124 typedef std::pair
<unsigned short, std::string
> School
;
125 typedef std::list
<School
> SchoolList
;
126 SchoolList schools
; // school names
130 void addSchool(unsigned short cat
, const std::string
& s
);
133 class PersonalInterestInfo
136 typedef std::pair
<unsigned short, std::string
> Interest
;
137 typedef std::list
<Interest
> InterestList
;
138 InterestList interests
;
140 PersonalInterestInfo();
142 void addInterest(unsigned short cat
, const std::string
& s
);
148 bool m_virtualcontact
;
153 // dynamic fields - updated when they come online
154 unsigned char m_tcp_version
;
155 unsigned int m_dc_cookie
;
158 bool m_authreq
, m_authawait
;
160 bool m_bday
; // Birthday Flag
162 unsigned int m_ext_ip
, m_lan_ip
;
163 unsigned short m_ext_port
, m_lan_port
, m_group_id
, m_tag_id
;
164 Capabilities
* m_capabilities
;
165 unsigned int m_signon_time
, m_last_online_time
, m_last_status_change_time
;
166 unsigned int m_last_message_time
, m_last_away_msg_check_time
;
168 static unsigned int imag_uin
;
171 unsigned short m_seqnum
;
174 MainHomeInfo m_main_home_info
;
175 HomepageInfo m_homepage_info
;
176 EmailInfo m_email_info
;
177 WorkInfo m_work_info
;
178 PersonalInterestInfo m_personal_interest_info
;
179 BackgroundInfo m_background_info
;
185 Contact(unsigned int uin
);
186 Contact(const std::string
& a
);
190 unsigned int getUIN() const;
191 void setUIN(unsigned int uin
);
192 std::string
getStringUIN() const;
193 std::string
getMobileNo() const;
194 std::string
getNormalisedMobileNo() const;
195 std::string
getAlias() const;
196 std::string
getFirstName() const;
197 std::string
getLastName() const;
198 std::string
getEmail() const;
200 std::string
getNameAlias() const;
202 Status
getStatus() const;
203 bool isInvisible() const;
204 bool getAuthReq() const;
205 bool getAuthAwait() const;
206 bool getServerBased() const;
208 unsigned int getExtIP() const;
209 unsigned int getLanIP() const;
210 unsigned short getExtPort() const;
211 unsigned short getLanPort() const;
212 unsigned char getTCPVersion() const;
213 unsigned int getDCCookie() const;
214 bool get_accept_adv_msgs() const;
215 Capabilities
get_capabilities() const;
217 unsigned int get_signon_time() const;
218 unsigned int get_last_online_time() const;
219 unsigned int get_last_status_change_time() const;
220 unsigned int get_last_message_time() const;
221 unsigned int get_last_away_msg_check_time() const;
223 void setMobileNo(const std::string
& mn
);
224 void setAlias(const std::string
& al
);
225 void setFirstName(const std::string
& fn
);
226 void setLastName(const std::string
& ln
);
227 void setEmail(const std::string
& em
);
228 void setAuthReq(bool b
);
229 void setAuthAwait(bool b
);
230 void setServerBased(bool b
);
232 bool getDirect() const;
233 void setDirect(bool b
);
235 bool getBirthday() const;
236 void setBirthday(bool b
);
238 void setStatus(Status st
, bool i
);
239 void setStatus(Status st
);
240 void setInvisible(bool i
);
241 void setExtIP(unsigned int ip
);
242 void setLanIP(unsigned int ip
);
243 void setExtPort(unsigned short port
);
244 void setLanPort(unsigned short port
);
245 void setTCPVersion(unsigned char v
);
246 void setDCCookie(unsigned int cookie
);
247 void set_capabilities(const Capabilities
& c
);
249 void setServerSideInfo(unsigned short group_id
, unsigned short tag_id
);
250 unsigned short getServerSideGroupID() const;
251 unsigned short getServerSideID() const;
253 void set_signon_time(unsigned int t
);
254 void set_last_online_time(unsigned int t
);
255 void set_last_status_change_time(unsigned int t
);
256 void set_last_message_time(unsigned int t
);
257 void set_last_away_msg_check_time(unsigned int t
);
259 void setMainHomeInfo(const MainHomeInfo
& m
);
260 void setHomepageInfo(const HomepageInfo
& s
);
261 void setEmailInfo(const EmailInfo
&e
);
262 void setWorkInfo(const WorkInfo
&w
);
263 void setInterestInfo(const PersonalInterestInfo
& p
);
264 void setBackgroundInfo(const BackgroundInfo
& b
);
265 void setAboutInfo(const std::string
& about
);
267 MainHomeInfo
& getMainHomeInfo();
268 HomepageInfo
& getHomepageInfo();
269 EmailInfo
& getEmailInfo();
270 WorkInfo
& getWorkInfo();
271 BackgroundInfo
& getBackgroundInfo();
272 PersonalInterestInfo
& getPersonalInterestInfo();
273 const std::string
& getAboutInfo() const;
275 bool isICQContact() const;
276 bool isVirtualContact() const;
278 bool isSMSable() const;
280 unsigned short nextSeqNum();
282 sigslot::signal1
<StatusChangeEvent
*> status_change_signal
;
283 sigslot::signal1
<UserInfoChangeEvent
*> userinfo_change_signal
;
285 void userinfo_change_emit();
286 void userinfo_change_emit(bool is_transient_detail
);
288 static std::string
UINtoString(unsigned int uin
);
289 static unsigned int StringtoUIN(const std::string
& s
);
291 static unsigned short MapStatusToICQStatus(Status st
, bool inv
);
292 static Status
MapICQStatusToStatus(unsigned short st
);
293 static bool MapICQStatusToInvisible(unsigned short st
);
295 static unsigned int nextImaginaryUIN();
298 typedef ref_ptr
<Contact
> ContactRef
;
302 Sbl_item() { uin
= 0; tag_id
= 0; }
303 Sbl_item(ContactRef
& cont
, unsigned short tag_id
, std::string group_name
) {
304 this->uin
= cont
->getUIN(); this->tag_id
= tag_id
; this->group_name
= group_name
;
305 this->nickname
= cont
->getAlias(); this->awaitAuth
= cont
->getAuthAwait();
306 if (this->nickname
.size() == 0)
307 this->nickname
= Contact::UINtoString(this->uin
);
310 Sbl_item(Sbl_item
&item
, unsigned short tag_id
, std::string group_name
) {
311 this->uin
= item
.uin
; this->tag_id
= tag_id
; this->group_name
= group_name
;
312 this->nickname
= item
.nickname
; this->awaitAuth
= item
.awaitAuth
;
315 Sbl_item(unsigned short group_id
, std::string group_name
) {
316 this->tag_id
= group_id
;
317 this->group_name
= group_name
;
321 unsigned short tag_id
;
322 std::string group_name
;
324 std::string nickname
;
330 Sbl_group() { group_id
= 0; }
331 Sbl_group(std::string name
, unsigned short group_id
) {
333 this->group_id
= group_id
;
337 unsigned short group_id
;
338 std::set
<unsigned short> buddies
;