changeset 673:ddc3fd0dcd51

[gaim-migrate @ 683] Made the necessary modifications to allow gaim to save buddy pounces. I just noticed that you cant _delete_ (remove) a buddy pounce. Woops. I'll take a look at that. I'll do saving of buddy chats when I get back from dinner. Adios. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 13 Aug 2000 03:15:06 +0000
parents 84987d2e4bd4
children b68c592829a6
files ChangeLog TODO src/gaimrc.c src/prefs.c
diffstat 4 files changed, 80 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Aug 13 02:06:09 2000 +0000
+++ b/ChangeLog	Sun Aug 13 03:15:06 2000 +0000
@@ -14,6 +14,7 @@
 	* Redesigned conversation dialog
 	* Removed the Lag-O-Meter
 	* Socks 4/5 Proxy works
+	* Buddy Pounces are now saved in .gaimrc
 	
 version 0.9.20 (07/14/2000):
 	* More plugin events, more plugin features
--- a/TODO	Sun Aug 13 02:06:09 2000 +0000
+++ b/TODO	Sun Aug 13 03:15:06 2000 +0000
@@ -2,7 +2,6 @@
 	Ability to merge gaim, toc, aim2, aim4 buddylists
 	Third sound option for people without soundcards who still want
 		sound events.  Make a PC Speaker Beep (^G / Char 7)
-	Save Buddy Pounces 
 	Save Buddy Chats
 	Execute Command on Buddy Pounce
 	Hmm, fix <BODY BGCOLOR=""></BODY>  hehe. Doesnt seem to want to
@@ -14,3 +13,4 @@
 		on your buddy list.  This won't be too hard it'll just
 		take a bit of work.  Maybe we'll save this one for the
 		release after our next release.
+	Fix deletion of buddy pounces
--- a/src/gaimrc.c	Sun Aug 13 02:06:09 2000 +0000
+++ b/src/gaimrc.c	Sun Aug 13 03:15:06 2000 +0000
@@ -146,6 +146,8 @@
 		return 2;
 	} else if (!strcmp(tag, "plugins")) {
 		return 3;
+	} else if (!strcmp(tag, "pounce")) {
+		return 4;
 	}
 
 	return -1;
@@ -240,6 +242,72 @@
 	fprintf(f, "}\n");
 }
 
+static void gaimrc_read_pounce(FILE *f)
+{
+	struct parse *p;
+	char buf[4096];
+	struct buddy_pounce *b;
+
+	buf[0] = 0;
+	
+	while (buf[0] != '}')
+	{
+		if (!fgets(buf, sizeof(buf), f))
+			return;
+		
+		if (buf[0] == '}')
+			return;
+
+		p = parse_line(buf);
+		if (!strcmp(p->option, "entry"))
+		{
+			b = g_new0(struct buddy_pounce, 1);
+
+			g_snprintf(b->name, sizeof(b->name),  "%s", p->value[0]);
+			g_snprintf(b->message, sizeof(b->message), "%s", p->value[1]);
+
+			b->popup = atoi(p->value[2]);
+			b->sendim = atoi(p->value[3]);
+		
+			filter_break(b->message);
+			buddy_pounces = g_list_append(buddy_pounces, b);
+		}
+	}
+}
+
+static void gaimrc_write_pounce(FILE *f)
+{
+	GList *pnc = buddy_pounces;
+	struct buddy_pounce *b;
+
+	fprintf(f, "pounce {\n");
+
+	if (pnc)
+	{
+		while (pnc) {
+			char *str1, *str2;
+			int popup, sendim;
+
+			b = (struct buddy_pounce *)pnc->data;
+
+			str1 = escape_text2(b->name);
+			str2 = escape_text2(b->message);
+			popup = b->popup;
+			sendim = b->sendim;
+
+			fprintf(f, "\tentry { %s } { %s } { %d } { %d }\n", str1, str2, popup, sendim);
+
+			/* escape_text2 uses malloc(), so we don't want to g_free these */
+			free(str1);
+			free(str2);
+	
+			pnc = pnc->next;
+		}
+	}
+
+	fprintf(f, "}\n");
+}
+
 #ifdef GAIM_PLUGINS
 static void gaimrc_write_plugins(FILE *f)
 {
@@ -607,6 +675,9 @@
 					gaimrc_read_plugins(f);
 					break;
 #endif
+				case 4:
+					gaimrc_read_pounce(f);
+					break;
 				default:
 					/* NOOP */
 					break;
@@ -628,15 +699,15 @@
 		if ((f = fopen(buf,"w"))) {
 			fprintf(f, "# .gaimrc v%d\n", 2);
 			gaimrc_write_users(f);
-                        gaimrc_write_options(f);
-                        gaimrc_write_away(f);
+			gaimrc_write_options(f);
+			gaimrc_write_away(f);
 #ifdef GAIM_PLUGINS
 			gaimrc_write_plugins(f);
 #endif
-                        fclose(f);
-                        chmod(buf, S_IRUSR | S_IWUSR);
-                }
-                
+			gaimrc_write_pounce(f);
+			fclose(f);
+			chmod(buf, S_IRUSR | S_IWUSR);
+		}
 	}
 }
 
--- a/src/prefs.c	Sun Aug 13 02:06:09 2000 +0000
+++ b/src/prefs.c	Sun Aug 13 03:15:06 2000 +0000
@@ -1121,7 +1121,7 @@
 	aol_icon(prefs->window);
 	gtk_container_border_width(GTK_CONTAINER(prefs), 10);
 	gtk_window_set_title(GTK_WINDOW(prefs), _("Gaim - Preferences"));
-	gtk_widget_set_usize(prefs, 600, 400);
+	gtk_widget_set_usize(prefs, 600, 440);
 
 	vbox = gtk_vbox_new(FALSE, 5);
 	gtk_container_add(GTK_CONTAINER(prefs), vbox);