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.h"
|
|
27 #include "group_free.h"
|
|
28 #include "group_network.h"
|
|
29
|
|
30 /* gracefully free all members in a group */
|
|
31 static void _qq_group_free_member(qq_group *group)
|
|
32 {
|
|
33 gint i;
|
|
34 GList *list;
|
|
35 qq_buddy *member;
|
|
36
|
|
37 g_return_if_fail(group != NULL);
|
|
38 i = 0;
|
|
39 while (NULL != (list = group->members)) {
|
|
40 member = (qq_buddy *) list->data;
|
|
41 i++;
|
|
42 group->members = g_list_remove(group->members, member);
|
|
43 g_free(member->nickname);
|
|
44 g_free(member);
|
|
45 }
|
|
46
|
|
47 group->members = NULL;
|
|
48 }
|
|
49
|
|
50 /* gracefully free the memory for one qq_group */
|
|
51 static void _qq_group_free(qq_group *group)
|
|
52 {
|
|
53 g_return_if_fail(group != NULL);
|
|
54 _qq_group_free_member(group);
|
|
55 g_free(group->group_name_utf8);
|
|
56 g_free(group->group_desc_utf8);
|
|
57 g_free(group);
|
|
58 }
|
|
59
|
|
60 /* clean up group_packets and free all contents */
|
|
61 void qq_group_packets_free(qq_data *qd)
|
|
62 {
|
|
63 group_packet *p;
|
|
64 gint i;
|
|
65
|
|
66 i = 0;
|
|
67 while (qd->group_packets != NULL) {
|
|
68 p = (group_packet *) (qd->group_packets->data);
|
|
69 qd->group_packets = g_list_remove(qd->group_packets, p);
|
|
70 g_free(p);
|
|
71 i++;
|
|
72 }
|
|
73 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d group packets are freed!\n", i);
|
|
74 }
|
|
75
|
|
76 void qq_group_remove_by_internal_group_id(qq_data *qd, guint32 internal_group_id)
|
|
77 {
|
|
78 qq_group *group;
|
|
79 GList *list;
|
|
80 g_return_if_fail(qd != NULL);
|
|
81
|
|
82 list = qd->groups;
|
|
83 while (list != NULL) {
|
|
84 group = (qq_group *) qd->groups->data;
|
|
85 if (internal_group_id == group->internal_group_id) {
|
|
86 qd->groups = g_list_remove(qd->groups, group);
|
|
87 _qq_group_free(group);
|
|
88 break;
|
|
89 } else {
|
|
90 list = list->next;
|
|
91 }
|
|
92 }
|
|
93 }
|
|
94
|
|
95 void qq_group_free_all(qq_data *qd)
|
|
96 {
|
|
97 qq_group *group;
|
|
98 gint i;
|
|
99 g_return_if_fail(qd != NULL);
|
|
100
|
|
101 i = 0;
|
|
102 while (qd->groups != NULL) {
|
|
103 i++;
|
|
104 group = (qq_group *) qd->groups->data;
|
|
105 qd->groups = g_list_remove(qd->groups, group);
|
|
106 _qq_group_free(group);
|
|
107 }
|
|
108
|
|
109 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d groups are freed\n", i);
|
|
110 }
|