comparison src/account.c @ 6366:773b8ce563f5

[gaim-migrate @ 6871] The patch to remove buddies when deleting an account needs to be re-thought. The code was put in the gaim_account_destroy() function, which is being called at shutdown, or if it's not, it's supposed to be... I don't want to lose my whole buddy list. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 04 Aug 2003 19:29:06 +0000
parents 72bbe310ac77
children 9fd154ca6a94
comparison
equal deleted inserted replaced
6365:72bbe310ac77 6366:773b8ce563f5
145 } 145 }
146 146
147 void 147 void
148 gaim_account_destroy(GaimAccount *account) 148 gaim_account_destroy(GaimAccount *account)
149 { 149 {
150 GaimBlistNode *gnode, *bnode;
151
152 g_return_if_fail(account != NULL); 150 g_return_if_fail(account != NULL);
153 151
154 gaim_debug(GAIM_DEBUG_INFO, "account", 152 gaim_debug(GAIM_DEBUG_INFO, "account",
155 "Destroying account %p\n", account); 153 "Destroying account %p\n", account);
156 154
157 if (account->gc != NULL) 155 if (account->gc != NULL)
158 gaim_connection_destroy(account->gc); 156 gaim_connection_destroy(account->gc);
159 157
160 gaim_debug(GAIM_DEBUG_INFO, "account", 158 gaim_debug(GAIM_DEBUG_INFO, "account",
161 "Continuing to destroy account %p\n", account); 159 "Continuing to destroy account %p\n", account);
162
163 /* Let's remove the buddies for this account, before they cause trouble */
164 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
165 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
166 continue;
167 for(bnode = gnode->child; bnode; bnode=bnode->next) {
168 if(GAIM_BLIST_NODE_IS_BUDDY(bnode)) {
169 struct buddy *b = (struct buddy *)bnode;
170 if(b->account == account)
171 gaim_blist_remove_buddy(b);
172 } else if(GAIM_BLIST_NODE_IS_CHAT(bnode)) {
173 struct chat *c = (struct chat *)bnode;
174 if(c->account == account)
175 gaim_blist_remove_chat(c);
176 }
177 }
178 }
179
180 gaim_blist_save();
181 160
182 if (account->username != NULL) g_free(account->username); 161 if (account->username != NULL) g_free(account->username);
183 if (account->alias != NULL) g_free(account->alias); 162 if (account->alias != NULL) g_free(account->alias);
184 if (account->password != NULL) g_free(account->password); 163 if (account->password != NULL) g_free(account->password);
185 if (account->user_info != NULL) g_free(account->user_info); 164 if (account->user_info != NULL) g_free(account->user_info);