Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/yahoo_aliases.c @ 27615:b909c4a7bfc8
Allow changing contact details for folks in the buddylist.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 15 Jul 2009 03:17:54 +0000 |
parents | fa827f6f990f |
children | a9187ae91656 |
comparison
equal
deleted
inserted
replaced
27614:fa827f6f990f | 27615:b909c4a7bfc8 |
---|---|
465 | 465 |
466 xmlnode_set_attrib(node, "k", purple_connection_get_display_name(gc)); | 466 xmlnode_set_attrib(node, "k", purple_connection_get_display_name(gc)); |
467 xmlnode_set_attrib(node, "cc", "1"); /* XXX: ? */ | 467 xmlnode_set_attrib(node, "cc", "1"); /* XXX: ? */ |
468 | 468 |
469 xmlnode_set_attrib(ct, "e", "1"); | 469 xmlnode_set_attrib(ct, "e", "1"); |
470 xmlnode_set_attrib(ct, "yi", purple_connection_get_display_name(gc)); | 470 xmlnode_set_attrib(ct, "yi", purple_request_fields_get_string(fields, "yname")); |
471 xmlnode_set_attrib(ct, "id", yd->ypd.id); | 471 xmlnode_set_attrib(ct, "id", purple_request_fields_get_string(fields, "yid")); |
472 xmlnode_set_attrib(ct, "pr", "0"); | 472 xmlnode_set_attrib(ct, "pr", "0"); |
473 | 473 |
474 for (i = 0; yfields[i]; i++) { | 474 for (i = 0; yfields[i]; i++) { |
475 const char *v = purple_request_fields_get_string(fields, yfields[i]); | 475 const char *v = purple_request_fields_get_string(fields, yfields[i]); |
476 xmlnode_set_attrib(ct, yfields[i], v ? v : ""); | 476 xmlnode_set_attrib(ct, yfields[i], v ? v : ""); |
527 g_free(webpage); | 527 g_free(webpage); |
528 g_free(content); | 528 g_free(content); |
529 g_free(request); | 529 g_free(request); |
530 } | 530 } |
531 | 531 |
532 void yahoo_set_userinfo(PurpleConnection *gc) | 532 static PurpleRequestFields * |
533 request_fields_from_personal_details(YahooPersonalDetails *ypd, const char *id) | |
533 { | 534 { |
534 PurpleRequestFields *fields; | 535 PurpleRequestFields *fields; |
535 PurpleRequestFieldGroup *group; | 536 PurpleRequestFieldGroup *group; |
536 PurpleRequestField *field; | 537 PurpleRequestField *field; |
537 struct yahoo_data *yd = purple_connection_get_protocol_data(gc); | |
538 int i; | 538 int i; |
539 struct { | 539 struct { |
540 char *id; | 540 char *id; |
541 char *text; | 541 char *text; |
542 char *value; | 542 char *value; |
543 } yfields[] = { | 543 } yfields[] = { |
544 {"fn", N_("First Name"), yd->ypd.names.first}, | 544 {"fn", N_("First Name"), ypd->names.first}, |
545 {"ln", N_("Last Name"), yd->ypd.names.last}, | 545 {"ln", N_("Last Name"), ypd->names.last}, |
546 {"nn", N_("Nickname"), yd->ypd.names.nick}, | 546 {"nn", N_("Nickname"), ypd->names.nick}, |
547 {"mn", N_("Middle Name"), yd->ypd.names.middle}, | 547 {"mn", N_("Middle Name"), ypd->names.middle}, |
548 {"hp", N_("Home Phone Number"), yd->ypd.phone.home}, | 548 {"hp", N_("Home Phone Number"), ypd->phone.home}, |
549 {"wp", N_("Work Phone Number"), yd->ypd.phone.work}, | 549 {"wp", N_("Work Phone Number"), ypd->phone.work}, |
550 {"mo", N_("Mobile Phone Number"), yd->ypd.phone.mobile}, | 550 {"mo", N_("Mobile Phone Number"), ypd->phone.mobile}, |
551 {NULL, NULL, NULL} | 551 {NULL, NULL, NULL} |
552 }; | 552 }; |
553 | 553 |
554 fields = purple_request_fields_new(); | 554 fields = purple_request_fields_new(); |
555 group = purple_request_field_group_new(NULL); | 555 group = purple_request_field_group_new(NULL); |
556 purple_request_fields_add_group(fields, group); | 556 purple_request_fields_add_group(fields, group); |
557 | |
558 field = purple_request_field_string_new("yname", "", id, FALSE); | |
559 purple_request_field_set_visible(field, FALSE); | |
560 purple_request_field_group_add_field(group, field); | |
561 | |
562 field = purple_request_field_string_new("yid", "", ypd->id, FALSE); | |
563 purple_request_field_set_visible(field, FALSE); | |
564 purple_request_field_group_add_field(group, field); | |
557 | 565 |
558 for (i = 0; yfields[i].id; i++) { | 566 for (i = 0; yfields[i].id; i++) { |
559 field = purple_request_field_string_new(yfields[i].id, _(yfields[i].text), | 567 field = purple_request_field_string_new(yfields[i].id, _(yfields[i].text), |
560 yfields[i].value, FALSE); | 568 yfields[i].value, FALSE); |
561 purple_request_field_group_add_field(group, field); | 569 purple_request_field_group_add_field(group, field); |
562 } | 570 } |
563 | 571 |
572 return fields; | |
573 } | |
574 | |
575 void yahoo_set_userinfo_for_buddy(PurpleConnection *gc, PurpleBuddy *buddy) | |
576 { | |
577 PurpleRequestFields *fields; | |
578 YahooFriend *f; | |
579 const char *name; | |
580 | |
581 name = purple_buddy_get_name(buddy); | |
582 f = yahoo_friend_find(gc, name); | |
583 if (!f) | |
584 return; | |
585 | |
586 fields = request_fields_from_personal_details(&f->ypd, name); | |
587 purple_request_fields(gc, NULL, _("Set User Info"), NULL, fields, | |
588 _("OK"), G_CALLBACK(yahoo_set_userinfo_cb), | |
589 _("Cancel"), NULL, | |
590 purple_connection_get_account(gc), NULL, NULL, gc); | |
591 } | |
592 | |
593 void yahoo_set_userinfo(PurpleConnection *gc) | |
594 { | |
595 struct yahoo_data *yd = purple_connection_get_protocol_data(gc); | |
596 PurpleRequestFields *fields = request_fields_from_personal_details(&yd->ypd, | |
597 purple_connection_get_display_name(gc)); | |
564 purple_request_fields(gc, NULL, _("Set User Info"), NULL, fields, | 598 purple_request_fields(gc, NULL, _("Set User Info"), NULL, fields, |
565 _("OK"), G_CALLBACK(yahoo_set_userinfo_cb), | 599 _("OK"), G_CALLBACK(yahoo_set_userinfo_cb), |
566 _("Cancel"), NULL, | 600 _("Cancel"), NULL, |
567 purple_connection_get_account(gc), NULL, NULL, gc); | 601 purple_connection_get_account(gc), NULL, NULL, gc); |
568 } | 602 } |