changeset 1437:1f0660a2c893

[gaim-migrate @ 1447] i'm in a fucking bad mood committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 28 Jan 2001 23:11:57 +0000
parents f6a9bd50fd19
children 7688db14c6dc
files src/conversation.c src/gaim.h src/prefs.c src/server.c
diffstat 4 files changed, 56 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Sun Jan 28 09:34:22 2001 +0000
+++ b/src/conversation.c	Sun Jan 28 23:11:57 2001 +0000
@@ -114,8 +114,12 @@
 
 		fd = open_log_file(c->name);
 		if (fd > 0) {
-			fprintf(fd, "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n",
+			if (!(general_options & OPT_GEN_STRIP_HTML))
+				fprintf(fd,
+					"<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n",
 					full_date());
+			else
+				fprintf(fd, " ---- New Conversation @ %s ----\n", full_date());
 			fclose(fd);
 		} else
 			/* do we want to do something here? */ ;
@@ -814,7 +818,7 @@
 	g_free(s);
 }
 
-static char *html_logize(char *p)
+static char *add_br(char *p)
 {
 
 	char *temp_p = p;
@@ -825,7 +829,7 @@
 
 	while (*temp_p != '\0') {
 		char_len++;
-		if ((*temp_p == '\n') || ((*temp_p == '<') && (*(temp_p + 1) == '!')))
+		if (*temp_p == '\n')
 			num_cr++;
 		++temp_p;
 	}
@@ -835,19 +839,15 @@
 	buffer_start = buffer_p;
 
 	while (*temp_p != '\0') {
+		*buffer_p = *temp_p;
 		if (*temp_p == '\n') {
 			*buffer_p++ = '<';
 			*buffer_p++ = 'B';
 			*buffer_p++ = 'R';
 			*buffer_p++ = '>';
-			*buffer_p++ = '\n';
-		} else if ((*temp_p == '<') && (*(temp_p + 1) == '!')) {
-			*buffer_p++ = '&';
-			*buffer_p++ = 'g';
-			*buffer_p++ = 't';
-			*buffer_p++ = ';';
-		} else
-			*buffer_p++ = *temp_p;
+			*buffer_p = '\n';
+		}
+		++buffer_p;
 		++temp_p;
 	}
 	*buffer_p = '\0';
@@ -1161,17 +1161,30 @@
 		gtk_imhtml_append_text(GTK_IMHTML(c->text), "<BR>", 0);
 
 		if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) {
+			char *t1;
 			char nm[256];
 
+			if (general_options & OPT_GEN_STRIP_HTML) {
+				t1 = strip_html(what);
+			} else {
+				t1 = what;
+			}
 			if (c->is_chat)
 				g_snprintf(nm, 256, "%s.chat", c->name);
 			else
 				g_snprintf(nm, 256, "%s", c->name);
 			fd = open_log_file(nm);
 			if (fd > 0) {
-				fprintf(fd, "%s<BR>\n", what);
+				if (general_options & OPT_GEN_STRIP_HTML) {
+					fprintf(fd, "%s\n", t1);
+				} else {
+					fprintf(fd, "%s<BR>\n", t1);
+				}
 				fclose(fd);
 			}
+			if (general_options & OPT_GEN_STRIP_HTML) {
+				g_free(t1);
+			}
 		}
 
 	} else {
@@ -1211,8 +1224,11 @@
 			}
 		}
 
-		g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><FONT SIZE=\"2\"><!--(%s) --></FONT>"
-				"<B>%s</B></FONT> ", colour, date(), str);
+		if (general_options & OPT_DISP_SHOW_TIME)
+			g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><FONT SIZE=\"2\">(%s) </FONT>"
+					"<B>%s</B></FONT> ", colour, date(), str);
+		else
+			g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s</B></FONT> ", colour, str);
 
 		g_free(str);
 
@@ -1223,20 +1239,32 @@
 		gtk_imhtml_append_text(GTK_IMHTML(c->text), "<BR>", 0);
 
 		if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) {
-			char *t1;
-			char nm[256];
+			char *t1, *t2;
+			char *nm = g_malloc(256);
 			if (c->is_chat)
 				g_snprintf(nm, 256, "%s.chat", c->name);
 			else
 				g_snprintf(nm, 256, "%s", c->name);
 
-			t1 = html_logize(what);
+			if (general_options & OPT_GEN_STRIP_HTML) {
+				t1 = strip_html(buf);
+				t2 = strip_html(what);
+			} else {
+				t1 = add_br(buf);
+				t2 = add_br(what);
+			}
 			fd = open_log_file(nm);
 			if (fd > 0) {
-				fprintf(fd, "%s%s<BR>\n", buf, t1);
+				if (general_options & OPT_GEN_STRIP_HTML) {
+					fprintf(fd, "%s%s\n", t1, t2);
+				} else {
+					fprintf(fd, "%s%s<BR>\n", t1, t2);
+				}
 				fclose(fd);
 			}
 			g_free(t1);
+			g_free(t2);
+			g_free(nm);
 		}
 	}
 
--- a/src/gaim.h	Sun Jan 28 09:34:22 2001 +0000
+++ b/src/gaim.h	Sun Jan 28 23:11:57 2001 +0000
@@ -440,7 +440,7 @@
 #define OPT_GEN_ENTER_SENDS       0x00000001
 /* #define OPT_GEN_AUTO_LOGIN        0x00000002 now OPT_USR_AUTO */
 #define OPT_GEN_LOG_ALL           0x00000004
-/* #define OPT_GEN_STRIP_HTML        0x00000008 this didn't work anyway */
+#define OPT_GEN_STRIP_HTML        0x00000008
 #define OPT_GEN_APP_BUDDY_SHOW    0x00000010
 #define OPT_GEN_POPUP_WINDOWS     0x00000020
 #define OPT_GEN_SEND_LINKS        0x00000040
--- a/src/prefs.c	Sun Jan 28 09:34:22 2001 +0000
+++ b/src/prefs.c	Sun Jan 28 23:11:57 2001 +0000
@@ -260,6 +260,7 @@
 	gtk_widget_show(sep);
 
 	gaim_button(_("Log all conversations"), &general_options, OPT_GEN_LOG_ALL, box);
+	gaim_button(_("Strip HTML from logs"), &general_options, OPT_GEN_STRIP_HTML, box);
 
 	sep = gtk_hseparator_new();
 	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
--- a/src/server.c	Sun Jan 28 09:34:22 2001 +0000
+++ b/src/server.c	Sun Jan 28 23:11:57 2001 +0000
@@ -646,11 +646,14 @@
 		g_snprintf(filename, 100, "%s.chat", b->name);
 
 		fd = open_log_file(filename);
-		if (fd > 0) {
-			fprintf(fd, "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n",
-					full_date());
-			fclose(fd);
-		}
+		if (!(general_options & OPT_GEN_STRIP_HTML))
+			fprintf(fd,
+				"<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n",
+				full_date());
+		else
+			fprintf(fd, "---- New Conversation @ %s ----\n", full_date());
+
+		fclose(fd);
 		free(filename);
 	}