00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef CONTACT_H
00024 #define CONTACT_H
00025
00026 #include <list>
00027 #include <string>
00028
00029 #include <sigc++/signal_system.h>
00030
00031 #include <libicq2000/constants.h>
00032 #include <libicq2000/ref_ptr.h>
00033
00034 #include <libicq2000/Capabilities.h>
00035
00036 namespace ICQ2000 {
00037
00038
00039 const unsigned short STATUS_FLAG_ONLINE = 0x0000;
00040 const unsigned short STATUS_FLAG_AWAY = 0x0001;
00041 const unsigned short STATUS_FLAG_DND = 0x0002;
00042 const unsigned short STATUS_FLAG_NA = 0x0004;
00043 const unsigned short STATUS_FLAG_OCCUPIED = 0x0010;
00044 const unsigned short STATUS_FLAG_FREEFORCHAT = 0x0020;
00045 const unsigned short STATUS_FLAG_INVISIBLE = 0x0100;
00046
00047 class MessageEvent;
00048 class StatusChangeEvent;
00049 class UserInfoChangeEvent;
00050
00051 class Contact {
00052 public:
00053
00054 unsigned int count;
00055
00056
00057
00058 class MainHomeInfo {
00059 std::string cellular, normalised_cellular;
00060
00061
00062
00063 void normaliseMobileNo();
00064
00065 public:
00066 MainHomeInfo();
00067
00068 std::string alias, firstname, lastname, email, city, state, phone, fax, street, zip;
00069 unsigned short country;
00070 signed char timezone;
00071
00072 std::string getCountry() const;
00073 std::string getMobileNo() const;
00074 void setMobileNo(const std::string& s);
00075
00076 std::string getNormalisedMobileNo() const;
00077 };
00078
00079 class HomepageInfo {
00080 public:
00081 HomepageInfo();
00082
00083 unsigned char age, sex;
00084 std::string homepage;
00085 unsigned short birth_year;
00086 unsigned char birth_month, birth_day, lang1, lang2, lang3;
00087
00088 std::string getBirthDate() const;
00089 std::string getLanguage(int l) const;
00090 };
00091
00092 class EmailInfo {
00093 private:
00094 std::list<std::string> email_list;
00095
00096 public:
00097 EmailInfo();
00098
00099 void addEmailAddress(const std::string&);
00100 };
00101
00102 class WorkInfo {
00103 public:
00104 WorkInfo();
00105
00106 std::string city, state, street, zip;
00107 unsigned short country;
00108 std::string company_name, company_dept, company_position, company_web;
00109 };
00110
00111 class BackgroundInfo {
00112 public:
00113 typedef std::pair<unsigned short, std::string> School;
00114 std::list<School> schools;
00115
00116 BackgroundInfo();
00117
00118 void addSchool(unsigned short cat, const std::string& s);
00119 };
00120
00121 class PersonalInterestInfo {
00122 public:
00123 typedef std::pair<unsigned short, std::string> Interest;
00124 std::list<Interest> interests;
00125
00126 PersonalInterestInfo();
00127
00128 void addInterest(unsigned short cat, const std::string& s);
00129 };
00130
00131 private:
00132 void Init();
00133 bool m_icqcontact;
00134 bool m_virtualcontact;
00135
00136
00137 unsigned int m_uin;
00138
00139
00140 unsigned char m_tcp_version;
00141 Status m_status;
00142 bool m_invisible;
00143 bool m_authreq;
00144 bool m_direct;
00145 unsigned int m_ext_ip, m_lan_ip;
00146 unsigned short m_ext_port, m_lan_port;
00147 Capabilities m_capabilities;
00148 unsigned int m_signon_time, m_last_online_time, m_last_status_change_time;
00149 unsigned int m_last_message_time, m_last_away_msg_check_time;
00150
00151 static unsigned int imag_uin;
00152
00153
00154 unsigned short m_seqnum;
00155
00156
00157 MainHomeInfo m_main_home_info;
00158 HomepageInfo m_homepage_info;
00159 EmailInfo m_email_info;
00160 WorkInfo m_work_info;
00161 PersonalInterestInfo m_personal_interest_info;
00162 BackgroundInfo m_background_info;
00163 std::string m_about;
00164
00165 public:
00166 Contact();
00167
00168 Contact(unsigned int uin);
00169 Contact(const std::string& a);
00170
00171 unsigned int getUIN() const;
00172 void setUIN(unsigned int uin);
00173 std::string getStringUIN() const;
00174 std::string getMobileNo() const;
00175 std::string getNormalisedMobileNo() const;
00176 std::string getAlias() const;
00177 std::string getFirstName() const;
00178 std::string getLastName() const;
00179 std::string getEmail() const;
00180
00181 std::string getNameAlias() const;
00182
00183 Status getStatus() const;
00184 std::string getStatusStr() const;
00185 bool isInvisible() const;
00186 bool getAuthReq() const;
00187
00188 unsigned int getExtIP() const;
00189 unsigned int getLanIP() const;
00190 unsigned short getExtPort() const;
00191 unsigned short getLanPort() const;
00192 unsigned char getTCPVersion() const;
00193 bool get_accept_adv_msgs() const;
00194 Capabilities get_capabilities() const;
00195
00196 unsigned int get_signon_time() const;
00197 unsigned int get_last_online_time() const;
00198 unsigned int get_last_status_change_time() const;
00199 unsigned int get_last_message_time() const;
00200 unsigned int get_last_away_msg_check_time() const;
00201
00202 void setMobileNo(const std::string& mn);
00203 void setAlias(const std::string& al);
00204 void setFirstName(const std::string& fn);
00205 void setLastName(const std::string& ln);
00206 void setEmail(const std::string& em);
00207 void setAuthReq(bool b);
00208
00209 bool getDirect() const;
00210 void setDirect(bool b);
00211
00212 void setStatus(Status st, bool i);
00213 void setStatus(Status st);
00214 void setInvisible(bool i);
00215 void setExtIP(unsigned int ip);
00216 void setLanIP(unsigned int ip);
00217 void setExtPort(unsigned short port);
00218 void setLanPort(unsigned short port);
00219 void setTCPVersion(unsigned char v);
00220 void set_capabilities(const Capabilities& c);
00221
00222 void set_signon_time(unsigned int t);
00223 void set_last_online_time(unsigned int t);
00224 void set_last_status_change_time(unsigned int t);
00225 void set_last_message_time(unsigned int t);
00226 void set_last_away_msg_check_time(unsigned int t);
00227
00228 void setMainHomeInfo(const MainHomeInfo& m);
00229 void setHomepageInfo(const HomepageInfo& s);
00230 void setEmailInfo(const EmailInfo &e);
00231 void setWorkInfo(const WorkInfo &w);
00232 void setInterestInfo(const PersonalInterestInfo& p);
00233 void setBackgroundInfo(const BackgroundInfo& b);
00234 void setAboutInfo(const std::string& about);
00235
00236 MainHomeInfo& getMainHomeInfo();
00237 HomepageInfo& getHomepageInfo();
00238 EmailInfo& getEmailInfo();
00239 WorkInfo& getWorkInfo();
00240 BackgroundInfo& getBackgroundInfo();
00241 PersonalInterestInfo& getPersonalInterestInfo();
00242 const std::string& getAboutInfo() const;
00243
00244 bool isICQContact() const;
00245 bool isVirtualContact() const;
00246
00247 bool isSMSable() const;
00248
00249 unsigned short nextSeqNum();
00250
00251 SigC::Signal1<void,StatusChangeEvent*> status_change_signal;
00252 SigC::Signal1<void,UserInfoChangeEvent*> userinfo_change_signal;
00253
00254 void userinfo_change_emit();
00255 void userinfo_change_emit(bool is_transient_detail);
00256
00257 static std::string UINtoString(unsigned int uin);
00258 static unsigned int StringtoUIN(const std::string& s);
00259
00260 static unsigned short MapStatusToICQStatus(Status st, bool inv);
00261 static Status MapICQStatusToStatus(unsigned short st);
00262 static bool MapICQStatusToInvisible(unsigned short st);
00263
00264 static unsigned int nextImaginaryUIN();
00265 };
00266
00267 typedef ref_ptr<Contact> ContactRef;
00268 }
00269
00270 #endif