00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CONTACTLIST_H
00023 #define CONTACTLIST_H
00024
00025 #include <list>
00026 #include <string>
00027 #include <map>
00028
00029 #include <libicq2000/Contact.h>
00030 #include <sigc++/signal_system.h>
00031
00032 using std::list;
00033 using std::string;
00034 using std::map;
00035
00036 namespace ICQ2000 {
00037
00038 class ContactListEvent;
00039
00040 class _ContactList_iterator {
00041 private:
00042 map<unsigned int,ContactRef>::iterator iter;
00043
00044 public:
00045 _ContactList_iterator(map<unsigned int,ContactRef>::iterator i)
00046 : iter(i) { }
00047
00048 _ContactList_iterator& operator++() { ++iter; return *this; }
00049 _ContactList_iterator operator++(int) { return _ContactList_iterator(iter++); }
00050 bool operator==(const _ContactList_iterator& x) const { return iter == x.iter; }
00051 bool operator!=(const _ContactList_iterator& x) const { return iter != x.iter; }
00052 ContactRef& operator*() { return (*iter).second; }
00053 };
00054
00055 class _ContactList_const_iterator {
00056 private:
00057 map<unsigned int,ContactRef>::const_iterator iter;
00058
00059 public:
00060 _ContactList_const_iterator(map<unsigned int,ContactRef>::const_iterator i)
00061 : iter(i) { }
00062
00063 _ContactList_const_iterator& operator++() { ++iter; return *this; }
00064 _ContactList_const_iterator operator++(int) { return _ContactList_const_iterator(iter++); }
00065 bool operator==(const _ContactList_const_iterator& x) const { return iter == x.iter; }
00066 bool operator!=(const _ContactList_const_iterator& x) const { return iter != x.iter; }
00067 const ContactRef& operator*() { return (*iter).second; }
00068 };
00069
00070 class ContactList {
00071 private:
00072 map<unsigned int,ContactRef> m_cmap;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 public:
00087 typedef _ContactList_iterator iterator;
00088 typedef _ContactList_const_iterator const_iterator;
00089
00090 ContactList();
00091 ContactList(const ContactList& cl);
00092
00093 ContactRef operator[](unsigned int uin);
00094 ContactRef lookup_uin(unsigned int uin);
00095 ContactRef lookup_mobile(const std::string& m);
00096 ContactRef lookup_email(const std::string& em);
00097 ContactRef add(ContactRef ct);
00098 void remove(unsigned int uin);
00099
00100 unsigned int size() const;
00101 bool empty() const;
00102
00103 bool exists(unsigned int uin);
00104 bool mobile_exists(const string& m);
00105 bool email_exists(const string& em);
00106
00107 iterator begin();
00108 iterator end();
00109 const_iterator begin() const;
00110 const_iterator end() const;
00111
00112 SigC::Signal1<void,ContactListEvent*> contactlist_signal;
00113 };
00114
00115 }
00116
00117 #endif