cpw.nader.asynclogging-3: 68e6abf0: Html logs now only write the footer if t...

morshed.nader at gmail.com morshed.nader at gmail.com
Thu Jan 5 15:27:06 EST 2012


----------------------------------------------------------------------
Revision: 68e6abf0efaee89c0c5a9becd8df159c3fe66d93
Parent:   a00ce9d7b71101b558da80f60ade0b625ff5e009
Author:   morshed.nader at gmail.com
Date:     01/04/12 11:40:20
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/68e6abf0efaee89c0c5a9becd8df159c3fe66d93

Changelog: 

Html logs now only write the footer if the file has already been touched/written to

Changes against parent a00ce9d7b71101b558da80f60ade0b625ff5e009

  patched  libpurple/htmllog.c

-------------- next part --------------
============================================================
--- libpurple/htmllog.c	5cf4776cc696e07f01d72ae7739e471e9b517653
+++ libpurple/htmllog.c	85203933b24b4fb04bb8053a4c56f60e8a99d90b
@@ -89,7 +89,15 @@ G_DEFINE_TYPE (PurpleHtmlLog, purple_htm
 
 G_DEFINE_TYPE (PurpleHtmlLog, purple_html_log, PURPLE_TYPE_COMMON_LOG)
 
+#define PURPLE_HTML_LOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+	PURPLE_TYPE_HTML_LOG, PurpleHtmlLogPrivate))
+typedef struct _PurpleHtmlLogPrivate PurpleHtmlLogPrivate;
 
+struct _PurpleHtmlLogPrivate {
+	gboolean created;
+};
+
+
 /* XXX: Move the extension in CommonLog somehow to reduce duplicate code here/txt
  * and make things more configurable for future loggers? */
 static gboolean
@@ -224,12 +232,15 @@ purple_html_log_write(PurpleLog *log, Pu
 		 * creating a new file there would result in empty files in the case
 		 * that you open a convo with someone, but don't say anything.
 		 */
+		PurpleHtmlLogPrivate *priv = PURPLE_HTML_LOG_GET_PRIVATE(log);
+
 		/* XXX: Should we be doing this? */
 		if (!purple_html_log_create(log, cancellable, error))
 			return -1;
 
 		path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
 		write_header = TRUE;
+		priv->created = TRUE;
 	} else
 		write_header = FALSE;
 
@@ -438,6 +449,7 @@ purple_html_log_write_async_2(PurpleLog 
 
 	if (res != NULL) {
 		GError *error = NULL;
+		PurpleHtmlLogPrivate *priv = PURPLE_HTML_LOG_GET_PRIVATE(log);
 
 		if (!purple_html_log_create_finish(log, res, &error)) {
 			simple = g_simple_async_result_new_from_error(G_OBJECT(log),
@@ -452,6 +464,7 @@ purple_html_log_write_async_2(PurpleLog 
 
 		g_clear_error(&error);
 		data->write_header = TRUE;
+		priv->created = TRUE;
 	}
 
 	path = purple_common_log_get_path(PURPLE_COMMON_LOG(log));
@@ -806,8 +819,11 @@ purple_html_log_finalize(GObject *object
 static void
 purple_html_log_finalize(GObject *object)
 {
-	/* XXX: Conditionally do this? */
-	write_footer(PURPLE_COMMON_LOG(object), "</body></html>\n");
+	PurpleHtmlLogPrivate *priv = PURPLE_HTML_LOG_GET_PRIVATE(object);
+
+	if (priv->created)
+		write_footer(PURPLE_COMMON_LOG(object), "</body></html>\n");
+
 	G_OBJECT_CLASS(purple_html_log_parent_class)->finalize(object);
 }
 
@@ -837,6 +853,8 @@ purple_html_log_init(PurpleHtmlLog *html
 static void
 purple_html_log_init(PurpleHtmlLog *html_log)
 {
+	PurpleHtmlLogPrivate *priv = PURPLE_HTML_LOG_GET_PRIVATE(html_log);
+	priv->created = FALSE;
 }
 
 void


More information about the Commits mailing list