Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/oscar.c @ 29034:6c333c1d20b9
disapproval of revision '661db628ce40c3548058f062ea72d9687654d53a'
This is causing a ton of crashes for Adium. Clearly this needs to be done differently.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sun, 29 Nov 2009 16:16:40 +0000 |
parents | 86ff30fb8ae3 |
children | c06e1f777e42 |
comparison
equal
deleted
inserted
replaced
28878:86ff30fb8ae3 | 29034:6c333c1d20b9 |
---|---|
5223 aim_ssi_cleanlist(od); | 5223 aim_ssi_cleanlist(od); |
5224 | 5224 |
5225 { /* If not in server list then prune from local list */ | 5225 { /* If not in server list then prune from local list */ |
5226 GSList *cur, *next; | 5226 GSList *cur, *next; |
5227 GSList *buddies = purple_find_buddies(account, NULL); | 5227 GSList *buddies = purple_find_buddies(account, NULL); |
5228 | 5228 |
5229 /* Buddies */ | 5229 /* Buddies */ |
5230 cur = NULL; | 5230 cur = NULL; |
5231 | 5231 |
5232 while(buddies) { | 5232 while(buddies) { |
5233 PurpleGroup *g; | 5233 PurpleGroup *g; |
5313 | 5313 |
5314 } /* end pruning buddies from local list */ | 5314 } /* end pruning buddies from local list */ |
5315 | 5315 |
5316 /* Add from server list to local list */ | 5316 /* Add from server list to local list */ |
5317 for (curitem=od->ssi.local; curitem; curitem=curitem->next) { | 5317 for (curitem=od->ssi.local; curitem; curitem=curitem->next) { |
5318 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) | |
5318 switch (curitem->type) { | 5319 switch (curitem->type) { |
5319 case AIM_SSI_TYPE_BUDDY: { /* Buddy */ | 5320 case AIM_SSI_TYPE_BUDDY: { /* Buddy */ |
5320 if (curitem->name) { | 5321 if (curitem->name) { |
5321 struct aim_ssi_item *groupitem; | 5322 struct aim_ssi_item *groupitem; |
5322 const char *gname, *alias; | 5323 char *gname, *gname_utf8, *alias, *alias_utf8; |
5323 | 5324 |
5324 groupitem = aim_ssi_itemlist_find(od->ssi.local, curitem->gid, 0x0000); | 5325 groupitem = aim_ssi_itemlist_find(od->ssi.local, curitem->gid, 0x0000); |
5325 gname = groupitem ? groupitem->name : NULL; | 5326 gname = groupitem ? groupitem->name : NULL; |
5326 | 5327 if (gname != NULL) { |
5327 g = purple_find_group(gname ? gname : _("Orphans")); | 5328 if (g_utf8_validate(gname, -1, NULL)) |
5329 gname_utf8 = g_strdup(gname); | |
5330 else | |
5331 gname_utf8 = oscar_utf8_try_convert(account, gname); | |
5332 } else | |
5333 gname_utf8 = NULL; | |
5334 | |
5335 g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans")); | |
5328 if (g == NULL) { | 5336 if (g == NULL) { |
5329 g = purple_group_new(gname ? gname : _("Orphans")); | 5337 g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
5330 purple_blist_add_group(g, NULL); | 5338 purple_blist_add_group(g, NULL); |
5331 } | 5339 } |
5332 | 5340 |
5333 alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name); | 5341 alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name); |
5342 if (alias != NULL) { | |
5343 if (g_utf8_validate(alias, -1, NULL)) | |
5344 alias_utf8 = g_strdup(alias); | |
5345 else | |
5346 alias_utf8 = oscar_utf8_try_convert(account, alias); | |
5347 g_free(alias); | |
5348 } else | |
5349 alias_utf8 = NULL; | |
5350 | |
5334 b = purple_find_buddy_in_group(account, curitem->name, g); | 5351 b = purple_find_buddy_in_group(account, curitem->name, g); |
5335 if (b) { | 5352 if (b) { |
5336 /* Get server stored alias */ | 5353 /* Get server stored alias */ |
5337 purple_blist_alias_buddy(b, alias); | 5354 purple_blist_alias_buddy(b, alias_utf8); |
5338 } else { | 5355 } else { |
5339 b = purple_buddy_new(account, curitem->name, alias); | 5356 b = purple_buddy_new(account, curitem->name, alias_utf8); |
5340 | 5357 |
5341 purple_debug_info("oscar", | 5358 purple_debug_info("oscar", |
5342 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname); | 5359 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname); |
5343 purple_blist_add_buddy(b, NULL, g, NULL); | 5360 purple_blist_add_buddy(b, NULL, g, NULL); |
5344 } | 5361 } |
5358 OSCAR_STATUS_ID_AVAILABLE, NULL); | 5375 OSCAR_STATUS_ID_AVAILABLE, NULL); |
5359 purple_prpl_got_user_status(account, | 5376 purple_prpl_got_user_status(account, |
5360 purple_buddy_get_name(b), | 5377 purple_buddy_get_name(b), |
5361 OSCAR_STATUS_ID_MOBILE, NULL); | 5378 OSCAR_STATUS_ID_MOBILE, NULL); |
5362 } | 5379 } |
5380 | |
5381 g_free(gname_utf8); | |
5382 g_free(alias_utf8); | |
5363 } | 5383 } |
5364 } break; | 5384 } break; |
5365 | 5385 |
5366 case AIM_SSI_TYPE_GROUP: { /* Group */ | 5386 case AIM_SSI_TYPE_GROUP: { /* Group */ |
5367 const char *gname = curitem->name; | 5387 char *gname; |
5368 if (gname != NULL && purple_find_group(gname) == NULL) { | 5388 char *gname_utf8; |
5369 g = purple_group_new(gname); | 5389 |
5390 gname = curitem->name; | |
5391 if (gname != NULL) { | |
5392 if (g_utf8_validate(gname, -1, NULL)) | |
5393 gname_utf8 = g_strdup(gname); | |
5394 else | |
5395 gname_utf8 = oscar_utf8_try_convert(account, gname); | |
5396 } else | |
5397 gname_utf8 = NULL; | |
5398 | |
5399 if (gname_utf8 != NULL && purple_find_group(gname_utf8) == NULL) { | |
5400 g = purple_group_new(gname_utf8); | |
5370 purple_blist_add_group(g, NULL); | 5401 purple_blist_add_group(g, NULL); |
5371 } | 5402 } |
5403 g_free(gname_utf8); | |
5372 } break; | 5404 } break; |
5373 | 5405 |
5374 case AIM_SSI_TYPE_PERMIT: { /* Permit buddy */ | 5406 case AIM_SSI_TYPE_PERMIT: { /* Permit buddy */ |
5375 if (curitem->name) { | 5407 if (curitem->name) { |
5376 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ | 5408 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
5501 static int | 5533 static int |
5502 purple_ssi_parseaddmod(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) | 5534 purple_ssi_parseaddmod(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) |
5503 { | 5535 { |
5504 PurpleConnection *gc; | 5536 PurpleConnection *gc; |
5505 PurpleAccount *account; | 5537 PurpleAccount *account; |
5506 const char *gname; | 5538 char *gname, *gname_utf8, *alias, *alias_utf8; |
5507 char *alias; | |
5508 PurpleBuddy *b; | 5539 PurpleBuddy *b; |
5509 PurpleGroup *g; | 5540 PurpleGroup *g; |
5510 struct aim_ssi_item *ssi_item; | 5541 struct aim_ssi_item *ssi_item; |
5511 va_list ap; | 5542 va_list ap; |
5512 guint16 snac_subtype, type; | 5543 guint16 snac_subtype, type; |
5523 | 5554 |
5524 if ((type != 0x0000) || (name == NULL)) | 5555 if ((type != 0x0000) || (name == NULL)) |
5525 return 1; | 5556 return 1; |
5526 | 5557 |
5527 gname = aim_ssi_itemlist_findparentname(od->ssi.local, name); | 5558 gname = aim_ssi_itemlist_findparentname(od->ssi.local, name); |
5559 gname_utf8 = gname ? oscar_utf8_try_convert(account, gname) : NULL; | |
5560 | |
5528 alias = aim_ssi_getalias(od->ssi.local, gname, name); | 5561 alias = aim_ssi_getalias(od->ssi.local, gname, name); |
5562 if (alias != NULL) | |
5563 { | |
5564 if (g_utf8_validate(alias, -1, NULL)) | |
5565 alias_utf8 = g_strdup(alias); | |
5566 else | |
5567 alias_utf8 = oscar_utf8_try_convert(account, alias); | |
5568 } | |
5569 else | |
5570 alias_utf8 = NULL; | |
5571 g_free(alias); | |
5529 | 5572 |
5530 b = purple_find_buddy(account, name); | 5573 b = purple_find_buddy(account, name); |
5531 if (b) { | 5574 if (b) { |
5532 /* | 5575 /* |
5533 * You're logged in somewhere else and you aliased one | 5576 * You're logged in somewhere else and you aliased one |
5534 * of your buddies, so update our local buddy list with | 5577 * of your buddies, so update our local buddy list with |
5535 * the person's new alias. | 5578 * the person's new alias. |
5536 */ | 5579 */ |
5537 purple_blist_alias_buddy(b, alias); | 5580 purple_blist_alias_buddy(b, alias_utf8); |
5538 } else if (snac_subtype == 0x0008) { | 5581 } else if (snac_subtype == 0x0008) { |
5539 /* | 5582 /* |
5540 * You're logged in somewhere else and you added a buddy to | 5583 * You're logged in somewhere else and you added a buddy to |
5541 * your server list, so add them to your local buddy list. | 5584 * your server list, so add them to your local buddy list. |
5542 */ | 5585 */ |
5543 b = purple_buddy_new(account, name, alias); | 5586 b = purple_buddy_new(account, name, alias_utf8); |
5544 | 5587 |
5545 if (!(g = purple_find_group(gname ? gname : _("Orphans")))) { | 5588 if (!(g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
5546 g = purple_group_new(gname ? gname : _("Orphans")); | 5589 g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
5547 purple_blist_add_group(g, NULL); | 5590 purple_blist_add_group(g, NULL); |
5548 } | 5591 } |
5549 | 5592 |
5550 purple_debug_info("oscar", | 5593 purple_debug_info("oscar", |
5551 "ssi: adding buddy %s to group %s to local list\n", name, gname ? gname : _("Orphans")); | 5594 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
5552 purple_blist_add_buddy(b, NULL, g, NULL); | 5595 purple_blist_add_buddy(b, NULL, g, NULL); |
5553 | 5596 |
5554 /* Mobile users should always be online */ | 5597 /* Mobile users should always be online */ |
5555 if (name[0] == '+') { | 5598 if (name[0] == '+') { |
5556 purple_prpl_got_user_status(account, | 5599 purple_prpl_got_user_status(account, |
5559 name, OSCAR_STATUS_ID_MOBILE, NULL); | 5602 name, OSCAR_STATUS_ID_MOBILE, NULL); |
5560 } | 5603 } |
5561 | 5604 |
5562 } | 5605 } |
5563 | 5606 |
5564 g_free(alias); | |
5565 | |
5566 ssi_item = aim_ssi_itemlist_finditem(od->ssi.local, | 5607 ssi_item = aim_ssi_itemlist_finditem(od->ssi.local, |
5567 gname, name, AIM_SSI_TYPE_BUDDY); | 5608 gname, name, AIM_SSI_TYPE_BUDDY); |
5568 if (ssi_item == NULL) | 5609 if (ssi_item == NULL) |
5569 { | 5610 { |
5570 purple_debug_error("oscar", "purple_ssi_parseaddmod: " | 5611 purple_debug_error("oscar", "purple_ssi_parseaddmod: " |
5571 "Could not find ssi item for oncoming buddy %s, " | 5612 "Could not find ssi item for oncoming buddy %s, " |
5572 "group %s\n", name, gname); | 5613 "group %s\n", name, gname); |
5573 } | 5614 } |
5615 | |
5616 g_free(gname_utf8); | |
5617 g_free(alias_utf8); | |
5574 | 5618 |
5575 return 1; | 5619 return 1; |
5576 } | 5620 } |
5577 | 5621 |
5578 static int purple_ssi_authgiven(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { | 5622 static int purple_ssi_authgiven(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { |
6272 PurpleConnection *gc; | 6316 PurpleConnection *gc; |
6273 OscarData *od; | 6317 OscarData *od; |
6274 struct name_data *data; | 6318 struct name_data *data; |
6275 PurpleGroup *g; | 6319 PurpleGroup *g; |
6276 char *comment; | 6320 char *comment; |
6321 gchar *comment_utf8; | |
6277 gchar *title; | 6322 gchar *title; |
6278 PurpleAccount *account; | 6323 PurpleAccount *account; |
6279 const char *name; | 6324 const char *name; |
6280 | 6325 |
6281 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); | 6326 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
6290 return; | 6335 return; |
6291 | 6336 |
6292 data = g_new(struct name_data, 1); | 6337 data = g_new(struct name_data, 1); |
6293 | 6338 |
6294 comment = aim_ssi_getcomment(od->ssi.local, purple_group_get_name(g), name); | 6339 comment = aim_ssi_getcomment(od->ssi.local, purple_group_get_name(g), name); |
6340 comment_utf8 = comment ? oscar_utf8_try_convert(account, comment) : NULL; | |
6295 | 6341 |
6296 data->gc = gc; | 6342 data->gc = gc; |
6297 data->name = g_strdup(name); | 6343 data->name = g_strdup(name); |
6298 data->nick = g_strdup(purple_buddy_get_alias_only(buddy)); | 6344 data->nick = g_strdup(purple_buddy_get_alias_only(buddy)); |
6299 | 6345 |
6300 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); | 6346 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6301 purple_request_input(gc, title, _("Buddy Comment:"), NULL, | 6347 purple_request_input(gc, title, _("Buddy Comment:"), NULL, |
6302 comment, TRUE, FALSE, NULL, | 6348 comment_utf8, TRUE, FALSE, NULL, |
6303 _("_OK"), G_CALLBACK(oscar_ssi_editcomment), | 6349 _("_OK"), G_CALLBACK(oscar_ssi_editcomment), |
6304 _("_Cancel"), G_CALLBACK(oscar_free_name_data), | 6350 _("_Cancel"), G_CALLBACK(oscar_free_name_data), |
6305 account, data->name, NULL, | 6351 account, data->name, NULL, |
6306 data); | 6352 data); |
6307 g_free(title); | 6353 g_free(title); |
6308 | 6354 |
6309 g_free(comment); | 6355 g_free(comment); |
6356 g_free(comment_utf8); | |
6310 } | 6357 } |
6311 | 6358 |
6312 static void | 6359 static void |
6313 oscar_ask_directim_yes_cb(struct oscar_ask_directim_data *data) | 6360 oscar_ask_directim_yes_cb(struct oscar_ask_directim_data *data) |
6314 { | 6361 { |