changeset 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 0d5dab71be7a
children c62fac7ada0d
files libpurple/protocols/oscar/family_icq.c libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscar.h
diffstat 3 files changed, 34 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/family_icq.c	Sun May 23 17:22:51 2010 +0000
+++ b/libpurple/protocols/oscar/family_icq.c	Sun May 23 18:28:46 2010 +0000
@@ -232,7 +232,7 @@
 	return 0;
 }
 
-int aim_icq_getalias(OscarData *od, const char *uin)
+int aim_icq_getalias(OscarData *od, const char *uin, gboolean for_auth_request, char *auth_request_reason)
 {
 	FlapConnection *conn;
 	ByteStream bs;
@@ -274,6 +274,8 @@
 	info->reqid = snacid;
 	info->uin = atoi(uin);
 	info->next = od->icq_info;
+	info->for_auth_request = for_auth_request;
+	info->auth_request_reason = g_strdup(auth_request_reason);
 	od->icq_info = info;
 
 	return 0;
--- a/libpurple/protocols/oscar/oscar.c	Sun May 23 17:22:51 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sun May 23 18:28:46 2010 +0000
@@ -2895,7 +2895,6 @@
 
 		case 0x06: { /* Someone requested authorization */
 			if (i >= 6) {
-				struct name_data *data = g_new(struct name_data, 1);
 				gchar *bn = g_strdup_printf("%u", args->uin);
 				gchar *reason = NULL;
 
@@ -2905,14 +2904,8 @@
 				purple_debug_info("oscar",
 						   "Received an authorization request from UIN %u\n",
 						   args->uin);
-				data->gc = gc;
-				data->name = bn;
-				data->nick = NULL;
-
-				purple_account_request_authorization(account, bn, NULL, NULL,
-						reason, purple_find_buddy(account, bn) != NULL,
-						purple_auth_grant,
-						purple_auth_dontgrant_msgprompt, data);
+				aim_icq_getalias(od, bn, TRUE, reason);
+				g_free(bn);
 				g_free(reason);
 			}
 		} break;
@@ -4210,15 +4203,28 @@
 	info = va_arg(ap, struct aim_icq_info *);
 	va_end(ap);
 
-	if (info->uin && info->nick && info->nick[0] && (utf8 = oscar_utf8_try_convert(account, od, info->nick))) {
-		g_snprintf(who, sizeof(who), "%u", info->uin);
-		serv_got_alias(gc, who, utf8);
-		if ((b = purple_find_buddy(account, who))) {
-			purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", utf8);
+	if (info->nick[0] && (utf8 = oscar_utf8_try_convert(account, od, info->nick))) {
+		if (info->for_auth_request) {
+			struct name_data *data = g_new(struct name_data, 1);
+
+			data->gc = gc;
+			data->name = g_strdup_printf("%u", info->uin);
+			data->nick = utf8;
+
+			purple_account_request_authorization(account, data->name, NULL, data->nick,
+				info->auth_request_reason, purple_find_buddy(account, data->name) != NULL,
+				purple_auth_grant, purple_auth_dontgrant_msgprompt, data);
+		} else {
+			g_snprintf(who, sizeof(who), "%u", info->uin);
+			serv_got_alias(gc, who, utf8);
+			if ((b = purple_find_buddy(account, who))) {
+				purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", utf8);
+			}
+			g_free(utf8);
 		}
-		g_free(utf8);
-	}
-
+	}
+
+	g_free(info->auth_request_reason);
 	return 1;
 }
 
@@ -5029,7 +5035,7 @@
 
 	/* XXX - Should this be done from AIM accounts, as well? */
 	if (od->icq)
-		aim_icq_getalias(od, bname);
+		aim_icq_getalias(od, bname, FALSE, NULL);
 }
 
 void oscar_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {
@@ -5653,24 +5659,18 @@
 
 static int purple_ssi_authrequest(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
 {
-	PurpleConnection *gc = od->gc;
 	va_list ap;
 	const char *bn;
-	const char *msg;
-	PurpleAccount *account = purple_connection_get_account(gc);
-	struct name_data *data;
-	PurpleBuddy *buddy;
+	char *msg;
 
 	va_start(ap, fr);
 	bn = va_arg(ap, const char *);
-	msg = va_arg(ap, const char *);
+	msg = va_arg(ap, char *);
 	va_end(ap);
 
 	purple_debug_info("oscar",
 			"ssi: received authorization request from %s\n", bn);
 
-	buddy = purple_find_buddy(account, bn);
-
 	if (!msg) {
 		purple_debug_warning("oscar", "Received auth request from %s with "
 				"empty message\n", bn);
@@ -5680,16 +5680,7 @@
 		msg = NULL;
 	}
 
-	data = g_new(struct name_data, 1);
-	data->gc = gc;
-	data->name = g_strdup(bn);
-	data->nick = (buddy ? g_strdup(purple_buddy_get_alias_only(buddy)) : NULL);
-
-	purple_account_request_authorization(account, bn, NULL,
-			(buddy ? purple_buddy_get_alias_only(buddy) : NULL),
-			msg, buddy != NULL, purple_auth_grant,
-			purple_auth_dontgrant_msgprompt, data);
-
+	aim_icq_getalias(od, bn, TRUE, msg);
 	return 1;
 }
 
--- a/libpurple/protocols/oscar/oscar.h	Sun May 23 17:22:51 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Sun May 23 18:28:46 2010 +0000
@@ -1416,6 +1416,9 @@
 	/* status note info */
 	guint8 icbm_cookie[8];
 	char *status_note_title;
+
+	gboolean for_auth_request;
+	char *auth_request_reason;
 };
 
 #ifdef OLDSTYLE_ICQ_OFFLINEMSGS
@@ -1425,7 +1428,7 @@
 int aim_icq_setsecurity(OscarData *od, gboolean auth_required, gboolean webaware);
 int aim_icq_changepasswd(OscarData *od, const char *passwd);
 int aim_icq_getsimpleinfo(OscarData *od, const char *uin);
-int aim_icq_getalias(OscarData *od, const char *uin);
+int aim_icq_getalias(OscarData *od, const char *uin, gboolean for_auth_request, char *auth_request_reason);
 int aim_icq_getallinfo(OscarData *od, const char *uin);
 int aim_icq_sendsms(OscarData *od, const char *name, const char *msg, const char *alias);