cpw.nader.asynclogging-3: dc9d7efb: Fixed the gnthistory plugin to refer to ...

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


----------------------------------------------------------------------
Revision: dc9d7efb0950c171dec59fce17466335fc564f30
Parent:   b804c64d4ebf9a800b10ae3521b514fc207e5d32
Author:   morshed.nader at gmail.com
Date:     01/04/12 20:26:30
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/dc9d7efb0950c171dec59fce17466335fc564f30

Changelog: 

Fixed the gnthistory plugin to refer to updated function names
Fixed commonlog.c's list functions to not give broken file system paths!
Fixed PurpleHtmlLogPrivate not being properly activated/added
Corrected log_list_cb trying to turn a null pointer into a purplelog

Changes against parent b804c64d4ebf9a800b10ae3521b514fc207e5d32

  patched  finch/plugins/gnthistory.c
  patched  libpurple/commonlog.c
  patched  libpurple/htmllog.c
  patched  libpurple/log.c

-------------- next part --------------
============================================================
--- libpurple/log.c	7d9812819b0ff31a67f5b4fc73285279c81ec7e6
+++ libpurple/log.c	eefff1f79e8aaf2ab538f0ff41fdd24071ec14b8
@@ -2056,7 +2056,6 @@ log_list_cb(GObject *object, GAsyncResul
 log_list_cb(GObject *object, GAsyncResult *res, gpointer userdata)
 {
 	_list_logs_callback_data *callback_data = userdata;
-	PurpleLog *log = PURPLE_LOG(object);
 	GError *error = NULL;
 	GList *list;
 
@@ -2068,8 +2067,8 @@ log_list_cb(GObject *object, GAsyncResul
 
 	if (list == NULL) {
 		if (error != NULL && error->code != G_IO_ERROR_NOT_SUPPORTED)
-			purple_debug_error("log", "Error listing %s logs: %s\n",
-				PURPLE_LOG_GET_CLASS(log)->logger_name, error->message);
+			purple_debug_error("log", "Error listing logs: %s\n",
+				error->message);
 	} else
 		callback_data->logs = g_list_concat(callback_data->logs, list);
 
============================================================
--- finch/plugins/gnthistory.c	3e57b7a27125d6f961eec7de28957613027b5dd6
+++ finch/plugins/gnthistory.c	82d82cc5645f9596923258411b10fbf7f001a872
@@ -125,7 +125,7 @@ historize(PurpleConversation *c)
 
 					callback_data->count++;
 
-					purple_logs_get_logs_async(PURPLE_LOG_IM, purple_buddy_get_name(buddy),
+					purple_logs_list_logs_async(PURPLE_LOG_IM, purple_buddy_get_name(buddy),
 						purple_buddy_get_account(buddy), G_PRIORITY_DEFAULT,
 						callback_data->cancel, historize_log_collector_cb, callback_data);
 				}
@@ -147,7 +147,7 @@ historize(PurpleConversation *c)
 
 		callback_data->count = 1;
 
-		purple_logs_get_logs_async(PURPLE_LOG_CHAT, name, account, G_PRIORITY_DEFAULT,
+		purple_logs_list_logs_async(PURPLE_LOG_CHAT, name, account, G_PRIORITY_DEFAULT,
 			callback_data->cancel, historize_log_list_cb, callback_data);
 	}
 
@@ -288,7 +288,7 @@ historize_log_list_cb(GObject *object, G
 		return;
 	}
 
-	list = purple_logs_get_logs_finish(res, &err);
+	list = purple_logs_list_logs_finish(res, &err);
 
 	if (list != NULL)
 		callback_data->log = get_last_log(list, callback_data->log);
@@ -322,7 +322,7 @@ historize_log_collector_cb(GObject *obje
 	GList *list;
 	GError *err = NULL;
 
-	list = purple_logs_get_logs_finish(res, &err);
+	list = purple_logs_list_logs_finish(res, &err);
 
 	if (list != NULL)
 		callback_data->log = get_last_log(list, callback_data->log);
@@ -343,7 +343,7 @@ historize_log_collector_cb_done(_histori
 	callback_data->count++;
 
 	if (callback_data->log == NULL)
-		purple_logs_get_logs_async(PURPLE_LOG_IM, callback_data->name,
+		purple_logs_list_logs_async(PURPLE_LOG_IM, callback_data->name,
 			callback_data->account, G_PRIORITY_DEFAULT, callback_data->cancel,
 			historize_log_list_cb, callback_data);
 	else
============================================================
--- libpurple/htmllog.c	511d8b879d506230f4e12cf306c441b570fa2ed0
+++ libpurple/htmllog.c	0bc89e7a100b7205950db27af802779464707b57
@@ -848,6 +848,8 @@ purple_html_log_class_init(PurpleHtmlLog
 	log_class->list_syslog_async = purple_html_log_list_syslog_async;
 
 	gobject_class->finalize = purple_html_log_finalize;
+
+	g_type_class_add_private(gobject_class, sizeof(PurpleHtmlLogPrivate));
 }
 
 static void
============================================================
--- libpurple/commonlog.c	f18ec5466f9c01327e0c62892f98edb20aef8033
+++ libpurple/commonlog.c	9e2fcdd20d88955984b169d8b625fedd234a7696
@@ -129,6 +129,7 @@ typedef struct {
 	GAsyncReadyCallback cb;
 	gpointer userdata;
 	GList *logs;
+	GFile *dir;
 } list_callback_data;
 
 typedef struct {
@@ -199,6 +200,7 @@ list_callback_data_free(gpointer userdat
 	g_free(data->name);
 	g_free(data->ext);
 	g_object_unref(data->cancel);
+	g_object_unref(data->dir);
 	g_free(data);
 }
 
@@ -947,7 +949,6 @@ purple_common_log_list_async(PurpleLogCh
 	gint io_priority, GCancellable *cancellable, GAsyncReadyCallback cb,
 	gpointer userdata)
 {
-	GFile *dir;
 	gchar *path;
 	list_callback_data *data;
 
@@ -964,14 +965,13 @@ purple_common_log_list_async(PurpleLogCh
 	data->logs = NULL;
 
 	path = purple_log_get_log_dir(chat_type, name, account);
-	dir = g_file_new_for_path(path);
+	data->dir = g_file_new_for_path(path);
 
-	g_file_enumerate_children_async(dir, G_FILE_ATTRIBUTE_STANDARD_NAME,
+	g_file_enumerate_children_async(data->dir, G_FILE_ATTRIBUTE_STANDARD_NAME,
 		G_FILE_QUERY_INFO_NONE, io_priority, cancellable,
 		purple_common_log_list_async_2, data);
 
 	g_free(path);
-	g_object_unref(dir);
 }
 
 static void
@@ -979,14 +979,13 @@ purple_common_log_list_async_2(GObject *
 	gpointer userdata)
 {
 	GError *err = NULL;
-	GFile *dir = G_FILE(object);
 	GFileEnumerator *enumerator;
 	list_callback_data *data = userdata;
 
-	enumerator = g_file_enumerate_children_finish(dir, res, &err);
+	enumerator = g_file_enumerate_children_finish(data->dir, res, &err);
 
 	if (enumerator == NULL) {
-		SIMPLE_ASYNC_RESULT_FROM_ERROR(dir, data->cb, data->userdata, err);
+		SIMPLE_ASYNC_RESULT_FROM_ERROR(data->dir, data->cb, data->userdata, err);
 		list_callback_data_free(data);
 
 		return;
@@ -1002,13 +1001,13 @@ purple_common_log_list_async_3(GObject *
 {
 	GError *err = NULL;
 	GFileEnumerator *enumerator = G_FILE_ENUMERATOR(object);
-	GList *files, *file;
-	gchar *dir;
+	GList *file_infos, *file;
+	gchar *dir_path;
 	list_callback_data *data = userdata;
 
-	files = g_file_enumerator_next_files_finish(enumerator, res, &err);
+	file_infos = g_file_enumerator_next_files_finish(enumerator, res, &err);
 
-	if (files == NULL) {
+	if (file_infos == NULL) {
 		if (err != NULL) {
 			SIMPLE_ASYNC_RESULT_FROM_ERROR(enumerator, data->cb, data->userdata,
 				err);
@@ -1025,27 +1024,33 @@ purple_common_log_list_async_3(GObject *
 		return;
 	}
 
-	dir = g_file_get_path(g_file_enumerator_get_container(enumerator));
+	dir_path = g_file_get_path(data->dir);
 
-	for (file = files; file != NULL; file = file->next) {
+	for (file = file_infos; file != NULL; file = file->next) {
 		GFileInfo *info = file->data;
+		GFile *child_file;
 		PurpleLog *log;
-		const gchar *filename;
+		gchar *child_path;
 
-		filename = g_file_info_get_attribute_byte_string(info,
-			G_FILE_ATTRIBUTE_STANDARD_NAME);
-		g_object_unref(info);
-		printf("%s\n", filename);
+		child_file = g_file_get_child(data->dir, g_file_info_get_name(info));
+		child_path = g_file_get_path(child_file);
+		g_object_unref(child_file);
 
-		if (!purple_str_has_suffix(filename, data->ext))
+		if (!purple_str_has_suffix(child_path, data->ext)) {
+			g_free(child_path);
 			continue;
+		}
 
-		log = create_log(dir, filename, data->chat_type, data->name,
+		log = create_log(dir_path, child_path, data->chat_type, data->name,
 			data->account, data->klass);
+
+		g_free(child_path);
 		data->logs = g_list_prepend(data->logs, log);
 	}
 
-	g_list_free(files);
+	g_list_foreach(file_infos, (GFunc) g_object_unref, NULL);
+	g_list_free(file_infos);
+	g_free(dir_path);
 
 	g_file_enumerator_next_files_async(enumerator, 20, data->io_priority,
 		data->cancel, purple_common_log_list_async_3, data);
@@ -1067,7 +1072,8 @@ purple_common_log_list_async_4(GObject *
 			err);
 
 		purple_log_list_free(data->logs);
-	} else
+	else
+		/* Everything went fine, notify the user of the logs */
 		SIMPLE_ASYNC_RESULT_NEW_GOOD(enumerator, data->cb, data->userdata,
 			purple_common_log_list_async,
 			g_simple_async_result_set_op_res_gpointer(simple, data->logs,
@@ -1154,7 +1160,7 @@ purple_common_log_total_size(PurpleLogCh
 			GFile *file;
 			GFileInfo *info;
 			gchar *tmp = g_build_filename(path, filename, NULL);
-			guint64 file_size;
+			goffset file_size;
 
 			file = g_file_new_for_path(tmp);
 			info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
@@ -1169,8 +1175,9 @@ purple_common_log_total_size(PurpleLogCh
 				return -1;
 			}
 
-			file_size = g_file_info_get_attribute_uint64(info,
-				G_FILE_ATTRIBUTE_STANDARD_SIZE);
+			file_size = g_file_info_get_size(info);
+			g_assert(size >= 0);
+
 			size += file_size;
 
 			purple_debug_info("commonlog", "file size for %s: %" G_GUINT64_FORMAT "\n", tmp, file_size);
@@ -1271,13 +1278,12 @@ purple_common_log_total_size_async_3(GOb
 	for (file = files; file != NULL; file = file->next) {
 		GFileInfo *info = file->data;
 		const gchar *path;
-		guint64 size;
+		goffset size;
 
-		path = g_file_info_get_attribute_string(info,
-			G_FILE_ATTRIBUTE_STANDARD_NAME);
+		path = g_file_info_get_name(info);
+		size = g_file_info_get_size(info);
+		g_assert(size >= 0);
 
-		size = g_file_info_get_attribute_uint64(info,
-			G_FILE_ATTRIBUTE_STANDARD_SIZE);
 		g_object_unref(info);
 
 		if (!purple_str_has_suffix(path, data->ext))


More information about the Commits mailing list