Mercurial > pidgin
comparison libpurple/protocols/myspace/user.c @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
| author | Elliott Sales de Andrade <qulogic@pidgin.im> |
|---|---|
| date | Sat, 02 Jun 2012 02:30:49 +0000 |
| parents | 904686722499 |
| children |
comparison
equal
deleted
inserted
replaced
| 32818:01ff09d4a463 | 32819:2c6510167895 |
|---|---|
| 115 guint cv; | 115 guint cv; |
| 116 | 116 |
| 117 /* Useful to identify the account the tooltip refers to. | 117 /* Useful to identify the account the tooltip refers to. |
| 118 * Other prpls show this. */ | 118 * Other prpls show this. */ |
| 119 if (user->username) { | 119 if (user->username) { |
| 120 purple_notify_user_info_add_pair(user_info, _("User"), user->username); | 120 purple_notify_user_info_add_pair_plaintext(user_info, _("User"), user->username); |
| 121 } | 121 } |
| 122 | 122 |
| 123 /* a/s/l...the vitals */ | 123 /* a/s/l...the vitals */ |
| 124 if (user->age) { | 124 if (user->age) { |
| 125 char age[16]; | 125 char age[16]; |
| 126 g_snprintf(age, sizeof(age), "%d", user->age); | 126 g_snprintf(age, sizeof(age), "%d", user->age); |
| 127 purple_notify_user_info_add_pair(user_info, _("Age"), age); | 127 purple_notify_user_info_add_pair_plaintext(user_info, _("Age"), age); |
| 128 } | 128 } |
| 129 | 129 |
| 130 if (user->gender && *user->gender) { | 130 if (user->gender && *user->gender) { |
| 131 purple_notify_user_info_add_pair(user_info, _("Gender"), user->gender); | 131 /* TODO: Check whether it's correct to call add_pair_html, |
| 132 or if we should be using add_pair_plaintext */ | |
| 133 purple_notify_user_info_add_pair_plaintext(user_info, _("Gender"), user->gender); | |
| 132 } | 134 } |
| 133 | 135 |
| 134 if (user->location && *user->location) { | 136 if (user->location && *user->location) { |
| 135 purple_notify_user_info_add_pair(user_info, _("Location"), user->location); | 137 /* TODO: Check whether it's correct to call add_pair_html, |
| 138 or if we should be using add_pair_plaintext */ | |
| 139 purple_notify_user_info_add_pair_plaintext(user_info, _("Location"), user->location); | |
| 136 } | 140 } |
| 137 | 141 |
| 138 /* Other information */ | 142 /* Other information */ |
| 139 if (user->headline && *user->headline) { | 143 if (user->headline && *user->headline) { |
| 140 purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline); | 144 /* TODO: Check whether it's correct to call add_pair_html, |
| 145 or if we should be using add_pair_plaintext */ | |
| 146 purple_notify_user_info_add_pair_plaintext(user_info, _("Headline"), user->headline); | |
| 141 } | 147 } |
| 142 | 148 |
| 143 if (user->buddy != NULL) { | 149 if (user->buddy != NULL) { |
| 144 presence = purple_buddy_get_presence(user->buddy); | 150 presence = purple_buddy_get_presence(user->buddy); |
| 145 | 151 |
| 151 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); | 157 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); |
| 152 artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); | 158 artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); |
| 153 | 159 |
| 154 str = msim_format_now_playing(artist, title); | 160 str = msim_format_now_playing(artist, title); |
| 155 if (str && *str) { | 161 if (str && *str) { |
| 156 purple_notify_user_info_add_pair(user_info, _("Song"), str); | 162 /* TODO: Check whether it's correct to call add_pair_html, |
| 163 or if we should be using add_pair_plaintext */ | |
| 164 purple_notify_user_info_add_pair_plaintext(user_info, _("Song"), str); | |
| 157 } | 165 } |
| 158 g_free(str); | 166 g_free(str); |
| 159 } | 167 } |
| 160 } | 168 } |
| 161 | 169 |
| 162 /* Note: total friends only available if looked up by uid, not username. */ | 170 /* Note: total friends only available if looked up by uid, not username. */ |
| 163 if (user->total_friends) { | 171 if (user->total_friends) { |
| 164 char friends[16]; | 172 char friends[16]; |
| 165 g_snprintf(friends, sizeof(friends), "%d", user->total_friends); | 173 g_snprintf(friends, sizeof(friends), "%d", user->total_friends); |
| 166 purple_notify_user_info_add_pair(user_info, _("Total Friends"), friends); | 174 purple_notify_user_info_add_pair_plaintext(user_info, _("Total Friends"), friends); |
| 167 } | 175 } |
| 168 | 176 |
| 169 if (full) { | 177 if (full) { |
| 170 /* Client information */ | 178 /* Client information */ |
| 171 char *client = NULL; | 179 char *client = NULL; |
| 178 } else if (str) { | 186 } else if (str) { |
| 179 client = g_strdup(str); | 187 client = g_strdup(str); |
| 180 } else if (cv) { | 188 } else if (cv) { |
| 181 client = g_strdup_printf("Build %d", cv); | 189 client = g_strdup_printf("Build %d", cv); |
| 182 } | 190 } |
| 183 if (client && *client) | 191 if (client && *client) { |
| 184 purple_notify_user_info_add_pair(user_info, _("Client Version"), client); | 192 /* TODO: Check whether it's correct to call add_pair_html, |
| 193 or if we should be using add_pair_plaintext */ | |
| 194 purple_notify_user_info_add_pair_plaintext(user_info, _("Client Version"), client); | |
| 195 } | |
| 185 g_free(client); | 196 g_free(client); |
| 186 } | 197 } |
| 187 | 198 |
| 188 if (full && user->id) { | 199 if (full && user->id) { |
| 189 /* TODO: link to username, if available */ | 200 /* TODO: link to username, if available */ |
| 193 profile = g_strdup_printf("<a href=\"http://myspace.com/%s\">%s</a>", | 204 profile = g_strdup_printf("<a href=\"http://myspace.com/%s\">%s</a>", |
| 194 purple_buddy_get_name(user->buddy), _("View web profile")); | 205 purple_buddy_get_name(user->buddy), _("View web profile")); |
| 195 else | 206 else |
| 196 profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">%s</a>", | 207 profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">%s</a>", |
| 197 user->id, _("View web profile")); | 208 user->id, _("View web profile")); |
| 198 purple_notify_user_info_add_pair(user_info, NULL, profile); | 209 purple_notify_user_info_add_pair_html(user_info, NULL, profile); |
| 199 g_free(profile); | 210 g_free(profile); |
| 200 } | 211 } |
| 201 } | 212 } |
| 202 | 213 |
| 203 /** | 214 /** |
| 371 | 382 |
| 372 /* Only download if URL changed */ | 383 /* Only download if URL changed */ |
| 373 if (!previous_url || !g_str_equal(previous_url, user->image_url)) { | 384 if (!previous_url || !g_str_equal(previous_url, user->image_url)) { |
| 374 if (user->url_data != NULL) | 385 if (user->url_data != NULL) |
| 375 purple_util_fetch_url_cancel(user->url_data); | 386 purple_util_fetch_url_cancel(user->url_data); |
| 376 user->url_data = purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)user); | 387 user->url_data = purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, -1, msim_downloaded_buddy_icon, (gpointer)user); |
| 377 } | 388 } |
| 378 } else if (g_str_equal(key_str, "LastImageUpdated")) { | 389 } else if (g_str_equal(key_str, "LastImageUpdated")) { |
| 379 /* TODO: use somewhere */ | 390 /* TODO: use somewhere */ |
| 380 user->last_image_updated = atol(value_str); | 391 user->last_image_updated = atol(value_str); |
| 381 g_free(value_str); | 392 g_free(value_str); |
| 399 /** | 410 /** |
| 400 * Save buddy information to the buddy list from a user info reply message. | 411 * Save buddy information to the buddy list from a user info reply message. |
| 401 * | 412 * |
| 402 * @param session | 413 * @param session |
| 403 * @param msg The user information reply, with any amount of information. | 414 * @param msg The user information reply, with any amount of information. |
| 404 * @param user The structure to save to, or NULL to save in PurpleBuddy->proto_data. | 415 * @param user The structure to save to, or NULL to save in PurpleBuddy's protocol_data. |
| 405 * | 416 * |
| 406 * Variable information is saved to the passed MsimUser structure. Permanent | 417 * Variable information is saved to the passed MsimUser structure. Permanent |
| 407 * information (UserID) is stored in the blist node of the buddy list (and | 418 * information (UserID) is stored in the blist node of the buddy list (and |
| 408 * ends up in blist.xml, persisted to disk) if it exists. | 419 * ends up in blist.xml, persisted to disk) if it exists. |
| 409 * | 420 * |
| 634 "fuseaction=profile.username to set your username."); | 645 "fuseaction=profile.username to set your username."); |
| 635 | 646 |
| 636 if (!body) { | 647 if (!body) { |
| 637 purple_debug_info("msim_username_is_set_cb", "No body"); | 648 purple_debug_info("msim_username_is_set_cb", "No body"); |
| 638 /* Error: No body! */ | 649 /* Error: No body! */ |
| 639 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); | 650 purple_connection_error(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); |
| 640 } | 651 } |
| 641 username = msim_msg_get_string(body, "UserName"); | 652 username = msim_msg_get_string(body, "UserName"); |
| 642 code = msim_msg_get_integer(body,"Code"); | 653 code = msim_msg_get_integer(body,"Code"); |
| 643 | 654 |
| 644 msim_msg_free(body); | 655 msim_msg_free(body); |
| 676 "rid", MSIM_TYPE_INTEGER, rid, | 687 "rid", MSIM_TYPE_INTEGER, rid, |
| 677 "body", MSIM_TYPE_DICTIONARY, body, | 688 "body", MSIM_TYPE_DICTIONARY, body, |
| 678 NULL)) { | 689 NULL)) { |
| 679 /* Error! */ | 690 /* Error! */ |
| 680 /* Can't set... Disconnect */ | 691 /* Can't set... Disconnect */ |
| 681 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); | 692 purple_connection_error(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); |
| 682 } | 693 } |
| 683 | 694 |
| 684 } else { | 695 } else { |
| 685 /* Error! */ | 696 /* Error! */ |
| 686 purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination"); | 697 purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination"); |
| 687 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); | 698 purple_connection_error(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg); |
| 688 } | 699 } |
| 689 } | 700 } |
| 690 | 701 |
| 691 /** | 702 /** |
| 692 * Asynchronously set new username, calling callback when receive result. | 703 * Asynchronously set new username, calling callback when receive result. |
| 745 MsimMessage *user_msg; | 756 MsimMessage *user_msg; |
| 746 MsimSession *session; | 757 MsimSession *session; |
| 747 | 758 |
| 748 g_return_if_fail(gc != NULL); | 759 g_return_if_fail(gc != NULL); |
| 749 | 760 |
| 750 session = (MsimSession *)gc->proto_data; | 761 session = purple_connection_get_protocol_data(gc); |
| 751 | 762 |
| 752 user_msg = msim_msg_new( | 763 user_msg = msim_msg_new( |
| 753 "user", MSIM_TYPE_STRING, g_strdup(msim_username_to_set), | 764 "user", MSIM_TYPE_STRING, g_strdup(msim_username_to_set), |
| 754 NULL); | 765 NULL); |
| 755 | 766 |
| 780 username = msim_msg_get_string(msg, "user"); | 791 username = msim_msg_get_string(msg, "user"); |
| 781 body = msim_msg_get_dictionary(userinfo, "body"); | 792 body = msim_msg_get_dictionary(userinfo, "body"); |
| 782 | 793 |
| 783 if (!body) { | 794 if (!body) { |
| 784 purple_debug_info("msim_username_is_available_cb", "No body for %s?!\n", username); | 795 purple_debug_info("msim_username_is_available_cb", "No body for %s?!\n", username); |
| 785 purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, | 796 purple_connection_error(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
| 786 _("An error occurred while trying to set the username. " | 797 _("An error occurred while trying to set the username. " |
| 787 "Please try again, or visit http://editprofile.myspace.com/index.cfm?" | 798 "Please try again, or visit http://editprofile.myspace.com/index.cfm?" |
| 788 "fuseaction=profile.username to set your username.")); | 799 "fuseaction=profile.username to set your username.")); |
| 789 return; | 800 return; |
| 790 } | 801 } |
| 838 MsimMessage *user_msg; | 849 MsimMessage *user_msg; |
| 839 MsimSession *session; | 850 MsimSession *session; |
| 840 | 851 |
| 841 g_return_if_fail(gc != NULL); | 852 g_return_if_fail(gc != NULL); |
| 842 | 853 |
| 843 session = (MsimSession *)gc->proto_data; | 854 session = purple_connection_get_protocol_data(gc); |
| 844 | 855 |
| 845 purple_debug_info("msim_check_username_availability_cb", "Checking username: %s\n", username_to_check); | 856 purple_debug_info("msim_check_username_availability_cb", "Checking username: %s\n", username_to_check); |
| 846 | 857 |
| 847 user_msg = msim_msg_new( | 858 user_msg = msim_msg_new( |
| 848 "user", MSIM_TYPE_STRING, g_strdup(username_to_check), | 859 "user", MSIM_TYPE_STRING, g_strdup(username_to_check), |
| 865 void msim_do_not_set_username_cb(PurpleConnection *gc) | 876 void msim_do_not_set_username_cb(PurpleConnection *gc) |
| 866 { | 877 { |
| 867 purple_debug_info("msim", "Don't set username"); | 878 purple_debug_info("msim", "Don't set username"); |
| 868 | 879 |
| 869 /* Protocol won't log in now without a username set.. Disconnect */ | 880 /* Protocol won't log in now without a username set.. Disconnect */ |
| 870 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set")); | 881 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set")); |
| 871 } | 882 } |
| 872 | 883 |
| 873 /** | 884 /** |
| 874 * They've decided to set a username! Yay! | 885 * They've decided to set a username! Yay! |
| 875 */ | 886 */ |
