cpw.nader.asynclogging-3: c5a14fed: Got the system logs working!

morshed.nader at gmail.com morshed.nader at gmail.com
Thu Jan 13 21:05:53 EST 2011


----------------------------------------------------------------------
Revision: c5a14fed2c83244f9bb6a70a1ad5ade6dbbc2861
Parent:   561ae872a7991a61f1170583865fbfbafabcf45c
Author:   morshed.nader at gmail.com
Date:     01/13/11 14:16:28
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/c5a14fed2c83244f9bb6a70a1ad5ade6dbbc2861

Changelog: 

Got the system logs working!
Fixed up log_hash_cb

Changes against parent 561ae872a7991a61f1170583865fbfbafabcf45c

  patched  libpurple/log.c
  patched  pidgin/gtklog.c

-------------- next part --------------
============================================================
--- libpurple/log.c	bbf06ce61dd71e2e313c3b894f6f087c50a479b2
+++ libpurple/log.c	47bcfc2d0cb70cad28c6d701d2d1895cbabcf152
@@ -2456,7 +2456,6 @@ purple_logs_get_system_logs_finish(GAsyn
 {
 	GSimpleAsyncResult *simple;
 
-	g_return_val_if_fail(PURPLE_IS_LOG(log), NULL);
 	g_return_val_if_fail(G_IS_SIMPLE_ASYNC_RESULT(res), NULL);
 
 	simple = G_SIMPLE_ASYNC_RESULT(res);
@@ -2492,72 +2491,6 @@ purple_log_system_init(void)
 	purple_txt_log_system_init();
 	purple_old_log_system_init();
 
-	// G_LOCK(html_logger);
-	// html_logger = purple_log_logger_new("html", _("HTML"), 21,
-		// NULL,
-		// html_logger_write,
-		// html_logger_finalize,
-		// html_logger_list,
-		// html_logger_read,
-		// purple_log_common_sizer,
-		// html_logger_total_size,
-		// html_logger_list_syslog,
-		// NULL,
-		// purple_log_common_deleter,
-		// purple_log_common_is_removable,
-		// NULL,
-		// html_logger_write_async,
-		// NULL,
-		// html_logger_list_async,
-		// html_logger_read_async,
-		// purple_log_common_sizer_async,
-		// html_logger_total_size_async,
-		// html_logger_list_syslog_async,
-		// NULL,
-		// purple_log_common_deleter_async);
-	// purple_log_logger_add(html_logger);
-	// G_UNLOCK(html_logger);
-
-	// G_LOCK(txt_logger);
-	// txt_logger = purple_log_logger_new("txt", _("Plain text"), 21,
-		// NULL,
-		// txt_logger_write,
-		// txt_logger_finalize,
-		// txt_logger_list,
-		// txt_logger_read,
-		// purple_log_common_sizer,
-		// txt_logger_total_size,
-		// txt_logger_list_syslog,
-		// NULL,
-		// purple_log_common_deleter,
-		// purple_log_common_is_removable,
-		// NULL,
-		// txt_logger_write_async,
-		// NULL,
-		// txt_logger_list_async,
-		// txt_logger_read_async,
-		// purple_log_common_sizer_async,
-		// txt_logger_total_size_async,
-		// txt_logger_list_syslog_async,
-		// NULL,
-		// purple_log_common_deleter_async);
-	// purple_log_logger_add(txt_logger);
-	// G_UNLOCK(txt_logger);
-
-	// G_LOCK(old_logger);
-	// old_logger = purple_log_logger_new("old", _("Old flat format"), 9,
-		// NULL,
-		// NULL,
-		// old_logger_finalize,
-		// old_logger_list,
-		// old_logger_read,
-		// old_logger_size,
-		// old_logger_total_size,
-		// NULL,
-		// old_logger_get_log_sets);
-	// purple_log_logger_add(old_logger);
-	// G_UNLOCK(old_logger);
-
 	purple_signal_register(handle, "log-timestamp",
 #if SIZEOF_TIME_T == 4
 		purple_marshal_POINTER__POINTER_INT_BOOLEAN,
@@ -3077,9 +3010,20 @@ log_hash_cb(GObject *object, GAsyncResul
 log_hash_cb(GObject *object, GAsyncResult *res, gpointer userdata)
 {
 	_purple_log_sets_callback_data *callback_data = userdata;
+	PurpleLog *log = PURPLE_LOG(object);
+	GError *error = NULL;
+	GHashTable *one_set;
 
-	// g_hash_table_foreach_steal(one_set, steal_log_sets, sets);
-	// g_hash_table_destroy(one_set);
+	one_set = purple_log_get_log_sets_finish(log, res, &error);
+
+	if (one_set == NULL)
+		purple_debug_error("log", "Error getting log sets for %s: %s\n",
+			PURPLE_LOG_GET_CLASS(log)->logger_name, error->message);
+	else {
+		g_hash_table_foreach_steal(one_set, steal_log_sets, callback_data->sets);
+		g_hash_table_destroy(one_set);
+	}
+
 	callback_data->counter--;
 
 	if (callback_data->counter < 1) {
============================================================
--- pidgin/gtklog.c	ba608a1f97c946d3de8e504a8460f54b5502d16e
+++ pidgin/gtklog.c	950222a881f7915ca37ce3f65d20d5e202a49b02
@@ -1221,16 +1221,16 @@ pidgin_log_size_cb(GObject *object, GAsy
 pidgin_log_size_cb(GObject *object, GAsyncResult *res, gpointer userdata)
 {
 	_pidgin_log_data *pidgin_log_data = userdata;
-	GError *err = NULL;
+	GError *error = NULL;
 	gssize log_size;
 
-	log_size = purple_logs_get_total_size_finish(res, &err);
+	log_size = purple_logs_get_total_size_finish(res, &error);
 	pidgin_log_data->count--;
 
 	if (log_size < 0) {
-		if (err->code != G_IO_ERROR_CANCELLED)
+		if (error->code != G_IO_ERROR_CANCELLED)
 			purple_debug_error("gtklog", "Error getting total log size: %s\n",
-				err->message);
+				error->message);
 	} else if (pidgin_log_data->is_window_open) {
 		PidginLogViewerEx *lv_ex = pidgin_log_data->log_viewer;
 		gchar *sz_txt, *text;
@@ -1251,7 +1251,7 @@ pidgin_log_size_cb(GObject *object, GAsy
 		g_free(text);
 	}
 
-	g_clear_error(&err);
+	g_clear_error(&error);
 	pidgin_log_viewer_update_list_bar(pidgin_log_data);
 
 	if (pidgin_log_data->count < 1)
@@ -1262,19 +1262,19 @@ pidgin_log_list_cb(GObject *object, GAsy
 pidgin_log_list_cb(GObject *object, GAsyncResult *res, gpointer userdata)
 {
 	_pidgin_log_data *pidgin_log_data = userdata;
-	GError *err = NULL;
+	GError *error = NULL;
 	GList *list;
 
-	list = purple_logs_get_logs_finish(res, &err);
+	list = purple_logs_get_logs_finish(res, &error);
 	pidgin_log_data->count--;
 
 	if (list == NULL) {
-		if (err != NULL && err->code != G_IO_ERROR_CANCELLED)
-			purple_debug_error("gtklog", "Error getting logs: %s\n", err->message);
+		if (error != NULL && error->code != G_IO_ERROR_CANCELLED)
+			purple_debug_error("gtklog", "Error getting logs: %s\n", error->message);
 	} else if (pidgin_log_data->is_window_open)
 		append_log_viewer_logs(pidgin_log_data->log_viewer, list);
 
-	g_clear_error(&err);
+	g_clear_error(&error);
 	pidgin_log_viewer_update_search_bar(pidgin_log_data);
 
 	if (pidgin_log_data->count < 1)
@@ -1285,19 +1285,19 @@ pidgin_log_system_list_cb(GObject *objec
 pidgin_log_system_list_cb(GObject *object, GAsyncResult *res, gpointer userdata)
 {
 	_pidgin_log_data *pidgin_log_data = userdata;
-	GError *err = NULL;
+	GError *error = NULL;
 	GList *list;
 
-	list = purple_log_get_system_logs_finish(PURPLE_LOG(object), res, &err);
+	list = purple_logs_get_system_logs_finish(res, &error);
 	pidgin_log_data->count--;
 
 	if (list == NULL) {
-		if (err != NULL && err->code != G_IO_ERROR_CANCELLED)
-			purple_debug_error("gtklog", "Error getting system logs: %s\n", err->message);
+		if (error != NULL && error->code != G_IO_ERROR_CANCELLED)
+			purple_debug_error("gtklog", "Error getting system logs: %s\n", error->message);
 	} else if (pidgin_log_data->is_window_open)
 		append_log_viewer_logs(pidgin_log_data->log_viewer, list);
 
-	g_clear_error(&err);
+	g_clear_error(&error);
 	pidgin_log_viewer_update_search_bar(pidgin_log_data);
 
 	if (pidgin_log_data->count < 1)


More information about the Commits mailing list