comparison libpurple/prpl.c @ 15593:f485c87e6546

sf patch #1655057, from Peter Tang Fix a memory leak when signing off an account, I think. Peter Tang found it and suggested one fix. I suggested another, then Sadrul made it work. I like this change. We're now re-using GaimStatusType objects instead of making lots of copies of them.
author Mark Doliner <mark@kingant.net>
date Fri, 09 Feb 2007 07:42:01 +0000
parents 84b3ab83df35
children 32c366eeeb99
comparison
equal deleted inserted replaced
15592:0a5823d45398 15593:f485c87e6546
163 } 163 }
164 164
165 void gaim_prpl_got_user_status_deactive(GaimAccount *account, const char *name, 165 void gaim_prpl_got_user_status_deactive(GaimAccount *account, const char *name,
166 const char *status_id) 166 const char *status_id)
167 { 167 {
168 GSList *list; 168 GaimBuddy *buddy;
169 GaimBuddy *buddy; 169 GaimPresence *presence;
170 GaimPresence *presence; 170 GaimStatus *status;
171 GaimStatus *status;
172 GaimStatus *old_status;
173 va_list args;
174 171
175 g_return_if_fail(account != NULL); 172 g_return_if_fail(account != NULL);
176 g_return_if_fail(name != NULL); 173 g_return_if_fail(name != NULL);
177 g_return_if_fail(status_id != NULL); 174 g_return_if_fail(status_id != NULL);
178 g_return_if_fail(gaim_account_is_connected(account) || gaim_account_is_connecting(account)); 175 g_return_if_fail(gaim_account_is_connected(account) || gaim_account_is_connecting(account));
244 } 241 }
245 242
246 GList * 243 GList *
247 gaim_prpl_get_statuses(GaimAccount *account, GaimPresence *presence) 244 gaim_prpl_get_statuses(GaimAccount *account, GaimPresence *presence)
248 { 245 {
249 GaimPlugin *prpl;
250 GaimPluginProtocolInfo *prpl_info;
251 GList *statuses = NULL; 246 GList *statuses = NULL;
252 GList *l, *list; 247 const GList *l;
253 GaimStatus *status; 248 GaimStatus *status;
254 249
255 g_return_val_if_fail(account != NULL, NULL); 250 g_return_val_if_fail(account != NULL, NULL);
256 g_return_val_if_fail(presence != NULL, NULL); 251 g_return_val_if_fail(presence != NULL, NULL);
257 252
258 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); 253 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next)
259
260 if (prpl == NULL)
261 return NULL;
262
263 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
264 if (prpl_info == NULL || prpl_info->status_types == NULL)
265 return NULL;
266
267 for (l = list = prpl_info->status_types(account); l != NULL; l = l->next)
268 { 254 {
269 status = gaim_status_new((GaimStatusType *)l->data, presence); 255 status = gaim_status_new((GaimStatusType *)l->data, presence);
270 statuses = g_list_append(statuses, status); 256 statuses = g_list_prepend(statuses, status);
271 } 257 }
272 258
273 g_list_free(list); 259 statuses = g_list_reverse(statuses);
274 260
275 return statuses; 261 return statuses;
276 } 262 }
277 263
278 264