changeset 1051:713b0e14e0a9

[gaim-migrate @ 1061] user_info only in aim_user (saves 2k per connection); mem leak fixes in dialogs.c and multi.c; and proto_opt in aim_user (so prpls can have their own saved information per user). no way to draw protocol option selection window thingy yet, so prpls will either have to do that on their own or something. i don't know. we'll figure it out. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 02 Nov 2000 22:29:51 +0000
parents c4baa5509558
children 25f121faa75e
files plugins/oscar.c src/dialogs.c src/gaim.h src/gaimrc.c src/multi.c src/multi.h src/oscar.c src/server.c src/toc.c
diffstat 9 files changed, 42 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/oscar.c	Thu Nov 02 00:25:58 2000 +0000
+++ b/plugins/oscar.c	Thu Nov 02 22:29:51 2000 +0000
@@ -305,7 +305,6 @@
 	gc->inpa = gdk_input_add(conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
 			oscar_callback, conn);
 
-	sprintf(gc->user_info, "%s", user->user_info);
 	gc->options = user->options;
 	save_prefs(); /* is this necessary anymore? */
 
@@ -1063,7 +1062,7 @@
 		aim_bos_ackrateresp(sess, command->conn);
 		aim_bos_reqpersonalinfo(sess, command->conn);
 		aim_bos_reqlocaterights(sess, command->conn);
-		aim_bos_setprofile(sess, command->conn, gc->user_info, NULL, gaim_caps);
+		aim_bos_setprofile(sess, command->conn, gc->user->user_info, NULL, gaim_caps);
 		aim_bos_reqbuddyrights(sess, command->conn);
 
 		account_online(gc->user, gc); /* this is an awkward hack */
@@ -1189,7 +1188,7 @@
 
 static void oscar_set_away(struct gaim_connection *g, char *message) {
 	struct oscar_data *odata = (struct oscar_data *)g->proto_data;
-	aim_bos_setprofile(odata->sess, odata->conn, g->user_info, message, gaim_caps);
+	aim_bos_setprofile(odata->sess, odata->conn, g->user->user_info, message, gaim_caps);
 }
 
 static void oscar_warn(struct gaim_connection *g, char *name, int anon) {
--- a/src/dialogs.c	Thu Nov 02 00:25:58 2000 +0000
+++ b/src/dialogs.c	Thu Nov 02 22:29:51 2000 +0000
@@ -1150,7 +1150,6 @@
 		save_prefs();
 
 		if (gc) {
-			g_snprintf(gc->user_info, sizeof(gc->user_info), "%s", junk);
 			buf = g_malloc(strlen(junk) * 4);
 			if (!buf) {
 				buf = g_malloc(1);
@@ -1637,13 +1636,16 @@
 /*  The dialog for the info requests                                      */
 /*------------------------------------------------------------------------*/
 
+static void info_dlg_free(GtkWidget *b, struct info_dlg *d) {
+	g_free(d);
+}
+
 void g_show_info_text(char *info)
 {
         GtkWidget *ok;
         GtkWidget *label;
 	GtkWidget *text;
         GtkWidget *bbox;
-        GtkWidget *button_box;
         GtkWidget *sw;
 
         struct info_dlg *b = g_new0(struct info_dlg, 1);
@@ -1654,11 +1656,12 @@
         gtk_container_border_width(GTK_CONTAINER(b->window), 5);
         bbox = gtk_vbox_new(FALSE, 5);
 	gtk_container_add(GTK_CONTAINER(b->window), bbox);
-		button_box = gtk_hbox_new(FALSE, 5);
 		gtk_widget_realize(GTK_WIDGET(b->window));
         ok = picture_button(b->window, _("OK"), ok_xpm);
 	gtk_signal_connect(GTK_OBJECT(b->window), "destroy",
 			   GTK_SIGNAL_FUNC(destroy_dialog), b->window);
+	gtk_signal_connect(GTK_OBJECT(b->window), "destroy",
+			   GTK_SIGNAL_FUNC(info_dlg_free), b);
         gtk_signal_connect(GTK_OBJECT(ok), "clicked",
 			   GTK_SIGNAL_FUNC(destroy_dialog), b->window);
 
@@ -1682,7 +1685,6 @@
 	gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
 	gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
-/*	gtk_box_pack_start(GTK_BOX(button_box), ok, FALSE, FALSE, 0);*/
 
 	aol_icon(b->window->window);
 	gtk_widget_show_all(b->window);
--- a/src/gaim.h	Thu Nov 02 00:25:58 2000 +0000
+++ b/src/gaim.h	Thu Nov 02 22:29:51 2000 +0000
@@ -132,6 +132,9 @@
 	char user_info[2048];
 	int options;
 	int protocol;
+	/* prpls can use this to save information about the user,
+	 * like which server to connect to, etc */
+	char proto_opt[6][256];
 
 	struct gaim_connection *gc;
 
--- a/src/gaimrc.c	Thu Nov 02 00:25:58 2000 +0000
+++ b/src/gaimrc.c	Thu Nov 02 22:29:51 2000 +0000
@@ -428,6 +428,7 @@
 {
         struct parse *p;
         struct aim_user *u;
+	int i;
         char buf[4096];
 
         if (!fgets(buf, sizeof(buf), f))
@@ -482,6 +483,20 @@
 	u->options = atoi(p->value[0]);
 	u->protocol = atoi(p->value[1]);
 
+	if (!fgets(buf, sizeof(buf), f))
+		return u;
+
+	if (!strcmp(buf, "\t}"))
+		return u;
+
+	p = parse_line(buf);
+
+	if (strcmp(p->option, "proto_opts"))
+		return u;
+
+	for (i = 0; i < 6; i++)
+		g_snprintf(u->proto_opt[i], sizeof u->proto_opt[i], "%s", p->value[i]);
+
         return u;
         
 }
@@ -489,7 +504,7 @@
 static void gaimrc_write_user(FILE *f, struct aim_user *u)
 {
         char *c;
-        int nl = 1;;
+        int nl = 1, i;
 	if (u->options & OPT_USR_REM_PASS)
 	        fprintf(f, "\t\tident { %s } { %s }\n", u->username, u->password);
 	else
@@ -513,7 +528,10 @@
         }
         fprintf(f, "\n\t\t}\n");
 	fprintf(f, "\t\tuser_opts { %d } { %d }\n", u->options, u->protocol);
-        
+        fprintf(f, "\t\tproto_opts");
+	for (i = 0; i < 6; i++)
+		fprintf(f, " { %s }", u->proto_opt[i]);
+	fprintf(f, "\n");
 }
 
 
--- a/src/multi.c	Thu Nov 02 00:25:58 2000 +0000
+++ b/src/multi.c	Thu Nov 02 22:29:51 2000 +0000
@@ -173,6 +173,10 @@
 	}
 }
 
+static void free_muo(GtkWidget *b, struct mod_usr_opt *m) {
+	g_free(m);
+}
+
 static GtkWidget *acct_button(const char *text, struct aim_user *u, int option, GtkWidget *box)
 {
 	GtkWidget *button;
@@ -186,6 +190,7 @@
 	gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
 	muo->user = u; muo->opt = option;
 	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(mod_opt), muo);
+	gtk_signal_connect(GTK_OBJECT(button), "destroy", GTK_SIGNAL_FUNC(free_muo), muo);
 	gtk_widget_show(button);
 	return button;
 }
--- a/src/multi.h	Thu Nov 02 00:25:58 2000 +0000
+++ b/src/multi.h	Thu Nov 02 22:29:51 2000 +0000
@@ -53,7 +53,6 @@
 
 	char username[64];
 	char password[32];
-	char user_info[2048];
 	char g_screenname[64];
 	int options; /* same as aim_user options */
 	int keepalive;
--- a/src/oscar.c	Thu Nov 02 00:25:58 2000 +0000
+++ b/src/oscar.c	Thu Nov 02 22:29:51 2000 +0000
@@ -309,7 +309,6 @@
 	gc->inpa = gdk_input_add(conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
 			oscar_callback, conn);
 
-	sprintf(gc->user_info, "%s", user->user_info);
 	gc->options = user->options;
 	save_prefs(); /* is this necessary anymore? */
 
@@ -1067,7 +1066,7 @@
 		aim_bos_ackrateresp(sess, command->conn);
 		aim_bos_reqpersonalinfo(sess, command->conn);
 		aim_bos_reqlocaterights(sess, command->conn);
-		aim_bos_setprofile(sess, command->conn, gc->user_info, NULL, gaim_caps);
+		aim_bos_setprofile(sess, command->conn, gc->user->user_info, NULL, gaim_caps);
 		aim_bos_reqbuddyrights(sess, command->conn);
 
 		account_online(gc->user, gc); /* this is an awkward hack */
@@ -1193,7 +1192,7 @@
 
 static void oscar_set_away(struct gaim_connection *g, char *message) {
 	struct oscar_data *odata = (struct oscar_data *)g->proto_data;
-	aim_bos_setprofile(odata->sess, odata->conn, g->user_info, message, gaim_caps);
+	aim_bos_setprofile(odata->sess, odata->conn, g->user->user_info, message, gaim_caps);
 }
 
 static void oscar_warn(struct gaim_connection *g, char *name, int anon) {
--- a/src/server.c	Thu Nov 02 00:25:58 2000 +0000
+++ b/src/server.c	Thu Nov 02 22:29:51 2000 +0000
@@ -87,9 +87,9 @@
 {
         char *buf;
 
-	if (strlen(gc->user_info)) {
-		buf = g_malloc(strlen(gc->user_info) * 4);
-		strcpy(buf, gc->user_info);
+	if (strlen(gc->user->user_info)) {
+		buf = g_malloc(strlen(gc->user->user_info) * 4);
+		strcpy(buf, gc->user->user_info);
 		serv_set_info(gc, buf);
 		g_free(buf);
 	}
--- a/src/toc.c	Thu Nov 02 00:25:58 2000 +0000
+++ b/src/toc.c	Thu Nov 02 22:29:51 2000 +0000
@@ -46,7 +46,7 @@
 #include "pixmaps/dt_icon.xpm"
 #include "pixmaps/free_icon.xpm"
 
-#define REVISION "gaim:$Revision: 1048 $"
+#define REVISION "gaim:$Revision: 1061 $"
 
 struct toc_data {
 	int toc_fd;
@@ -133,7 +133,6 @@
 		return;
 	}
 
-	sprintf(gc->user_info, "%s", user->user_info);
 	gc->options = user->options;
 	save_prefs();