diff libgaim/protocols/yahoo/yahoo.c @ 15057:f227feab8c78

[gaim-migrate @ 17841] Ok... let's throw this to the wild. Support for "So-and-so want's authorization" in the core. It creates a new mini-dialog in the blist for this with an Authorize and Deny button, which do as you might imagine. Clicking Authorize will also spawn an "Add buddy" dialog if that person isn't already a buddy. I'm not sure I like this, since I never add buddies that I authorize, but it seems the best option. I considered a checkbox in the dialog (but it only applies when you hit "Authorize," which could be weird), and a third "Authorize and Add" button (but that was too big for the blist). I'll come back to the UI later, I'm sure. I'd like to see that the prpl changes all work. Yahoo, especially, looked confusing, and had the most changes. I'm mostly happy with this. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 29 Nov 2006 01:13:21 +0000
parents 89ae31668a9c
children acf1b5803346
line wrap: on
line diff
--- a/libgaim/protocols/yahoo/yahoo.c	Tue Nov 28 21:29:12 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo.c	Wed Nov 29 01:13:21 2006 +0000
@@ -910,16 +910,7 @@
 };
 
 static void
-yahoo_buddy_add_authorize_cb(struct yahoo_add_request *add_req, const char *msg) {
-	GaimBuddy *buddy = gaim_find_buddy(add_req->gc->account, add_req->who);
-
-	if (buddy != NULL)
-		gaim_account_notify_added(add_req->gc->account, add_req->who,
-			add_req->id, NULL, add_req->msg);
-	else
-		gaim_account_request_add(add_req->gc->account, add_req->who,
-			add_req->id, NULL, add_req->msg);
-
+yahoo_buddy_add_authorize_cb(struct yahoo_add_request *add_req) {
 	g_free(add_req->id);
 	g_free(add_req->who);
 	g_free(add_req->msg);
@@ -956,6 +947,20 @@
 	g_free(add_req);
 }
 
+static void
+yahoo_buddy_add_deny_noreason_cb(struct yahoo_add_request *add_req, const char*msg)
+{
+	yahoo_buddy_add_deny_cb(add_req, NULL);
+}
+
+static void
+yahoo_buddy_add_deny_reason_cb(struct yahoo_add_request *add_req) {
+	gaim_request_input(add_req->gc, NULL, _("Authorization denied message:"),
+			NULL, _("No reason given."), TRUE, FALSE, NULL, 
+			_("OK"), G_CALLBACK(yahoo_buddy_add_deny_cb),
+			_("Cancel"), G_CALLBACK(yahoo_buddy_add_deny_noreason_cb), add_req);
+}
+
 static void yahoo_buddy_added_us(GaimConnection *gc, struct yahoo_packet *pkt) {
 	struct yahoo_add_request *add_req;
 	char *msg = NULL;
@@ -984,27 +989,16 @@
 	}
 
 	if (add_req->id) {
-		char *prompt_msg;
 		if (msg)
 			add_req->msg = yahoo_string_decode(gc, msg, FALSE);
 
-		/* TODO: this is almost exactly the same as what MSN does,
+		/* DONE! this is almost exactly the same as what MSN does,
 		 * this should probably be moved to the core.
 		 */
-		prompt_msg = g_strdup_printf(_("The user %s wants to add %s to "
-					"his or her buddy list%s%s."),
-				add_req->who, add_req->id,
-				add_req->msg ? ": " : "",
-				add_req->msg ? add_req->msg : "");
-		gaim_request_input(gc, NULL, prompt_msg,
-				_("Message (optional) :"),
-				NULL, TRUE, FALSE, NULL,
-				_("Authorize"), G_CALLBACK(
-					yahoo_buddy_add_authorize_cb),
-				_("Deny"), G_CALLBACK(
-					yahoo_buddy_add_deny_cb),
-				add_req);
-		g_free(prompt_msg);
+		 gaim_account_request_authorization(gaim_connection_get_account(gc), add_req->who, add_req->id,
+                                                    NULL, add_req->msg, G_CALLBACK(yahoo_buddy_add_authorize_cb), 
+						    G_CALLBACK(yahoo_buddy_add_deny_reason_cb),
+                                                    add_req);
 	} else {
 		g_free(add_req->id);
 		g_free(add_req->who);