comparison src/protocols/msn/group.h @ 5518:bf2a7a7b739d

[gaim-migrate @ 5918] Reworked the group support. You should now be able to delete groups by dragging a user into them and then back out. I stress _should_. This will likely have bugs. I cleaned up the ones I found, I think, but I'm not 100% confident here :) Please test! Preferably on test accounts, but it won't kill things, just reorder stuff. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 25 May 2003 22:51:19 +0000
parents
children b7e113a59b51
comparison
equal deleted inserted replaced
5517:e9b9fbf89c42 5518:bf2a7a7b739d
1 /**
2 * @file group.h Group functions
3 *
4 * gaim
5 *
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 #ifndef _MSN_GROUP_H_
23 #define _MSN_GROUP_H_
24
25 typedef struct _MsnGroup MsnGroup;
26 typedef struct _MsnGroups MsnGroups;
27
28 #include "session.h"
29 #include "user.h"
30
31 /**
32 * A group.
33 */
34 struct _MsnGroup
35 {
36 size_t ref_count; /**< The reference count. */
37
38 MsnSession *session; /**< The MSN session. */
39
40 int id; /**< The group ID. */
41 char *name; /**< The name of the group. */
42
43 MsnUsers *users; /**< The users in the group. */
44 };
45
46 /**
47 * A list of groups.
48 */
49 struct _MsnGroups
50 {
51 size_t count; /**< The number of groups. */
52
53 GList *groups; /**< The list of groups. */
54 };
55
56 /**************************************************************************/
57 /** @name Group API */
58 /**************************************************************************/
59 /*@{*/
60
61 /**
62 * Creates a new group structure.
63 *
64 * @param session The MSN session.
65 * @param id The group ID.
66 * @param name The name of the group.
67 *
68 * @return A new group structure.
69 */
70 MsnGroup *msn_group_new(MsnSession *session, int id, const char *name);
71
72 /**
73 * Destroys a group structure.
74 *
75 * @param group The group to destroy.
76 */
77 void msn_group_destroy(MsnGroup *group);
78
79 /**
80 * Increments the reference count on a group.
81 *
82 * @param group The group.
83 *
84 * @return @a group
85 */
86 MsnGroup *msn_group_ref(MsnGroup *group);
87
88 /**
89 * Decrements the reference count on a group.
90 *
91 * This will destroy the structure if the count hits 0.
92 *
93 * @param group The group.
94 *
95 * @return @a group, or @c NULL if the new count is 0.
96 */
97 MsnGroup *msn_group_unref(MsnGroup *group);
98
99 /**
100 * Sets the ID for a group.
101 *
102 * @param group The group.
103 * @param id The ID.
104 */
105 void msn_group_set_id(MsnGroup *group, int id);
106
107 /**
108 * Sets the name for a group.
109 *
110 * @param group The group.
111 * @param name The name.
112 */
113 void msn_group_set_name(MsnGroup *group, const char *name);
114
115 /**
116 * Returns the ID for a group.
117 *
118 * @param group The group.
119 *
120 * @return The ID.
121 */
122 int msn_group_get_id(const MsnGroup *group);
123
124 /**
125 * Returns the name for a group.
126 *
127 * @param group The group.
128 *
129 * @return The name.
130 */
131 const char *msn_group_get_name(const MsnGroup *group);
132
133 /**
134 * Adds a user to the group.
135 *
136 * @param group The group.
137 * @param user The user.
138 */
139 void msn_group_add_user(MsnGroup *group, MsnUser *user);
140
141 /**
142 * Removes a user from the group.
143 *
144 * @param group The group.
145 * @param user The user.
146 */
147 void msn_group_remove_user(MsnGroup *group, MsnUser *user);
148
149 /**
150 * Returns the users in a group.
151 *
152 * @param group The group.
153 *
154 * @return The list of users.
155 */
156 MsnUsers *msn_group_get_users(const MsnGroup *group);
157
158 /*@}*/
159
160 /**************************************************************************/
161 /** @name Group List API */
162 /**************************************************************************/
163 /*@{*/
164
165 /**
166 * Creates a new MsnGroups structure.
167 *
168 * @return A new MsnGroups structure.
169 */
170 MsnGroups *msn_groups_new(void);
171
172 /**
173 * Destroys a groups list.
174 *
175 * @param groups The groups list.
176 */
177 void msn_groups_destroy(MsnGroups *groups);
178
179 /**
180 * Adds a group to a groups list.
181 *
182 * @param groups The groups list.
183 * @param group The group.
184 */
185 void msn_groups_add(MsnGroups *groups, MsnGroup *group);
186
187 /**
188 * Removes a group from a groups list.
189 *
190 * @param groups The groups list.
191 * @param group The group.
192 */
193 void msn_groups_remove(MsnGroups *groups, MsnGroup *group);
194
195 /**
196 * Returns the number of groups in a groups list.
197 *
198 * @param groups The groups list.
199 *
200 * @return The number of groups.
201 */
202 size_t msn_groups_get_count(const MsnGroups *groups);
203
204 /**
205 * Finds a group with the specified ID.
206 *
207 * @param groups A list of groups.
208 * @param id The group ID.
209 *
210 * @return The group if found, or @c NULL otherwise.
211 */
212 MsnGroup *msn_groups_find_with_id(MsnGroups *groups, int id);
213
214 /**
215 * Returns a GList of all groups.
216 *
217 * @param groups The list of groups.
218 *
219 * @return A GList of all groups.
220 */
221 GList *msn_groups_get_list(const MsnGroups *groups);
222
223 /**
224 * Finds a group with the specified name.
225 *
226 * @param groups A list of groups.
227 * @param name The group name.
228 *
229 * @return The group if found, or @c NULL otherwise.
230 */
231 MsnGroup *msn_groups_find_with_name(MsnGroups *groups, const char *name);
232
233 #endif /* _MSN_GROUP_H_ */