changeset 2582:5efa8077107f

[gaim-migrate @ 2595] add committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 23 Oct 2001 04:54:45 +0000
parents 3e9906e1e5f6
children ce3df2c43f46
files ChangeLog src/buddy.c src/conversation.c src/dialogs.c src/protocols/icq/gaim_icq.c src/protocols/msn/msn.c src/protocols/yahoo/yay.c src/prpl.c src/prpl.h src/ui.h
diffstat 10 files changed, 94 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Oct 23 04:18:07 2001 +0000
+++ b/ChangeLog	Tue Oct 23 04:54:45 2001 +0000
@@ -18,6 +18,8 @@
 	  dequeued.
 	* You can choose which sound player you use at run-time
 	  (thanks Ben Miller)
+	* When someone adds you to their buddy list, it asks if you want
+	  to add them as well (Yahoo, ICQ, and MSN) (thanks Nathan Walp)
 
 version 0.46 (10/18/2001):
 	* New applet icons (courtesy David Raeman)
--- a/src/buddy.c	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/buddy.c	Tue Oct 23 04:54:45 2001 +0000
@@ -1310,7 +1310,7 @@
 			gc = (struct gaim_connection *)type;
 		}
 	}
-	show_add_buddy(gc, NULL, grp);
+	show_add_buddy(gc, NULL, grp, NULL);
 
 }
 
--- a/src/conversation.c	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/conversation.c	Tue Oct 23 04:54:45 2001 +0000
@@ -547,7 +547,7 @@
 		update_convo_add_button(c);
 	} else {
 		if (c->gc)
-			show_add_buddy(c->gc, c->name, NULL);
+			show_add_buddy(c->gc, c->name, NULL, NULL);
 	}
 
 	gtk_widget_grab_focus(c->entry);
--- a/src/dialogs.c	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/dialogs.c	Tue Oct 23 04:54:45 2001 +0000
@@ -869,7 +869,7 @@
 
 }
 
-void show_add_buddy(struct gaim_connection *gc, char *buddy, char *group)
+void show_add_buddy(struct gaim_connection *gc, char *buddy, char *group, char *alias)
 {
 	GtkWidget *mainbox;
 	GtkWidget *frame;
@@ -922,6 +922,8 @@
 
 	a->entry_for_alias = gtk_entry_new();
 	gtk_table_attach_defaults(GTK_TABLE(table), a->entry_for_alias, 1, 2, 1, 2);
+	if (alias != NULL)
+		gtk_entry_set_text(GTK_ENTRY(a->entry_for_alias), alias);
 
 	label = gtk_label_new(_("Group"));
 	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
--- a/src/protocols/icq/gaim_icq.c	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/protocols/icq/gaim_icq.c	Tue Oct 23 04:54:45 2001 +0000
@@ -245,19 +245,52 @@
 	return;
 }
 
+static void icq_recv_add(icq_Link *link, unsigned long id, unsigned char hour, unsigned char minute,
+		unsigned char day, unsigned char month, unsigned short year, const char *nick,
+		const char *first, const char *last, const char *email)
+{
+	char uin[16];
+	g_snprintf(uin, sizeof(uin), "%ld", id);
+	show_got_added(link->icq_UserData, NULL, uin, nick, NULL);
+}
+
 struct icq_auth {
 	icq_Link *link;
+	char *nick;
 	unsigned long uin;
+	struct gaim_connection *gc;
 };
 
 static void icq_den_auth(gpointer x, struct icq_auth *iq)
 {
+	g_free(iq->nick);
 	g_free(iq);
 }
 
+static void icq_add_after_auth(gpointer x, struct icq_auth *iq)
+{
+	char uin[16];
+	g_snprintf(uin, sizeof(uin), "%ld", iq->uin);
+	show_add_buddy(iq->gc, uin, NULL, iq->nick);
+}
+
 static void icq_acc_auth(gpointer x, struct icq_auth *iq)
 {
+	char msg[1024];
+	char uin[16];
+	struct icq_auth *iqnew;
+	
 	icq_SendAuthMsg(iq->link, iq->uin);
+
+	g_snprintf(uin, sizeof(uin), "%ld", iq->uin);
+	if (find_buddy(iq->gc, uin))
+		return;
+
+	iqnew = g_memdup(iq, sizeof(struct icq_auth));
+	iqnew->nick = g_strdup(iq->nick);
+
+	g_snprintf(msg, sizeof(msg), "Add %ld to your buddy list?", iq->uin);
+	do_ask_dialog(msg, iqnew, icq_add_after_auth, icq_den_auth);
 }
 
 static void icq_auth_req(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute,
@@ -267,7 +300,9 @@
 	char msg[8192];
 	struct icq_auth *iq = g_new0(struct icq_auth, 1);
 	iq->link = link;
+	iq->nick = g_strdup(nick);
 	iq->uin = uin;
+	iq->gc = link->icq_UserData;
 
 	g_snprintf(msg, sizeof(msg), "The user %s (%s%s%s%s%s) wants you to authorize them.",
 			nick, first ? first : "", first && last ? " " : "", last ? last : "",
@@ -295,6 +330,7 @@
 	link->icq_RecvURL = icq_url_incoming;
 	link->icq_RecvWebPager = icq_web_pager;
 	link->icq_RecvMailExpress = icq_mail_express;
+	link->icq_RecvAdded = icq_recv_add;
 	link->icq_RecvAuthReq = icq_auth_req;
 	link->icq_UserOnline = icq_user_online;
 	link->icq_UserOffline = icq_user_offline;
--- a/src/protocols/msn/msn.c	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/protocols/msn/msn.c	Tue Oct 23 04:54:45 2001 +0000
@@ -595,6 +595,8 @@
 		signoff(map->gc);
 		return;
 	}
+
+	show_got_added(map->gc, NULL, map->user, map->friend, NULL);
 }
 
 static void msn_cancel_add(gpointer w, struct msn_add_permit *map)
--- a/src/protocols/yahoo/yay.c	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/protocols/yahoo/yay.c	Tue Oct 23 04:54:45 2001 +0000
@@ -174,7 +174,6 @@
 	char *id;
 	char *who;
 	char *msg;
-	char buf[2048];
 
 	va_start(ap, sess);
 	id = va_arg(ap, char *);
@@ -182,9 +181,7 @@
 	msg = va_arg(ap, char *);
 	va_end(ap);
 
-	g_snprintf(buf, sizeof(buf), _("%s has made %s their buddy%s%s"), who, id,
-			msg ? ": " : "", msg ? msg : "");
-	do_error_dialog(buf, _("Gaim - Buddy"));
+	show_got_added(sess->user_data, id, who, NULL, msg);
 
 	return 1;
 }
--- a/src/prpl.c	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/prpl.c	Tue Oct 23 04:54:45 2001 +0000
@@ -529,3 +529,47 @@
 	*len = 0;
 	return NULL;
 }
+
+struct got_add {
+	struct gaim_connection *gc;
+	char *who;
+	char *alias;
+};
+
+static void dont_add(gpointer x, struct got_add *ga)
+{
+	g_free(ga->who);
+	if (ga->alias)
+		g_free(ga->alias);
+	g_free(ga);
+}
+
+static void do_add(gpointer x, struct got_add *ga)
+{
+	show_add_buddy(ga->gc, ga->who, NULL, ga->alias);
+}
+
+void show_got_added(struct gaim_connection *gc, const char *id,
+		    const char *who, const char *alias, const char *msg)
+{
+	char buf[BUF_LONG];
+	struct got_add *ga = g_new0(struct got_add, 1);
+
+	ga->gc = gc;
+	ga->who = g_strdup(who);
+	ga->alias = alias ? g_strdup(alias) : NULL;
+
+	g_snprintf(buf, sizeof(buf), _("%s%s%s%s has made %s their buddy%s%s%s"),
+		   who,
+		   alias ? " (" : "",
+		   alias ? alias : "",
+		   alias ? ")" : "",
+		   id ? id : gc->displayname[0] ? gc->displayname : gc->username,
+		   msg ? ": " : ".",
+		   msg ? msg : "",
+		   find_buddy(gc, ga->who) ? "" : _("\n\nDo you wish to add them to your buddy list?"));
+	if (find_buddy(gc, ga->who))
+		do_error_dialog(buf, "Added to List");
+	else
+		do_ask_dialog(buf, ga, do_add, dont_add);
+}
--- a/src/prpl.h	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/prpl.h	Tue Oct 23 04:54:45 2001 +0000
@@ -160,6 +160,9 @@
 extern struct prpl *find_prpl(int);
 extern void do_proto_menu();
 
+extern void show_got_added(struct gaim_connection *, const char *,
+			   const char *, const char *, const char *);
+
 extern void do_ask_dialog(const char *, void *, void *, void *);
 extern void do_prompt_dialog(const char *, const char *, void *, void *, void *);
 
--- a/src/ui.h	Tue Oct 23 04:18:07 2001 +0000
+++ b/src/ui.h	Tue Oct 23 04:54:45 2001 +0000
@@ -364,7 +364,7 @@
 extern void show_warn_dialog(struct gaim_connection *, char *);
 extern void show_im_dialog();
 extern void show_info_dialog();
-extern void show_add_buddy(struct gaim_connection *, char *, char *);
+extern void show_add_buddy(struct gaim_connection *, char *, char *, char *);
 extern void show_add_group(struct gaim_connection *);
 extern void show_add_perm(struct gaim_connection *, char *, gboolean);
 extern void destroy_all_dialogs();