cpw.nader.asynclogging-3: c8ab97b3: Made PurpleOldLog extend PurpleCommonLog

morshed.nader at gmail.com morshed.nader at gmail.com
Thu Jan 13 01:25:53 EST 2011


----------------------------------------------------------------------
Revision: c8ab97b3849dbd87e18bc4fd0aa5653d179bc615
Parent:   763bc70661c55a1bfa1b5fd057b3a3b50add5023
Author:   morshed.nader at gmail.com
Date:     01/12/11 14:41:08
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/c8ab97b3849dbd87e18bc4fd0aa5653d179bc615

Changelog: 

Made PurpleOldLog extend PurpleCommonLog

Changes against parent 763bc70661c55a1bfa1b5fd057b3a3b50add5023

  patched  libpurple/oldlog.c
  patched  libpurple/oldlog.h

-------------- next part --------------
============================================================
--- libpurple/oldlog.c	4a3424d189aa7a778a422f79e72b293a7401844e
+++ libpurple/oldlog.c	77895cd5a8fbf1e038366371aceb54599a48668d
@@ -29,13 +29,12 @@
 #include "debug.h"
 #include "stringref.h"
 
-G_DEFINE_TYPE (PurpleOldLog, purple_old_log, PURPLE_TYPE_LOG)
+G_DEFINE_TYPE (PurpleOldLog, purple_old_log, PURPLE_TYPE_COMMON_LOG)
 
 #define PURPLE_OLD_LOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), PURPLE_TYPE_OLD_LOG, PurpleOldLogPrivate))
 typedef struct _PurpleOldLogPrivate PurpleOldLogPrivate;
 
 struct _PurpleOldLogPrivate {
-	GFile *file;
 	gssize offset;
 	gssize length;
 };
@@ -45,7 +44,6 @@ static GHashTable *purple_old_log_get_lo
 static gchar *purple_old_log_read(PurpleLog *, PurpleLogReadFlags *, GCancellable *, GError **);
 static gssize purple_old_log_size(PurpleLog *, GCancellable *, GError **);
 static GHashTable *purple_old_log_get_log_sets(PurpleLog *, GCancellable *, GError **);
-static void purple_old_log_finalize(GObject *);
 
 
 /* The old logger doesn't write logs, only reads them.  This is to include
@@ -67,8 +65,6 @@ purple_old_log_class_init(PurpleOldLogCl
 	log_class->total_size_fn = purple_old_log_total_size;
 	log_class->get_log_sets_fn = purple_old_log_get_log_sets;
 
-	gobject_class->finalize = purple_old_log_finalize;
-
 	g_type_class_add_private(gobject_class, sizeof(PurpleOldLogPrivate));
 }
 
@@ -81,7 +77,7 @@ purple_old_log_new(PurpleLogChatType typ
 purple_old_log_new(PurpleLogChatType type, const gchar *name, PurpleAccount *account,
 	PurpleConversation *conv, time_t time, const struct tm *tm)
 {
-	return purple_log_new(PURPLE_TYPE_OLD_LOG, type, name, account, conv, time, tm);
+	return purple_common_log_new(PURPLE_TYPE_OLD_LOG, type, name, account, conv, time, tm);
 }
 
 // Needs testing!!!
@@ -177,7 +173,7 @@ purple_old_log_list(PurpleLog *log, Purp
 						sn, account, NULL, idx_time, NULL);
 
 					priv = PURPLE_OLD_LOG_GET_PRIVATE(log);
-					priv->file = g_object_ref(file);
+					purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
 					priv->offset = lastoff;
 					priv->length = newlen;
 
@@ -278,7 +274,7 @@ purple_old_log_list(PurpleLog *log, Purp
 						account, NULL, lasttime, NULL);
 					PurpleOldLogPrivate *priv = PURPLE_OLD_LOG_GET_PRIVATE(log);
 
-					priv->file = g_object_ref(file);
+					purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
 					priv->offset = lastoff;
 					priv->length = newlen;
 
@@ -337,7 +333,7 @@ purple_old_log_list(PurpleLog *log, Purp
 				account, NULL, lasttime, NULL);
 			PurpleOldLogPrivate *priv = PURPLE_OLD_LOG_GET_PRIVATE(log);
 
-			priv->file = g_object_ref(file);
+			purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
 			priv->offset = lastoff;
 			priv->length = newlen;
 
@@ -414,12 +410,14 @@ purple_old_log_read(PurpleLog *log, Purp
 purple_old_log_read(PurpleLog *log, PurpleLogReadFlags *flags, GCancellable *cancellable, GError **error)
 {
 	PurpleOldLogPrivate *priv = PURPLE_OLD_LOG_GET_PRIVATE(log);
+	GFile *file;
 	GFileInputStream *file_stream;
 	GInputStream *stream;
 	gchar *read;
 	gssize result;
 
-	file_stream = g_file_read(priv->file, cancellable, error);
+	file = purple_common_log_get_file(PURPLE_COMMON_LOG(log));
+	file_stream = g_file_read(file, cancellable, error);
 
 	if (file_stream == NULL)
 		return NULL;
@@ -580,17 +578,6 @@ purple_old_log_get_log_sets(PurpleLog *l
 	return sets;
 }
 
-static void
-purple_old_log_finalize(GObject *object)
-{
-	PurpleLog *log = PURPLE_LOG(object);
-	PurpleOldLogPrivate *priv = PURPLE_OLD_LOG_GET_PRIVATE(log);
-
-	g_object_unref(priv->file);
-
-	G_OBJECT_CLASS(purple_old_log_parent_class)->finalize(object);
-}
-
 void
 purple_old_log_system_init(void)
 {
============================================================
--- libpurple/oldlog.h	e6bd78ef0a4c48035707ef9d0a82529459e32954
+++ libpurple/oldlog.h	c8fad548bf6ae53aa548698245fb5b6cc3842535
@@ -30,7 +30,7 @@
 
 #include <glib-object.h>
 
-#include "log.h"
+#include "commonlog.h"
 
 G_BEGIN_DECLS
 
@@ -45,11 +45,11 @@ struct _PurpleOldLog {
 typedef struct _PurpleOldLogClass   PurpleOldLogClass;
 
 struct _PurpleOldLog {
-	PurpleLog parent_instance;
+	PurpleCommonLog parent_instance;
 };
 
 struct _PurpleOldLogClass {
-	PurpleLogClass parent_class;
+	PurpleCommonLogClass parent_class;
 
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);


More information about the Commits mailing list