comparison libpurple/protocols/oscar/oscar.c @ 30790:674a656893a3

Show authorization request sender's nickname in the "Authorize buddy?" dialog. Fixes #3207. I've slightly modified the original patch (courtesy of Collin): * the code emitting the "buddy-status-changed" signal was removed, because it doesn't appear to be necessary; * "info->uin && info->nick" check in purple_icqalias() was removed, since icqresponse() in family_icq.c already does that.
author ivan.komarov@soc.pidgin.im
date Sun, 23 May 2010 18:28:46 +0000
parents 053776c347c8
children 8d5b0cbec844
comparison
equal deleted inserted replaced
30789:0d5dab71be7a 30790:674a656893a3
2893 } 2893 }
2894 } break; 2894 } break;
2895 2895
2896 case 0x06: { /* Someone requested authorization */ 2896 case 0x06: { /* Someone requested authorization */
2897 if (i >= 6) { 2897 if (i >= 6) {
2898 struct name_data *data = g_new(struct name_data, 1);
2899 gchar *bn = g_strdup_printf("%u", args->uin); 2898 gchar *bn = g_strdup_printf("%u", args->uin);
2900 gchar *reason = NULL; 2899 gchar *reason = NULL;
2901 2900
2902 if (msg2[5] != NULL) 2901 if (msg2[5] != NULL)
2903 reason = purple_plugin_oscar_decode_im_part(account, bn, AIM_CHARSET_LATIN_1, 0x0000, msg2[5], strlen(msg2[5])); 2902 reason = purple_plugin_oscar_decode_im_part(account, bn, AIM_CHARSET_LATIN_1, 0x0000, msg2[5], strlen(msg2[5]));
2904 2903
2905 purple_debug_info("oscar", 2904 purple_debug_info("oscar",
2906 "Received an authorization request from UIN %u\n", 2905 "Received an authorization request from UIN %u\n",
2907 args->uin); 2906 args->uin);
2908 data->gc = gc; 2907 aim_icq_getalias(od, bn, TRUE, reason);
2909 data->name = bn; 2908 g_free(bn);
2910 data->nick = NULL;
2911
2912 purple_account_request_authorization(account, bn, NULL, NULL,
2913 reason, purple_find_buddy(account, bn) != NULL,
2914 purple_auth_grant,
2915 purple_auth_dontgrant_msgprompt, data);
2916 g_free(reason); 2909 g_free(reason);
2917 } 2910 }
2918 } break; 2911 } break;
2919 2912
2920 case 0x07: { /* Someone has denied you authorization */ 2913 case 0x07: { /* Someone has denied you authorization */
4208 4201
4209 va_start(ap, fr); 4202 va_start(ap, fr);
4210 info = va_arg(ap, struct aim_icq_info *); 4203 info = va_arg(ap, struct aim_icq_info *);
4211 va_end(ap); 4204 va_end(ap);
4212 4205
4213 if (info->uin && info->nick && info->nick[0] && (utf8 = oscar_utf8_try_convert(account, od, info->nick))) { 4206 if (info->nick[0] && (utf8 = oscar_utf8_try_convert(account, od, info->nick))) {
4214 g_snprintf(who, sizeof(who), "%u", info->uin); 4207 if (info->for_auth_request) {
4215 serv_got_alias(gc, who, utf8); 4208 struct name_data *data = g_new(struct name_data, 1);
4216 if ((b = purple_find_buddy(account, who))) { 4209
4217 purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", utf8); 4210 data->gc = gc;
4218 } 4211 data->name = g_strdup_printf("%u", info->uin);
4219 g_free(utf8); 4212 data->nick = utf8;
4220 } 4213
4221 4214 purple_account_request_authorization(account, data->name, NULL, data->nick,
4215 info->auth_request_reason, purple_find_buddy(account, data->name) != NULL,
4216 purple_auth_grant, purple_auth_dontgrant_msgprompt, data);
4217 } else {
4218 g_snprintf(who, sizeof(who), "%u", info->uin);
4219 serv_got_alias(gc, who, utf8);
4220 if ((b = purple_find_buddy(account, who))) {
4221 purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", utf8);
4222 }
4223 g_free(utf8);
4224 }
4225 }
4226
4227 g_free(info->auth_request_reason);
4222 return 1; 4228 return 1;
4223 } 4229 }
4224 4230
4225 static int purple_popup(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) 4231 static int purple_popup(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
4226 { 4232 {
5027 } 5033 }
5028 } 5034 }
5029 5035
5030 /* XXX - Should this be done from AIM accounts, as well? */ 5036 /* XXX - Should this be done from AIM accounts, as well? */
5031 if (od->icq) 5037 if (od->icq)
5032 aim_icq_getalias(od, bname); 5038 aim_icq_getalias(od, bname, FALSE, NULL);
5033 } 5039 }
5034 5040
5035 void oscar_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { 5041 void oscar_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {
5036 OscarData *od = purple_connection_get_protocol_data(gc); 5042 OscarData *od = purple_connection_get_protocol_data(gc);
5037 5043
5651 return 1; 5657 return 1;
5652 } 5658 }
5653 5659
5654 static int purple_ssi_authrequest(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) 5660 static int purple_ssi_authrequest(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
5655 { 5661 {
5656 PurpleConnection *gc = od->gc;
5657 va_list ap; 5662 va_list ap;
5658 const char *bn; 5663 const char *bn;
5659 const char *msg; 5664 char *msg;
5660 PurpleAccount *account = purple_connection_get_account(gc);
5661 struct name_data *data;
5662 PurpleBuddy *buddy;
5663 5665
5664 va_start(ap, fr); 5666 va_start(ap, fr);
5665 bn = va_arg(ap, const char *); 5667 bn = va_arg(ap, const char *);
5666 msg = va_arg(ap, const char *); 5668 msg = va_arg(ap, char *);
5667 va_end(ap); 5669 va_end(ap);
5668 5670
5669 purple_debug_info("oscar", 5671 purple_debug_info("oscar",
5670 "ssi: received authorization request from %s\n", bn); 5672 "ssi: received authorization request from %s\n", bn);
5671
5672 buddy = purple_find_buddy(account, bn);
5673 5673
5674 if (!msg) { 5674 if (!msg) {
5675 purple_debug_warning("oscar", "Received auth request from %s with " 5675 purple_debug_warning("oscar", "Received auth request from %s with "
5676 "empty message\n", bn); 5676 "empty message\n", bn);
5677 } else if (!g_utf8_validate(msg, -1, NULL)) { 5677 } else if (!g_utf8_validate(msg, -1, NULL)) {
5678 purple_debug_warning("oscar", "Received auth request from %s with " 5678 purple_debug_warning("oscar", "Received auth request from %s with "
5679 "invalid UTF-8 message\n", bn); 5679 "invalid UTF-8 message\n", bn);
5680 msg = NULL; 5680 msg = NULL;
5681 } 5681 }
5682 5682
5683 data = g_new(struct name_data, 1); 5683 aim_icq_getalias(od, bn, TRUE, msg);
5684 data->gc = gc;
5685 data->name = g_strdup(bn);
5686 data->nick = (buddy ? g_strdup(purple_buddy_get_alias_only(buddy)) : NULL);
5687
5688 purple_account_request_authorization(account, bn, NULL,
5689 (buddy ? purple_buddy_get_alias_only(buddy) : NULL),
5690 msg, buddy != NULL, purple_auth_grant,
5691 purple_auth_dontgrant_msgprompt, data);
5692
5693 return 1; 5684 return 1;
5694 } 5685 }
5695 5686
5696 static int purple_ssi_authreply(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { 5687 static int purple_ssi_authreply(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
5697 PurpleConnection *gc = od->gc; 5688 PurpleConnection *gc = od->gc;