diff src/gaimrc.c @ 774:b61607d6c2af

[gaim-migrate @ 784] save buddy chats, and better display of them (though they flash now, but they don't cause errors) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 28 Aug 2000 18:49:17 +0000
parents c7c0d2590681
children 9b8b83592bb6
line wrap: on
line diff
--- a/src/gaimrc.c	Mon Aug 28 18:25:39 2000 +0000
+++ b/src/gaimrc.c	Mon Aug 28 18:49:17 2000 +0000
@@ -148,6 +148,8 @@
 		return 3;
 	} else if (!strcmp(tag, "pounce")) {
 		return 4;
+	} else if (!strcmp(tag, "chat")) {
+		return 5;
 	}
 
 	return -1;
@@ -313,6 +315,64 @@
 	fprintf(f, "}\n");
 }
 
+static void gaimrc_read_chat(FILE *f)
+{
+	struct parse *p;
+	char buf[4096];
+	struct chat_room *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 chat_room, 1);
+
+			g_snprintf(b->name, sizeof(b->name),  "%s", p->value[0]);
+
+			b->exchange = atoi(p->value[1]);
+		
+			chat_rooms = g_list_append(chat_rooms, b);
+		}
+	}
+}
+
+static void gaimrc_write_chat(FILE *f)
+{
+	GList *pnc = chat_rooms;
+	struct chat_room *b;
+
+	fprintf(f, "chat {\n");
+
+	if (pnc)
+	{
+		while (pnc) {
+			char *str1;
+
+			b = (struct chat_room *)pnc->data;
+
+			str1 = escape_text2(b->name);
+
+			fprintf(f, "\tentry { %s } { %d }\n", str1, b->exchange);
+
+			/* escape_text2 uses malloc(), so we don't want to g_free these */
+			free(str1);
+	
+			pnc = pnc->next;
+		}
+	}
+
+	fprintf(f, "}\n");
+}
+
 #ifdef GAIM_PLUGINS
 static void gaimrc_write_plugins(FILE *f)
 {
@@ -687,6 +747,9 @@
 				case 4:
 					gaimrc_read_pounce(f);
 					break;
+				case 5:
+					gaimrc_read_chat(f);
+					break;
 				default:
 					/* NOOP */
 					break;
@@ -714,6 +777,7 @@
 			gaimrc_write_plugins(f);
 #endif
 			gaimrc_write_pounce(f);
+			gaimrc_write_chat(f);
 			fclose(f);
 			chmod(buf, S_IRUSR | S_IWUSR);
 		}