cpw.nader.asynclogging-3: cc0ba487: Fixed the function calls in gntlog.c to ...

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


----------------------------------------------------------------------
Revision: cc0ba487ce7b3202eb374ccaee9fe66ef0c76a01
Parent:   40ef73f875299a8b9391b33f227ea97de3e86b89
Author:   morshed.nader at gmail.com
Date:     01/03/12 18:16:40
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/cc0ba487ce7b3202eb374ccaee9fe66ef0c76a01

Changelog: 

Fixed the function calls in gntlog.c to use the updated logger functions names
Fixed SIMPLE_ASYNC_RESULT_FROM_NEW_ERROR to allow for optional extra arguments to the formatting message
Fixed a few crashes due to dereferencing null pointers and freeing memory twice

Changes against parent 40ef73f875299a8b9391b33f227ea97de3e86b89

  patched  finch/gntlog.c
  patched  libpurple/commonlog.c

-------------- next part --------------
============================================================
--- finch/gntlog.c	04c12f16325217b28e7a529a9170e041b5aaccad
+++ finch/gntlog.c	bdabee070f2a152c3aa52913e5f2a5fd69d088e4
@@ -638,7 +638,7 @@ finch_log_list_cb(GObject *object, GAsyn
 	GError *error = NULL;
 	GList *list;
 
-	list = purple_logs_get_logs_finish(res, &error);
+	list = purple_logs_list_logs_finish(res, &error);
 	finch_log_data->count--;
 
 	if (list == NULL) {
@@ -664,7 +664,7 @@ finch_log_system_list_cb(GObject *object
 	GError *error = NULL;
 	GList *list;
 
-	list = purple_logs_get_system_logs_finish(res, &error);
+	list = purple_logs_list_system_logs_finish(res, &error);
 	finch_log_data->count--;
 
 	if (list == NULL) {
@@ -715,7 +715,7 @@ finch_log_sets_cb(GObject *object, GAsyn
 
 				finch_log_data->count = (finch_log_data->total += 2);
 
-				purple_logs_get_logs_async(PURPLE_LOG_IM, set->name,
+				purple_logs_list_logs_async(PURPLE_LOG_IM, set->name,
 					set->account, G_PRIORITY_DEFAULT, cancel,
 					finch_log_list_cb, finch_log_data);
 				purple_logs_get_total_size_async(PURPLE_LOG_IM, set->name,
@@ -804,7 +804,7 @@ finch_log_show(PurpleLogChatType chat_ty
 	if (username != NULL) {
 		finch_log_data->count = finch_log_data->total = 2;
 
-		purple_logs_get_logs_async(chat_type, username, account,
+		purple_logs_list_logs_async(chat_type, username, account,
 			G_PRIORITY_DEFAULT, cancel, finch_log_list_cb, finch_log_data);
 		purple_logs_get_total_size_async(chat_type, username, account,
 			G_PRIORITY_DEFAULT, cancel, finch_log_size_cb, finch_log_data);
@@ -897,7 +897,7 @@ finch_log_show_contact(PurpleContact *co
 		name = purple_buddy_get_name(PURPLE_BUDDY(child));
 		account = purple_buddy_get_account(PURPLE_BUDDY(child));
 
-		purple_logs_get_logs_async(PURPLE_LOG_IM, name, account,
+		purple_logs_list_logs_async(PURPLE_LOG_IM, name, account,
 			G_PRIORITY_DEFAULT, cancel, finch_log_list_cb, finch_log_data);
 		purple_logs_get_total_size_async(PURPLE_LOG_IM, name, account,
 			G_PRIORITY_DEFAULT, cancel, finch_log_size_cb, finch_log_data);
@@ -953,7 +953,7 @@ finch_syslog_show(void)
 		finch_log_data->count++;
 		finch_log_data->total++;
 
-		purple_logs_get_system_logs_async(account, G_PRIORITY_DEFAULT,
+		purple_logs_list_system_logs_async(account, G_PRIORITY_DEFAULT,
 			cancel, finch_log_system_list_cb, finch_log_data);
 	}
 
============================================================
--- libpurple/commonlog.c	f21d99ffe9bfdf92611b0d6f95618b0cba7754a8
+++ libpurple/commonlog.c	4b3bcbebeb6f95ad47eb1b73d2163675b0587562
@@ -60,11 +60,11 @@
 		g_object_unref(simple); \
 	}
 
-#define SIMPLE_ASYNC_RESULT_FROM_NEW_ERROR(obj, cb, data, domain, code, msg) \
+#define SIMPLE_ASYNC_RESULT_FROM_NEW_ERROR(obj, cb, data, domain, code, format, ...) \
 	{ \
 		GSimpleAsyncResult *simple; \
 		simple = g_simple_async_result_new_error(G_OBJECT(obj), cb, data, \
-			domain, code, msg); \
+			domain, code, format, ##__VA_ARGS__); \
 		g_simple_async_result_complete_in_idle(simple); \
 		g_object_unref(simple); \
 	}
@@ -586,7 +586,7 @@ purple_common_log_create_async(PurpleLog
 			SIMPLE_ASYNC_RESULT_FROM_NEW_ERROR(log, cb, userdata,
 				G_IO_ERROR,
 				g_file_error_from_errno(errno),
-				g_strerror(errno));
+				"%s", g_strerror(errno));
 
 			return;
 		}
@@ -636,7 +636,7 @@ purple_common_log_create_async_2(gpointe
 			callback_data->cb, callback_data->userdata,
 			G_IO_ERROR,
 			g_file_error_from_errno(errno),
-			g_strerror(errno));
+			"%s", g_strerror(errno));
 
 		return FALSE;
 	}
@@ -764,7 +764,7 @@ purple_common_log_read_async_2(GIOChanne
 				data->userdata,
 				G_IO_ERROR,
 				g_file_error_from_errno(errno),
-				g_strerror(errno));
+				"%s", g_strerror(errno));
 
 			return FALSE;
 		}
@@ -962,6 +962,7 @@ purple_common_log_list_async(PurpleLogCh
 	data->cancel = g_object_ref(cancellable);
 	data->cb = cb;
 	data->userdata = userdata;
+	data->logs = NULL;
 
 	path = purple_log_get_log_dir(chat_type, name, account);
 	dir = g_file_new_for_path(path);
@@ -1021,6 +1022,8 @@ purple_common_log_list_async_3(GObject *
 		/* Out of files! Close shop */
 		g_file_enumerator_close_async(enumerator, data->io_priority,
 			data->cancel, purple_common_log_list_async_4, data);
+
+		return;
 	}
 
 	dir = g_file_get_path(g_file_enumerator_get_container(enumerator));
@@ -1033,7 +1036,7 @@ purple_common_log_list_async_3(GObject *
 		filename = g_file_info_get_attribute_byte_string(info,
 			G_FILE_ATTRIBUTE_STANDARD_NAME);
 		g_object_unref(info);
-		printf("%s", filename);
+		printf("%s\n", filename);
 
 		if (!purple_str_has_suffix(filename, data->ext))
 			continue;
@@ -1254,6 +1257,7 @@ purple_common_log_total_size_async_3(GOb
 		if (err != NULL) {
 			SIMPLE_ASYNC_RESULT_FROM_ERROR(enumerator, data->cb, data->userdata,
 				err);
+			printf("data: %p, %p\n", data, data->name);
 			total_size_callback_data_free(data);
 
 			return;
@@ -1262,6 +1266,8 @@ purple_common_log_total_size_async_3(GOb
 		/* Out of files! Close shop */
 		g_file_enumerator_close_async(enumerator, data->io_priority,
 			data->cancel, purple_common_log_total_size_async_4, data);
+
+		return;
 	}
 
 	for (file = files; file != NULL; file = file->next) {


More information about the Commits mailing list