14192
|
1 /**
|
|
2 * The QQ2003C protocol plugin
|
|
3 *
|
|
4 * for gaim
|
|
5 *
|
|
6 * Copyright (C) 2004 Puzzlebird
|
|
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
|
|
23 #include "debug.h"
|
|
24
|
|
25 #include "buddy_status.h"
|
|
26 #include "group_free.h"
|
|
27 #include "group_network.h"
|
|
28
|
|
29 /* gracefully free all members in a group */
|
14404
|
30 static void qq_group_free_member(qq_group *group)
|
14192
|
31 {
|
|
32 gint i;
|
|
33 GList *list;
|
|
34 qq_buddy *member;
|
|
35
|
|
36 g_return_if_fail(group != NULL);
|
|
37 i = 0;
|
|
38 while (NULL != (list = group->members)) {
|
|
39 member = (qq_buddy *) list->data;
|
|
40 i++;
|
|
41 group->members = g_list_remove(group->members, member);
|
|
42 g_free(member->nickname);
|
|
43 g_free(member);
|
|
44 }
|
|
45
|
|
46 group->members = NULL;
|
|
47 }
|
|
48
|
|
49 /* gracefully free the memory for one qq_group */
|
14404
|
50 void qq_group_free(qq_group *group)
|
14192
|
51 {
|
|
52 g_return_if_fail(group != NULL);
|
14404
|
53 qq_group_free_member(group);
|
14192
|
54 g_free(group->group_name_utf8);
|
|
55 g_free(group->group_desc_utf8);
|
|
56 g_free(group);
|
|
57 }
|
|
58
|
|
59 /* clean up group_packets and free all contents */
|
|
60 void qq_group_packets_free(qq_data *qd)
|
|
61 {
|
|
62 group_packet *p;
|
|
63 gint i;
|
|
64
|
|
65 i = 0;
|
|
66 while (qd->group_packets != NULL) {
|
|
67 p = (group_packet *) (qd->group_packets->data);
|
|
68 qd->group_packets = g_list_remove(qd->group_packets, p);
|
|
69 g_free(p);
|
|
70 i++;
|
|
71 }
|
|
72 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d group packets are freed!\n", i);
|
|
73 }
|
|
74
|
|
75 void qq_group_free_all(qq_data *qd)
|
|
76 {
|
|
77 qq_group *group;
|
|
78 gint i;
|
|
79 g_return_if_fail(qd != NULL);
|
|
80
|
|
81 i = 0;
|
|
82 while (qd->groups != NULL) {
|
|
83 i++;
|
|
84 group = (qq_group *) qd->groups->data;
|
|
85 qd->groups = g_list_remove(qd->groups, group);
|
14404
|
86 qq_group_free(group);
|
14192
|
87 }
|
|
88
|
|
89 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d groups are freed\n", i);
|
|
90 }
|