changeset 4244:091e9db94ebc

[gaim-migrate @ 4494] I'm paving the way for the information super duper clown road of lemon and apple goodnessness. Also, someone please test direct connections and direct IMs. They might crash like a banshee. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 08 Jan 2003 05:23:22 +0000
parents eae97ca4bbea
children cd84b0fd63fc
files src/protocols/oscar/oscar.c
diffstat 1 files changed, 68 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c	Wed Jan 08 04:06:20 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Wed Jan 08 05:23:22 2003 +0000
@@ -1721,19 +1721,25 @@
 	g_free(oft);
 }
 
-static int accept_direct_im(struct ask_direct *d) {
+static void accept_direct_im(struct ask_direct *d) {
 	struct gaim_connection *gc = d->gc;
-	struct oscar_data *od = (struct oscar_data *)gc->proto_data;
+	struct oscar_data *od;
 	struct direct_im *dim;
 	char *host; int port = 4443;
 	int i;
 
+	if (!g_slist_find(connections, gc)) {
+		cancel_direct_im(d);
+		return;
+	}
+
+	od = (struct oscar_data *)gc->proto_data;
 	debug_printf("Accepted DirectIM.\n");
 
 	dim = find_direct_im(od, d->sn);
 	if (dim) {
 		cancel_direct_im(d); /* 40 */
-		return TRUE;
+		return;
 	}
 	dim = g_new0(struct direct_im, 1);
 	dim->gc = d->gc;
@@ -1743,7 +1749,7 @@
 	if (!dim->conn) {
 		g_free(dim);
 		cancel_direct_im(d);
-		return TRUE;
+		return;
 	}
 
 	aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING,
@@ -1766,12 +1772,12 @@
 		aim_conn_kill(od->sess, &dim->conn);
 		g_free(dim);
 		cancel_direct_im(d);
-		return TRUE;
+		return;
 	}
 
 	cancel_direct_im(d);
 
-	return TRUE;
+	return;
 }
 
 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) {
@@ -2058,60 +2064,80 @@
  */
 static void gaim_auth_request(struct name_data *data) {
 	struct gaim_connection *gc = data->gc;
-	struct oscar_data *od = gc->proto_data;
-	struct buddy *buddy = find_buddy(gc, data->name);
-	struct group *group = find_group_by_buddy(gc, data->name);
-	if (buddy && group) {
-		debug_printf("ssi: adding buddy %s to group %s\n", buddy->name, group->name);
-		aim_ssi_sendauthrequest(od->sess, od->conn, data->name, "Please authorize me so I can add you to my buddy list.");
-		aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 1);
+
+	if (g_slist_find(connections, gc)) {
+		struct oscar_data *od = gc->proto_data;
+		struct buddy *buddy = find_buddy(gc, data->name);
+		struct group *group = find_group_by_buddy(gc, data->name);
+		if (buddy && group) {
+			debug_printf("ssi: adding buddy %s to group %s\n", buddy->name, group->name);
+			aim_ssi_sendauthrequest(od->sess, od->conn, data->name, "Please authorize me so I can add you to my buddy list.");
+			aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 1);
+		}
 	}
+
 	gaim_free_name_data(data);
 }
 
 static void gaim_auth_dontrequest(struct name_data *data) {
-/*	struct gaim_connection *gc = data->gc; */
-/*	struct oscar_data *od = gc->proto_data; */
-	/* XXX - Take the buddy out of our buddy list */
+	struct gaim_connection *gc = data->gc;
+
+	if (g_slist_find(connections, gc)) {
+		/* struct oscar_data *od = gc->proto_data; */
+		/* XXX - Take the buddy out of our buddy list */
+	}
+
 	gaim_free_name_data(data);
 }
 
 /* When other people ask you for authorization */
 static void gaim_auth_grant(struct name_data *data) {
 	struct gaim_connection *gc = data->gc;
-	struct oscar_data *od = gc->proto_data;
+
+	if (g_slist_find(connections, gc)) {
+		struct oscar_data *od = gc->proto_data;
 #ifdef NOSSI
-	struct buddy *buddy;
-	gchar message;
-	message = 0;
-	buddy = find_buddy(gc, data->name);
-	aim_send_im_ch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message);
-	show_got_added(gc, NULL, data->name, (buddy ? get_buddy_alias_only(buddy) : NULL), NULL);
+		struct buddy *buddy;
+		gchar message;
+		message = 0;
+		buddy = find_buddy(gc, data->name);
+		aim_send_im_ch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message);
+		show_got_added(gc, NULL, data->name, (buddy ? get_buddy_alias_only(buddy) : NULL), NULL);
 #else
-	aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x01, NULL);
+		aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x01, NULL);
 #endif
+	}
+
 	gaim_free_name_data(data);
 }
 
 /* When other people ask you for authorization */
 static void gaim_auth_dontgrant(struct name_data *data) {
 	struct gaim_connection *gc = data->gc;
-	struct oscar_data *od = gc->proto_data;
-	gchar *message;
-	message = g_strdup_printf(_("No reason given."));
+
+	if (g_slist_find(connections, gc)) {
+		struct oscar_data *od = gc->proto_data;
+		gchar *message;
 #ifdef NOSSI
-	aim_send_im_ch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, message);
+		message = g_strdup_printf(_("No reason given."));
+		aim_send_im_ch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, message);
 #else
-	aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x00, message);
+		aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x00, message);
 #endif
-	g_free(message);
+		g_free(message);
+	}
+
 	gaim_free_name_data(data);
 }
 
 /* When someone sends you contacts  */
 static void gaim_icq_contactadd(struct name_data *data) {
 	struct gaim_connection *gc = data->gc;
-	show_add_buddy(gc, data->name, NULL, data->nick);
+
+	if (g_slist_find(connections, gc)) {
+		show_add_buddy(gc, data->name, NULL, data->nick);
+	}
+
 	gaim_free_name_data(data);
 }
 
@@ -4774,9 +4800,16 @@
 
 static void oscar_direct_im(struct ask_do_dir_im *data) {
 	struct gaim_connection *gc = data->gc;
-	struct oscar_data *od = (struct oscar_data *)gc->proto_data;
+	struct oscar_data *od;
 	struct direct_im *dim;
 
+	if (!g_slist_find(connections, gc)) {
+		g_free(data);
+		return;
+	}
+
+	od = (struct oscar_data *)gc->proto_data;
+
 	dim = find_direct_im(od, data->who);
 	if (dim) {
 		if (!(dim->connected)) {  /* We'll free the old, unconnected dim, and start over */
@@ -4786,6 +4819,7 @@
 			debug_printf("Gave up on old direct IM, trying again\n");
 		} else {
 			do_error_dialog("DirectIM already open.", NULL, GAIM_ERROR);
+			g_free(data);
 			return;
 		}
 	}
@@ -4804,6 +4838,8 @@
 		do_error_dialog(_("Unable to open Direct IM"), NULL, GAIM_ERROR);
 		g_free(dim);
 	}
+
+	g_free(data);
 }
 
 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) {