cpw.nader.asynclogging-3: cd83e0af: Got rid of xmllog.[hc]

morshed.nader at gmail.com morshed.nader at gmail.com
Thu May 12 03:41:38 EDT 2011


----------------------------------------------------------------------
Revision: cd83e0af9773f39d0cf16554fa694f232541e299
Parent:   2d986a4ffbc6b4c4c33e865bc75dff903479e48b
Author:   morshed.nader at gmail.com
Date:     05/12/11 03:22:31
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/cd83e0af9773f39d0cf16554fa694f232541e299

Changelog: 

Got rid of xmllog.[hc]
Fixed a warning caused by looking up logs from someone whom had not been chatted with
Little more code cleanup

Changes against parent 2d986a4ffbc6b4c4c33e865bc75dff903479e48b

  dropped  libpurple/xmllog.c
  dropped  libpurple/xmllog.h
  patched  libpurple/commonlog.c

-------------- next part --------------
============================================================
--- libpurple/xmllog.c	c44388ba6b4d07929fe5e59ff5a574fa4c9d6d2d
+++ /dev/null	
@@ -1,111 +0,0 @@
-#if 0 /* Maybe some other time. */
-/****************
- ** XML LOGGER **
- ****************/
-
-static const gchar *
-str_from_msg_type (PurpleMessageFlags type)
-{
-	return "";
-}
-
-static void
-xml_logger_write(PurpleLog *log, PurpleMessageFlags type, const gchar *from, time_t time,
-	const gchar *message)
-{
-	gchar *xhtml = NULL;
-
-	if (!log->logger_data) {
-		/* This log is new.  We could use the loggers 'new' function, but
-		 * 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.
-		 */
-		struct tm *tm;
-		const gchar *tz;
-		const gchar *date;
-		gchar *dir = purple_log_get_log_dir(log->type, log->name, log->account);
-		gchar *name;
-		gchar *filename;
-
-		if (dir == NULL)
-			return;
-
-		tm = localtime(&log->time);
-		tz = purple_escape_filename(purple_utf8_strftime("%Z", tm);
-		date = purple_utf8_strftime("%Y-%m-%d.%H%M%S%z", tm);
-
-		name = g_strdup_printf("%s%s%s", date, tz, ext ? ext : "");
-
-		purple_build_dir (dir, S_IRUSR | S_IWUSR | S_IXUSR);
-
-		filename = g_build_filename(dir, name, NULL);
-		g_free(dir);
-		g_free(name);
-
-		log->logger_data = g_fopen(filename, "a");
-		if (!log->logger_data) {
-			purple_debug(PURPLE_DEBUG_ERROR, "log", "Could not create log file %s\n", filename);
-			g_free(filename);
-			return;
-		}
-		g_free(filename);
-		fprintf(log->logger_data, "<?xml version='1.0' encoding='UTF-8' ?>\n"
-			"<?xml-stylesheet href='file:///usr/src/web/htdocs/log-stylesheet.xsl' type='text/xml' ?>\n");
-
-		date = purple_utf8_strftime("%Y-%m-%d %H:%M:%S", localtime(&log->time));
-		fprintf(log->logger_data, "<conversation time='%s' screenname='%s' protocol='%s'>\n",
-			date, log->name, prpl);
-	}
-
-	/* if we can't write to the file, give up before we hurt ourselves */
-	if(!data->file)
-		return;
-
-	date = log_get_timestamp(log, time);
-
-	purple_markup_html_to_xhtml(message, &xhtml, NULL);
-	if (from)
-		fprintf(log->logger_data, "<message %s %s from='%s' time='%s'>%s</message>\n",
-			str_from_msg_type(type),
-			type & PURPLE_MESSAGE_SEND ? "direction='sent'" :
-			type & PURPLE_MESSAGE_RECV ? "direction='received'" : "",
-			from, date, xhtml);
-	else
-		fprintf(log->logger_data, "<message %s %s time='%s'>%s</message>\n",
-			str_from_msg_type(type),
-			type & PURPLE_MESSAGE_SEND ? "direction='sent'" :
-			type & PURPLE_MESSAGE_RECV ? "direction='received'" : "",
-			date, xhtml):
-	fflush(log->logger_data);
-	g_free(date);
-	g_free(xhtml);
-}
-
- static void
- xml_logger_finalize(PurpleLog *log)
-{
-	if (log->logger_data) {
-		fprintf(log->logger_data, "</conversation>\n");
-		fclose(log->logger_data);
-		log->logger_data = NULL;
-	}
-}
-
-static GList *
-xml_logger_list(PurpleLogType type, const gchar *sn, PurpleAccount *account)
-{
-	return purple_log_common_lister(type, sn, account, ".xml", &xml_logger);
-}
-
-static PurpleLogLogger xml_logger =  {
-	N_("XML"), "xml",
-	NULL,
-	xml_logger_write,
-	xml_logger_finalize,
-	xml_logger_list,
-	NULL,
-	NULL,
-	NULL
-};
-#endif
-
============================================================
--- libpurple/xmllog.h	da39a3ee5e6b4b0d3255bfef95601890afd80709
+++ /dev/null	
============================================================
--- libpurple/commonlog.c	11e5a5d7ff09bf9ca30b165c205c5ee81ee21096
+++ libpurple/commonlog.c	127a4ffd03707f5b36e49c273f0e29e1b54879ab
@@ -416,6 +416,7 @@ purple_log_common_lister(PurpleLogChatTy
 	GCancellable *cancellable, GError **error)
 {
 	GDir *dir;
+	GError *err = NULL;
 	GList *list = NULL;
 	const gchar *filename;
 	gchar *path;
@@ -437,13 +438,21 @@ purple_log_common_lister(PurpleLogChatTy
 		return NULL;
 	}
 
-	dir = g_dir_open(path, 0, error);
+	dir = g_dir_open(path, 0, &err);
 
 	if (dir == NULL) {
+		if (err->code == G_FILE_ERROR_NOENT)
+			g_clear_error(&err);
+		else
+			g_propagate_error(error, err);
+
 		g_free(path);
+
 		return NULL;
 	}
 
+	g_clear_error(&err);
+
 	while ((filename = g_dir_read_name(dir)) != NULL) {
 		if (g_cancellable_set_error_if_cancelled(cancellable, error)) {
 			g_dir_close(dir);
@@ -468,8 +477,10 @@ purple_log_common_lister(PurpleLogChatTy
 			stamp = purple_str_to_time(purple_unescape_filename(filename),
 				FALSE, &tm, &tz_off, &rest);
 
-			/* As zero is a valid offset, PURPLE_NO_TZ_OFF means no offset was
-			 * provided. See util.h. Yes, it's kinda ugly. */
+			/**
+			 * As zero is a valid offset, PURPLE_NO_TZ_OFF means no offset was
+			 * provided. See util.h. Yes, it's kinda ugly.
+			 */
 			if (tz_off != PURPLE_NO_TZ_OFF)
 				tm.tm_gmtoff = tz_off - tm.tm_gmtoff;
 
@@ -543,7 +554,7 @@ purple_log_common_lister_async(PurpleLog
 	GSimpleAsyncResult *simple;
 
 	g_return_if_fail(name != NULL);
-	g_return_if_fail(account != NULL); // PURPLE_IS_ACCOUNT(account)
+	g_return_if_fail(account != NULL); /* XXX: PURPLE_IS_ACCOUNT(account) */
 	g_return_if_fail(ext != NULL);
 
 	callback_data = g_new0(_common_thread_callback_data, 1);


More information about the Commits mailing list