cpw.nader.asynclogging-3: e36f0ae9: Fixed up gnthistory to work with the new...

morshed.nader at gmail.com morshed.nader at gmail.com
Fri Jan 14 00:32:05 EST 2011


----------------------------------------------------------------------
Revision: e36f0ae963381835a9ae02ae7fbcab99623df4ae
Parent:   af58ebfd8e7173fee85848af8be4f2443de1af77
Author:   morshed.nader at gmail.com
Date:     01/13/11 23:46:11
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/e36f0ae963381835a9ae02ae7fbcab99623df4ae

Changelog: 

Fixed up gnthistory to work with the new logger updates

Changes against parent af58ebfd8e7173fee85848af8be4f2443de1af77

  patched  finch/plugins/gnthistory.c

-------------- next part --------------
============================================================
--- finch/plugins/gnthistory.c	0ceb2703077587e3417212852dd423e97da2ec0b
+++ finch/plugins/gnthistory.c	3c6a3bfd2eb464947d0947e07d2708e08fbeef2b
@@ -43,7 +43,6 @@ typedef struct {
 	PurpleAccount *account;
 	PurpleConversation *conv;
 	PurpleLog *log;
-	PurpleLogReadFlags flags;
 	GCancellable *cancel;
 	const gchar *name;
 	const gchar *alias;
@@ -112,8 +111,8 @@ historize(PurpleConversation *c)
 				purple_blist_node_get_sibling_next(node) != NULL))
 			{
 				PurpleBlistNode *node2;
+				PurpleBlistNode *parent = purple_blist_node_get_parent(node);
 				PurpleBlistNode *child = purple_blist_node_get_first_child(parent);
-				PurpleBlistNode *parent = purple_blist_node_get_parent(node);
 
 				alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(node));
 
@@ -126,7 +125,7 @@ historize(PurpleConversation *c)
 
 					callback_data->count++;
 
-					purple_log_get_logs_async(PURPLE_LOG_IM, purple_buddy_get_name(buddy),
+					purple_logs_get_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);
 				}
@@ -148,7 +147,7 @@ historize(PurpleConversation *c)
 
 		callback_data->count = 1;
 
-		purple_log_get_logs_async(PURPLE_LOG_CHAT, name, account, G_PRIORITY_DEFAULT,
+		purple_logs_get_logs_async(PURPLE_LOG_CHAT, name, account, G_PRIORITY_DEFAULT,
 			callback_data->cancel, historize_log_list_cb, callback_data);
 	}
 
@@ -180,10 +179,10 @@ get_last_log(GList *list, PurpleLog *las
 
 	for( ; node; node = g_list_next(node))
 		if (purple_log_compare(last_log, node->data) > 0) {
-			purple_log_free(last_log);
+			g_object_unref(last_log);
 			last_log = node->data;
 		} else
-			purple_log_free(node->data);
+			g_object_unref(node->data);
 
 	g_list_free(list);
 
@@ -196,6 +195,7 @@ historize_log_read_cb(GObject *object, G
 	_historize_callback_data *callback_data = userdata;
 	PurpleConversation *c = callback_data->conv;
 	PurpleLog *log = callback_data->log;
+	PurpleLogReadFlags flags;
 	PurpleMessageFlags options;
 	FinchConv *fc = FINCH_CONV(callback_data->conv);
 	GntTextView *view = GNT_TEXT_VIEW(fc->tv);
@@ -203,6 +203,7 @@ historize_log_read_cb(GObject *object, G
 	GString *buffer = view->string;
 	const gchar *header_date;
 	gchar *text, *escaped_alias, *header, *full_header, *text_backup;
+	struct tm *tm;
 
 	if (res == NULL) {
 		callback_data->count--;
@@ -224,10 +225,13 @@ historize_log_read_cb(GObject *object, G
 	if (buffer->len > 0)
 		purple_conversation_write(c, "", "<hr>", options, time(NULL));
 
-	if (log->tm)
-		header_date = purple_date_format_full(log->tm);
-	else
-		header_date = purple_date_format_full(localtime(&log->time));
+	tm = purple_log_get_tm(log);
+	if (tm)
+		header_date = purple_date_format_full(tm);
+	else {
+		time_t log_time = purple_log_get_time(log);
+		header_date = purple_date_format_full(localtime(&log_time));
+	}
 
 	escaped_alias = g_markup_escape_text(callback_data->alias, -1);
 	full_header = g_strdup_printf(_("Conversation with %s on %s"), escaped_alias, header_date);
@@ -239,14 +243,14 @@ historize_log_read_cb(GObject *object, G
 	g_free(escaped_alias);
 	g_free(full_header);
 
-	text = purple_log_read_finish(log, res, &err);
+	text = purple_log_read_finish(log, res, &flags, &err);
 
 	if (text == NULL)
 		text = err->message;
 	else
 		g_strchomp(text);
 
-	if (callback_data->flags & PURPLE_LOG_READ_NO_NEWLINE)
+	if (flags & PURPLE_LOG_READ_NO_NEWLINE)
 		purple_str_strip_char(text, '\n');
 
 	purple_conversation_write(c, "", text, options, time(NULL));
@@ -283,7 +287,7 @@ historize_log_list_cb(GObject *object, G
 		return;
 	}
 
-	list = purple_log_get_logs_finish(res, &err);
+	list = purple_logs_get_logs_finish(res, &err);
 
 	if (list != NULL)
 		callback_data->log = get_last_log(list, callback_data->log);
@@ -304,9 +308,8 @@ historize_log_list_cb_done(_historize_ca
 	callback_data->count++;
 
 	if (callback_data->log != NULL)
-		purple_log_read_async(callback_data->log, &callback_data->flags,
-			G_PRIORITY_DEFAULT, callback_data->cancel, historize_log_read_cb,
-			callback_data);
+		purple_log_read_async(callback_data->log, G_PRIORITY_DEFAULT,
+			callback_data->cancel, historize_log_read_cb, callback_data);
 	else
 		historize_log_read_cb(NULL, NULL, callback_data);
 }
@@ -318,7 +321,7 @@ historize_log_collector_cb(GObject *obje
 	GList *list;
 	GError *err = NULL;
 
-	list = purple_log_get_logs_finish(res, &err);
+	list = purple_logs_get_logs_finish(res, &err);
 
 	if (list != NULL)
 		callback_data->log = get_last_log(list, callback_data->log);
@@ -339,7 +342,7 @@ historize_log_collector_cb_done(_histori
 	callback_data->count++;
 
 	if (callback_data->log == NULL)
-		purple_log_get_logs_async(PURPLE_LOG_IM, callback_data->name,
+		purple_logs_get_logs_async(PURPLE_LOG_IM, callback_data->name,
 			callback_data->account, G_PRIORITY_DEFAULT, callback_data->cancel,
 			historize_log_list_cb, callback_data);
 	else


More information about the Commits mailing list