3 * a list of groups, then list of contacts within each group
5 * Copyright (C) 2002 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
31 #include <libicq2000/Contact.h>
32 #include <libicq2000/sigslot.h>
36 class ContactListEvent
;
38 // ---------------------------------------------------------------------------
40 // (typedef'd into ContactTree::Group)
41 // ---------------------------------------------------------------------------
42 class _ContactTree_Group
45 std::map
<unsigned int, ContactRef
> m_crefs
;
47 // unique id, used by server
56 std::map
<unsigned int,ContactRef
>::iterator iter
;
59 iterator(std::map
<unsigned int,ContactRef
>::iterator i
)
62 iterator
& operator++() { ++iter
; return *this; }
63 iterator
operator++(int) { return iterator(iter
++); }
64 bool operator==(const iterator
& x
) const { return iter
== x
.iter
; }
65 bool operator!=(const iterator
& x
) const { return iter
!= x
.iter
; }
66 ContactRef
& operator*() { return (*iter
).second
; }
69 class const_iterator
{
71 std::map
<unsigned int,ContactRef
>::const_iterator iter
;
74 const_iterator(std::map
<unsigned int,ContactRef
>::const_iterator i
)
77 const_iterator
& operator++() { ++iter
; return *this; }
78 const_iterator
operator++(int) { return const_iterator(iter
++); }
79 bool operator==(const const_iterator
& x
) const { return iter
== x
.iter
; }
80 bool operator!=(const const_iterator
& x
) const { return iter
!= x
.iter
; }
81 const ContactRef
& operator*() { return (*iter
).second
; }
84 _ContactTree_Group(const std::string
& l
, unsigned short id
);
86 _ContactTree_Group(const _ContactTree_Group
& gp
);
88 unsigned short get_id() const;
89 void set_id(unsigned short i
) { m_id
= i
; }
91 std::string
get_label() const;
92 void set_label(const std::string
& l
);
94 ContactRef
operator[](unsigned int uin
);
95 ContactRef
lookup_uin(unsigned int uin
);
96 ContactRef
lookup_mobile(const std::string
& m
);
97 ContactRef
lookup_email(const std::string
& em
);
99 ContactRef
add(ContactRef ct
);
100 void remove(unsigned int uin
);
102 void relocate_from(ContactRef ct
);
103 void relocate_to(ContactRef ct
);
105 unsigned int size() const;
108 bool exists(unsigned int uin
);
109 bool mobile_exists(const std::string
& m
);
110 bool email_exists(const std::string
& em
);
114 const_iterator
begin() const;
115 const_iterator
end() const;
117 // aggregation of contact's
118 sigslot::signal1
<StatusChangeEvent
*> contact_status_change_signal
;
119 sigslot::signal1
<UserInfoChangeEvent
*> contact_userinfo_change_signal
;
121 sigslot::signal1
<ContactListEvent
*> contactlist_signal
;
124 // ---------------------------------------------------------------------------
126 // ---------------------------------------------------------------------------
130 typedef _ContactTree_Group Group
;
131 typedef std::list
<Group
>::iterator iterator
;
132 typedef std::list
<Group
>::const_iterator const_iterator
;
136 std::list
<Group
> m_groups
;
138 unsigned short get_unique_group_id() const;
142 ContactTree(const ContactTree
& ct
);
144 Group
& add_group(const std::string
& l
);
145 Group
& add_group(const std::string
& l
, unsigned short group_id
);
146 void remove_group(Group
& gp
);
147 void remove_group(unsigned short group_id
);
148 bool exists_group(unsigned short group_id
);
149 Group
& lookup_group(unsigned short group_id
);
150 Group
& lookup_group_containing_contact(ContactRef ct
);
152 void relocate_contact(ContactRef ct
, Group
& from
, Group
& to
);
154 ContactRef
operator[](unsigned int uin
);
155 ContactRef
lookup_uin(unsigned int uin
);
156 ContactRef
lookup_mobile(const std::string
& m
);
157 ContactRef
lookup_email(const std::string
& em
);
158 void remove(unsigned int uin
);
160 unsigned int size() const;
161 unsigned int group_size() const;
164 bool exists(unsigned int uin
);
165 bool mobile_exists(const std::string
& m
);
166 bool email_exists(const std::string
& em
);
170 const_iterator
begin() const;
171 const_iterator
end() const;
173 // aggregation of contact's
174 sigslot::signal1
<StatusChangeEvent
*> contact_status_change_signal
;
175 sigslot::signal1
<UserInfoChangeEvent
*> contact_userinfo_change_signal
;
177 sigslot::signal1
<ContactListEvent
*> contactlist_signal
;