comparison src/protocols/qq/group_free.c @ 13870:983fd420e86b

[gaim-migrate @ 16340] Performed minor cleanup of the OpenQ codebase and patched it into the Gaim trunk as a prpl, providing basic QQ functionality. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Mon, 26 Jun 2006 02:58:54 +0000
parents
children ef8490f9e823
comparison
equal deleted inserted replaced
13869:5642f4658b59 13870:983fd420e86b
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 // START OF FILE
24 /*****************************************************************************/
25 #include "debug.h" // gaim_debug
26
27 #include "buddy_status.h" // QQ_BUDDY_ONLINE_OFFLINE
28 #include "group_free.h"
29 #include "group_network.h" // group_packet
30 #include "group.h" // qq_group
31
32 /*****************************************************************************/
33 // gracefully free all members in a group
34 static void _qq_group_free_member(qq_group * group)
35 {
36 gint i;
37 GList *list;
38 qq_buddy *member;
39
40 g_return_if_fail(group != NULL);
41 i = 0;
42 while (NULL != (list = group->members)) {
43 member = (qq_buddy *) list->data;
44 i++;
45 group->members = g_list_remove(group->members, member);
46 g_free(member->nickname);
47 g_free(member);
48 } // while
49
50 group->members = NULL;
51
52 } // _qq_group_free_member
53
54 /*****************************************************************************/
55 // gracefully free the memory for one qq_group
56 static void _qq_group_free(qq_group * group)
57 {
58 g_return_if_fail(group != NULL);
59 _qq_group_free_member(group);
60 g_free(group->group_name_utf8);
61 g_free(group->group_desc_utf8);
62 g_free(group);
63 } // _qq_group_free
64
65 /*****************************************************************************/
66 // clean up group_packets and free all contents
67 void qq_group_packets_free(qq_data * qd)
68 {
69 group_packet *p;
70 gint i;
71
72 i = 0;
73 while (qd->group_packets != NULL) {
74 p = (group_packet *) (qd->group_packets->data);
75 qd->group_packets = g_list_remove(qd->group_packets, p);
76 g_free(p);
77 i++;
78 } // while
79 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d group packets are freed!\n", i);
80 } // qq_group_packets_free
81
82 /*****************************************************************************/
83 void qq_group_remove_by_internal_group_id(qq_data * qd, guint32 internal_group_id) {
84 qq_group *group;
85 GList *list;
86 g_return_if_fail(qd != NULL);
87
88 list = qd->groups;
89 while (list != NULL) {
90 group = (qq_group *) qd->groups->data;
91 if (internal_group_id == group->internal_group_id) {
92 qd->groups = g_list_remove(qd->groups, group);
93 _qq_group_free(group);
94 break;
95 } else
96 list = list->next;
97 } // while
98
99 } // qq_group_free_all
100
101 /*****************************************************************************/
102 void qq_group_free_all(qq_data * qd)
103 {
104 qq_group *group;
105 gint i;
106 g_return_if_fail(qd != NULL);
107
108 i = 0;
109 while (qd->groups != NULL) {
110 i++;
111 group = (qq_group *) qd->groups->data;
112 qd->groups = g_list_remove(qd->groups, group);
113 _qq_group_free(group);
114 } // while
115
116 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d groups are freed\n", i);
117 } // qq_group_free_all
118
119 /*****************************************************************************/
120 // END OF FILE