changeset 4236:9641bd9c79f5

[gaim-migrate @ 4482] Hi there. Me again. A small patch from Mr. Reisner that makes the rename buddy dialog and jabber's vcard dialog (set jabber info) dialog buttons follow the gnome HIG. Thank you thank you. Pizza pizza. Changes to oscar.c... Make some debug_printf's not i18nish. 1) They don't really help us if they're in another language. 2) Translators have enough strings as it is I made a few more of the ICQ auth dialogs show ##### (alias) instead of just #####. Change how some data in ssi.c is allocated/freed. It's a cleaner implementation this way, but maybe just a little slower. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 08 Jan 2003 01:37:11 +0000
parents cba92ec56248
children 2b5fa2b2f4ae
files src/dialogs.c src/protocols/oscar/oscar.c src/protocols/oscar/ssi.c
diffstat 3 files changed, 97 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Tue Jan 07 23:58:52 2003 +0000
+++ b/src/dialogs.c	Wed Jan 08 01:37:11 2003 +0000
@@ -4464,16 +4464,16 @@
 		bbox = gtk_hbox_new(FALSE, 5);
 		gtk_box_pack_start(GTK_BOX(mainbox), bbox, FALSE, FALSE, 0);
 
-		button = picture_button(rename_bud_dialog, _("Cancel"), cancel_xpm);
-		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
-		g_signal_connect(GTK_OBJECT(button), "clicked",
-				   G_CALLBACK(destroy_dialog), rename_bud_dialog);
-
 		button = picture_button(rename_bud_dialog, _("OK"), ok_xpm);
 		gtk_object_set_user_data(GTK_OBJECT(button), b);
 		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 		g_signal_connect(GTK_OBJECT(button), "clicked",
 				   G_CALLBACK(do_rename_buddy), name_entry);
+
+		button = picture_button(rename_bud_dialog, _("Cancel"), cancel_xpm);
+		gtk_box_pack_end(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+		g_signal_connect(GTK_OBJECT(button), "clicked",
+				   G_CALLBACK(destroy_dialog), rename_bud_dialog);
 	}
 
 	gtk_widget_show_all(rename_bud_dialog);
@@ -5206,6 +5206,12 @@
 	gtk_box_pack_start(GTK_BOX (vbox), hbox, FALSE, FALSE, 5);
 	gtk_widget_show(hbox);
 
+	button = picture_button(b->window, _("Save"), save_xpm);
+	g_signal_connect(GTK_OBJECT (button), "clicked",
+		G_CALLBACK (b->ok), (gpointer) b);
+	gtk_box_pack_end(GTK_BOX (hbox), button, FALSE, FALSE, 5);
+	gtk_widget_show(button);
+
 	button = picture_button(b->window, _("Cancel"), cancel_xpm);
 
 	/* Let "destroy handling" (set above) handle cleanup */
@@ -5214,12 +5220,6 @@
 	gtk_box_pack_end(GTK_BOX (hbox), button, FALSE, FALSE, 5);
 	gtk_widget_show(button);
 
-	button = picture_button(b->window, _("Save"), save_xpm);
-	g_signal_connect(GTK_OBJECT (button), "clicked",
-		G_CALLBACK (b->ok), (gpointer) b);
-	gtk_box_pack_end(GTK_BOX (hbox), button, FALSE, FALSE, 5);
-	gtk_widget_show(button);
-
 	gtk_widget_show(vbox);
 	gtk_widget_show(b->window);
 }
--- a/src/protocols/oscar/oscar.c	Tue Jan 07 23:58:52 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Wed Jan 08 01:37:11 2003 +0000
@@ -513,7 +513,7 @@
 		if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {
 			debug_printf("got information on rendezvous\n");
 			if (aim_handlerendconnect(odata->sess, conn) < 0) {
-				debug_printf(_("connection error (rend)\n"));
+				debug_printf("connection error (rend)\n");
 				aim_conn_kill(odata->sess, &conn);
 			}
 		} else {
@@ -524,7 +524,7 @@
 			} else {
 				if ((conn->type == AIM_CONN_TYPE_BOS) ||
 					   !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) {
-					debug_printf(_("major connection error\n"));
+					debug_printf("major connection error\n");
 					hide_login_progress_error(gc, _("Disconnected."));
 					signoff(gc);
 				} else if (conn->type == AIM_CONN_TYPE_CHAT) {
@@ -630,7 +630,7 @@
 	aim_conn_completeconnect(sess, conn);
 	gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ,
 			oscar_callback, conn);
-	debug_printf(_("Password sent, waiting for response\n"));
+	debug_printf("Password sent, waiting for response\n");
 }
 
 static void oscar_login(struct aim_user *user) {
@@ -665,7 +665,7 @@
 
 	conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL);
 	if (conn == NULL) {
-		debug_printf(_("internal connection error\n"));
+		debug_printf("internal connection error\n");
 		hide_login_progress(gc, _("Unable to login to AIM"));
 		signoff(gc);
 		return;
@@ -753,7 +753,7 @@
 	odata->sess = NULL;
 	g_free(gc->proto_data);
 	gc->proto_data = NULL;
-	debug_printf(_("Signed off.\n"));
+	debug_printf("Signed off.\n");
 }
 
 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) {
@@ -2080,13 +2080,15 @@
 static void gaim_auth_grant(struct name_data *data) {
 	struct gaim_connection *gc = data->gc;
 	struct oscar_data *od = gc->proto_data;
+#ifdef NOSSI
+	struct buddy *buddy;
 	gchar message;
 	message = 0;
-#ifdef NOSSI
+	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, NULL, NULL);
+	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, &message);
+	aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x01, NULL);
 #endif
 	gaim_free_name_data(data);
 }
@@ -4216,21 +4218,22 @@
 				if (retval->action == AIM_CB_SSI_ADD) {
 					struct name_data *data = g_new(struct name_data, 1);
 					struct buddy *buddy;
-					gchar *alias;
-					gchar *dialog_msg;
+					gchar *dialog_msg, *nombre;
 
 					buddy = find_buddy(gc, retval->name);
 					if (buddy && (get_buddy_alias_only(buddy)))
-						alias = g_strdup_printf(" (%s)", get_buddy_alias_only(buddy));
+						nombre = g_strdup_printf("%s (%s)", retval->name, get_buddy_alias_only(buddy));
 					else
-						alias = g_strdup("");
-					dialog_msg = g_strdup_printf(_("The user %s%s requires authorization before being added to a buddy list.  Do you want to send an authorization request?"), retval->name, alias);
+						nombre = g_strdup(retval->name);
+
+					dialog_msg = g_strdup_printf(_("The user %s requires authorization before being added to a buddy list.  Do you want to send an authorization request?"), nombre);
 					data->gc = gc;
 					data->name = g_strdup(retval->name);
 					data->nick = NULL;
 					do_ask_dialog(_("Request Authorization"), dialog_msg, data, _("Request Authorization"), gaim_auth_request, _("Cancel"), gaim_auth_dontrequest);
+
 					g_free(dialog_msg);
-					g_free(alias);
+					g_free(nombre);
 				}
 			} break;
 
@@ -4250,8 +4253,9 @@
 	struct gaim_connection *gc = sess->aux_data;
 	va_list ap;
 	char *sn, *msg;
-	gchar *dialog_msg;
+	gchar *dialog_msg, *nombre;
 	struct name_data *data;
+	struct buddy *buddy;
 
 	va_start(ap, fr);
 	sn = va_arg(ap, char *);
@@ -4260,13 +4264,21 @@
 
 	debug_printf("ssi: %s has given you permission to add him to your buddy list\n", sn);
 
-	dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list.  Do you want to add them?"), sn);
+	buddy = find_buddy(gc, sn);
+	if (buddy && (get_buddy_alias_only(buddy)))
+		nombre = g_strdup_printf("%s (%s)", sn, get_buddy_alias_only(buddy));
+	else
+		nombre = g_strdup(sn);
+
+	dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list.  Do you want to add them?"), nombre);
 	data = g_new(struct name_data, 1);
 	data->gc = gc;
 	data->name = g_strdup(sn);
 	data->nick = NULL;
 	do_ask_dialog(_("Authorization Given"), dialog_msg, data, _("Yes"), gaim_icq_contactadd, _("No"), gaim_free_name_data);
+
 	g_free(dialog_msg);
+	g_free(nombre);
 
 	return 1;
 }
@@ -4275,8 +4287,9 @@
 	struct gaim_connection *gc = sess->aux_data;
 	va_list ap;
 	char *sn, *msg;
-	gchar *dialog_msg;
+	gchar *dialog_msg, *nombre;
 	struct name_data *data;
+	struct buddy *buddy;
 
 	va_start(ap, fr);
 	sn = va_arg(ap, char *);
@@ -4285,22 +4298,32 @@
 
 	debug_printf("ssi: received authorization request from %s\n", sn);
 
-	dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason: %s"), sn, msg ? msg : _("No reason given."));
+	buddy = find_buddy(gc, sn);
+	if (buddy && (get_buddy_alias_only(buddy)))
+		nombre = g_strdup_printf("%s (%s)", sn, get_buddy_alias_only(buddy));
+	else
+		nombre = g_strdup(sn);
+
+	dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason: %s"), nombre, msg ? msg : _("No reason given."));
 	data = g_new(struct name_data, 1);
 	data->gc = gc;
 	data->name = g_strdup(sn);
 	data->nick = NULL;
 	do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant);
+
 	g_free(dialog_msg);
+	g_free(nombre);
 
 	return 1;
 }
 
 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) {
+	struct gaim_connection *gc = sess->aux_data;
 	va_list ap;
 	char *sn, *msg;
-	gchar *dialog_msg;
+	gchar *dialog_msg, *nombre;
 	fu8_t reply;
+	struct buddy *buddy;
 
 	va_start(ap, fr);
 	sn = va_arg(ap, char *);
@@ -4308,16 +4331,25 @@
 	msg = va_arg(ap, char *);
 	va_end(ap);
 
+	debug_printf("ssi: received authorization reply from %s.  Reply is 0x%04hhx\n", sn, reply);
+
+	buddy = find_buddy(gc, sn);
+	if (buddy && (get_buddy_alias_only(buddy)))
+		nombre = g_strdup_printf("%s (%s)", sn, get_buddy_alias_only(buddy));
+	else
+		nombre = g_strdup(sn);
+
 	if (reply) {
 		/* Granted */
-		dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your contact list."), sn);
+		dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your contact list."), nombre);
 		do_error_dialog(_("Authorization Granted"), dialog_msg, GAIM_INFO);
 	} else {
 		/* Denied */
-		dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your contact list for the following reason:\n%s"), sn, msg ? msg : _("No reason given."));
+		dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your contact list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given."));
 		do_error_dialog(_("Authorization Denied"), dialog_msg, GAIM_INFO);
 	}
 	g_free(dialog_msg);
+	g_free(nombre);
 
 	return 1;
 }
@@ -4326,13 +4358,15 @@
 	struct gaim_connection *gc = sess->aux_data;
 	va_list ap;
 	char *sn;
+	struct buddy *buddy;
 
 	va_start(ap, fr);
 	sn = va_arg(ap, char *);
 	va_end(ap);
 
+	buddy = find_buddy(gc, sn);
 	debug_printf("ssi: %s added you to their buddy list\n", sn);
-	show_got_added(gc, NULL, sn, NULL, NULL);
+	show_got_added(gc, NULL, sn, (buddy ? get_buddy_alias_only(buddy) : NULL), NULL);
 
 	return 1;
 }
--- a/src/protocols/oscar/ssi.c	Tue Jan 07 23:58:52 2003 +0000
+++ b/src/protocols/oscar/ssi.c	Wed Jan 08 01:37:11 2003 +0000
@@ -147,7 +147,7 @@
 	new->type = type;
 
 	/* Set the TLV list */
-	new->data = data;
+	new->data = aim_tlvlist_copy(data);
 
 	/* Add the item to the list in the correct numerical position.  Fancy, eh? */
 	if (*list) {
@@ -693,6 +693,7 @@
 
 	/* Add that bad boy */
 	aim_ssi_itemlist_add(&sess->ssi.local, name, parent->gid, 0xFFFF, AIM_SSI_TYPE_BUDDY, data);
+	aim_freetlvchain(&data);
 
 	/* Modify the parent group */
 	aim_ssi_itemlist_rebuildgroup(sess->ssi.local, group);
@@ -929,6 +930,7 @@
 		tmp->data = data;
 	} else {
 		tmp = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PDINFO, data);
+		aim_freetlvchain(&data);
 	}
 
 	/* Sync our local list with the server list */
@@ -961,6 +963,7 @@
 		tmp->data = data;
 	} else {
 		tmp = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PRESENCEPREFS, data);
+		aim_freetlvchain(&data);
 	}
 
 	/* Sync our local list with the server list */
@@ -1068,42 +1071,33 @@
 {
 	int ret = 0;
 	aim_rxcallback_t userfunc;
-	struct aim_ssi_item *cur, *new;
 	fu8_t fmtver; /* guess */
-	fu16_t numitems, namelen;
+	fu16_t numitems, namelen, gid, bid, type;
 	fu32_t timestamp;
+	char *name;
+	aim_tlvlist_t *data;
 
 	if (snac->flags & 0x0001) {
 		/* XXX - Free all ssi data? */
 	}
 
 	fmtver = aimbs_get8(bs); /* Version of ssi data.  Should be 0x00 */
-	numitems = aimbs_get16(bs); /* # of times ssi data has been modified */
+	numitems = aimbs_get16(bs); /* # of items in this SSI SNAC */
 	sess->ssi.numitems += numitems;
 
 	/* Read in the list */
-	/* If we already have a partial list, move cur to the end of it */
-	if (sess->ssi.official)
-		for (cur=sess->ssi.official; cur->next; cur=cur->next);
 	while (aim_bstream_empty(bs) > 4) { /* last four bytes are timestamp */
-		if (!sess->ssi.official) {
-			if (!(sess->ssi.official = malloc(sizeof(struct aim_ssi_item))))
-				return -ENOMEM;
-			cur = sess->ssi.official;
-		} else {
-			if (!(cur->next = malloc(sizeof(struct aim_ssi_item))))
-				return -ENOMEM;
-			cur = cur->next;
-		}
 		if ((namelen = aimbs_get16(bs)))
-			cur->name = aimbs_getstr(bs, namelen);
+			name = aimbs_getstr(bs, namelen);
 		else
-			cur->name = NULL;
-		cur->gid = aimbs_get16(bs);
-		cur->bid = aimbs_get16(bs);
-		cur->type = aimbs_get16(bs);
-		cur->data = aim_readtlvchain_len(bs, aimbs_get16(bs));
-		cur->next = NULL;
+			name = NULL;
+		gid = aimbs_get16(bs);
+		bid = aimbs_get16(bs);
+		type = aimbs_get16(bs);
+		data = aim_readtlvchain_len(bs, aimbs_get16(bs));
+		aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, data);
+		free(name);
+		aim_freetlvchain(&data);
 	}
 
 	/* Read in the timestamp */
@@ -1112,27 +1106,9 @@
 
 	if (!(snac->flags & 0x0001)) {
 		/* Make a copy of the list */
-		for (cur=sess->ssi.official; cur; cur=cur->next) {
-			if (!sess->ssi.local) {
-				if (!(sess->ssi.local = malloc(sizeof(struct aim_ssi_item))))
-					return -ENOMEM;
-				new = sess->ssi.local;
-			} else {
-				if (!(new->next = malloc(sizeof(struct aim_ssi_item))))
-					return -ENOMEM;
-				new = new->next;
-			}
-			if (cur->name) {
-				new->name = (char *)malloc((strlen(cur->name)+1)*sizeof(char));
-				strcpy(new->name, cur->name);
-			} else
-				new->name = NULL;
-			new->gid = cur->gid;
-			new->bid = cur->bid;
-			new->type = cur->type;
-			new->data = aim_tlvlist_copy(cur->data);
-			new->next = NULL;
-		}
+		struct aim_ssi_item *cur;
+		for (cur=sess->ssi.official; cur; cur=cur->next)
+			aim_ssi_itemlist_add(&sess->ssi.local, cur->name, cur->gid, cur->bid, cur->type, cur->data);
 
 		sess->ssi.received_data = 1;
 
@@ -1235,7 +1211,9 @@
 			data = NULL;
 
 		aim_ssi_itemlist_add(&sess->ssi.local, name, gid, bid, type, data);
-		aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, aim_tlvlist_copy(data));
+		aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, data);
+		free(name);
+		aim_freetlvchain(&data);
 
 		if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
 			ret = userfunc(sess, rx);
@@ -1301,8 +1279,8 @@
 		if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
 			ret = userfunc(sess, rx);
 
+		free(name);
 		aim_freetlvchain(&data);
-		free(name);
 	}
 
 	return ret;
@@ -1368,7 +1346,7 @@
 		if (cur->ack) {
 			/* Our action was unsuccessful, so change the local list back to how it was */
 			if (cur->action == AIM_CB_SSI_ADD) {
-				/* Remove the item from the items list */
+				/* Remove the item from the local list */
 				if (cur->item->name) {
 					cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
 					strcpy(cur->name, cur->item->name);
@@ -1377,7 +1355,7 @@
 				cur->item = NULL;
 
 			} else if (cur->action == AIM_CB_SSI_MOD) {
-				/* Replace the new item with the old item in the items list */
+				/* Replace the official item with the item in the local list */
 				struct aim_ssi_item *cur1;
 				if ((cur1 = aim_ssi_itemlist_find(sess->ssi.local, cur->item->gid, cur->item->bid))) {
 					free(cur1->name);
@@ -1391,19 +1369,15 @@
 				}
 
 			} else if (cur->action == AIM_CB_SSI_DEL) {
-				/* Add the item to the items list */
-				aim_tlvlist_t *data;
-				data = aim_tlvlist_copy(cur->item->data);
-				aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, data);
+				/* Add the item back into the local list */
+				aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
 			}
 
 		} else {
 			/* Do the exact opposite */
 			if (cur->action == AIM_CB_SSI_ADD) {
-				/* Add the item to the items list */
-				aim_tlvlist_t *data;
-				data = aim_tlvlist_copy(cur->item->data);
-				aim_ssi_itemlist_add(&sess->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, data);
+				/* Add the item to the official list */
+				aim_ssi_itemlist_add(&sess->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
 
 			} else if (cur->action == AIM_CB_SSI_MOD) {
 				/* Replace the old item with the new item in the items list */