Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

Contact.h

00001 /*
00002  * Contact (model)
00003  * A contact on the contact list
00004  *
00005  * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
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 using std::list;
00037 using std::string;
00038 
00039 namespace ICQ2000 {
00040 
00041   // -- Status Codes Flags --
00042   const unsigned short STATUS_FLAG_ONLINE = 0x0000;
00043   const unsigned short STATUS_FLAG_AWAY = 0x0001;
00044   const unsigned short STATUS_FLAG_DND = 0x0002;
00045   const unsigned short STATUS_FLAG_NA = 0x0004;
00046   const unsigned short STATUS_FLAG_OCCUPIED = 0x0010;
00047   const unsigned short STATUS_FLAG_FREEFORCHAT = 0x0020;
00048   const unsigned short STATUS_FLAG_INVISIBLE = 0x0100;
00049 
00050   class MessageEvent;
00051   class StatusChangeEvent;
00052   class UserInfoChangeEvent;
00053 
00054   class Contact {
00055    public:
00056     // reference count
00057     unsigned int count;
00058 
00059     // Inner classes for various sections of Contact details
00060 
00061     class MainHomeInfo {
00062       string cellular, normalised_cellular;
00063       // cellular private - access must be through
00064       // get/setMobileNo for consistency
00065     
00066       void normaliseMobileNo();
00067 
00068     public:
00069       MainHomeInfo();
00070 
00071       string alias, firstname, lastname, email, city, state, phone, fax, street, zip;
00072       unsigned short country;
00073       signed char timezone;
00074 
00075       string getCountry() const;
00076       string getMobileNo() const;
00077       void setMobileNo(const string& s);
00078 
00079       string getNormalisedMobileNo() const;
00080     };
00081 
00082     class HomepageInfo {
00083     public:
00084       HomepageInfo();
00085 
00086       unsigned char age, sex;
00087       string homepage;
00088       unsigned short birth_year;
00089       unsigned char birth_month, birth_day, lang1, lang2, lang3;
00090 
00091       string getBirthDate() const;
00092       string getLanguage(int l) const;
00093     };
00094 
00095     class EmailInfo {
00096     private:
00097       list<string> email_list;
00098 
00099     public:
00100       EmailInfo();
00101 
00102       void addEmailAddress(const string&);
00103     };
00104   
00105     class WorkInfo {
00106     public:
00107       WorkInfo();
00108     
00109       string city, state, street, zip;
00110       unsigned short country;
00111       string company_name, company_dept, company_position, company_web;
00112     };
00113 
00114     class BackgroundInfo {
00115     public:
00116       typedef std::pair<unsigned short, string> School;
00117       list<School> schools;   // school names
00118 
00119       BackgroundInfo();
00120 
00121       void addSchool(unsigned short cat, const string& s);
00122     };
00123 
00124     class PersonalInterestInfo {
00125     public:
00126       typedef std::pair<unsigned short, string> Interest;
00127       list<Interest> interests;
00128 
00129       PersonalInterestInfo();
00130     
00131       void addInterest(unsigned short cat, const string& s);
00132     };
00133 
00134   private:
00135     void Init();
00136     bool m_icqcontact;
00137     bool m_virtualcontact;
00138 
00139     // static fields
00140     unsigned int m_uin;
00141 
00142     // dynamic fields - updated when they come online
00143     unsigned char m_tcp_version;
00144     Status m_status;
00145     bool m_invisible;
00146     bool m_authreq;
00147     bool m_direct;
00148     unsigned int m_ext_ip, m_lan_ip;
00149     unsigned short m_ext_port, m_lan_port;
00150     Capabilities m_capabilities;
00151     unsigned int m_signon_time, m_last_online_time, m_last_status_change_time;
00152     unsigned int m_last_message_time, m_last_away_msg_check_time;
00153 
00154     static unsigned int imag_uin;
00155     
00156     // other fields
00157     unsigned short m_seqnum;
00158 
00159     // detailed fields
00160     MainHomeInfo m_main_home_info;
00161     HomepageInfo m_homepage_info;
00162     EmailInfo m_email_info;
00163     WorkInfo m_work_info;
00164     PersonalInterestInfo m_personal_interest_info;
00165     BackgroundInfo m_background_info;
00166     string m_about;
00167 
00168   public:
00169     Contact();
00170 
00171     Contact(unsigned int uin);
00172     Contact(const string& a);
00173 
00174     unsigned int getUIN() const;
00175     void setUIN(unsigned int uin);
00176     string getStringUIN() const;
00177     string getMobileNo() const;
00178     string getNormalisedMobileNo() const;
00179     string getAlias() const;
00180     string getFirstName() const;
00181     string getLastName() const;
00182     string getEmail() const;
00183 
00184     string getNameAlias() const;
00185 
00186     Status getStatus() const;
00187     string getStatusStr() const;
00188     bool isInvisible() const;
00189     bool getAuthReq() const;
00190 
00191     unsigned int getExtIP() const;
00192     unsigned int getLanIP() const;
00193     unsigned short getExtPort() const;
00194     unsigned short getLanPort() const;
00195     unsigned char getTCPVersion() const;
00196     bool get_accept_adv_msgs() const;
00197     Capabilities get_capabilities() const;
00198 
00199     unsigned int get_signon_time() const;
00200     unsigned int get_last_online_time() const;
00201     unsigned int get_last_status_change_time() const;
00202     unsigned int get_last_message_time() const;
00203     unsigned int get_last_away_msg_check_time() const;
00204 
00205     void setMobileNo(const string& mn);
00206     void setAlias(const string& al);
00207     void setFirstName(const string& fn);
00208     void setLastName(const string& ln);
00209     void setEmail(const string& em);
00210     void setAuthReq(bool b);
00211 
00212     bool getDirect() const;
00213     void setDirect(bool b);
00214 
00215     void setStatus(Status st, bool i);
00216     void setStatus(Status st);
00217     void setInvisible(bool i);
00218     void setExtIP(unsigned int ip);
00219     void setLanIP(unsigned int ip);
00220     void setExtPort(unsigned short port);
00221     void setLanPort(unsigned short port);
00222     void setTCPVersion(unsigned char v);
00223     void set_capabilities(const Capabilities& c);
00224 
00225     void set_signon_time(unsigned int t);
00226     void set_last_online_time(unsigned int t);
00227     void set_last_status_change_time(unsigned int t);
00228     void set_last_message_time(unsigned int t);
00229     void set_last_away_msg_check_time(unsigned int t);
00230 
00231     void setMainHomeInfo(const MainHomeInfo& m);
00232     void setHomepageInfo(const HomepageInfo& s);
00233     void setEmailInfo(const EmailInfo &e);
00234     void setWorkInfo(const WorkInfo &w);
00235     void setInterestInfo(const PersonalInterestInfo& p);
00236     void setBackgroundInfo(const BackgroundInfo& b);
00237     void setAboutInfo(const string& about);
00238 
00239     MainHomeInfo& getMainHomeInfo();
00240     HomepageInfo& getHomepageInfo();
00241     EmailInfo& getEmailInfo();
00242     WorkInfo& getWorkInfo();
00243     BackgroundInfo& getBackgroundInfo();
00244     PersonalInterestInfo& getPersonalInterestInfo();
00245     const string& getAboutInfo() const;
00246 
00247     bool isICQContact() const;
00248     bool isVirtualContact() const;
00249 
00250     bool isSMSable() const;
00251 
00252     unsigned short nextSeqNum();
00253 
00254     SigC::Signal1<void,StatusChangeEvent*> status_change_signal;
00255     SigC::Signal1<void,UserInfoChangeEvent*> userinfo_change_signal;
00256 
00257     void userinfo_change_emit();
00258     void userinfo_change_emit(bool is_transient_detail);
00259 
00260     static string UINtoString(unsigned int uin);
00261     static unsigned int StringtoUIN(const string& s);
00262     
00263     static unsigned short MapStatusToICQStatus(Status st, bool inv);
00264     static Status MapICQStatusToStatus(unsigned short st);
00265     static bool MapICQStatusToInvisible(unsigned short st);
00266 
00267     static unsigned int nextImaginaryUIN();
00268   };
00269 
00270   typedef ref_ptr<Contact> ContactRef;
00271 }
00272 
00273 #endif

Generated on Fri Apr 26 23:48:14 2002 for libicq2000 by doxygen1.2.15