cpw.nader.asynclogging-3: 763bc706: Made the common log's file be a get/sett..

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


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

Changelog: 

Made the common log's file be a get/settable property
Made HtmlLog and TxtLog call purple_common_log_new in their creators

Changes against parent f373ab07a2d37a3966fff0a7ac9db8e3101d6829

  patched  libpurple/commonlog.c
  patched  libpurple/commonlog.h
  patched  libpurple/htmllog.c
  patched  libpurple/txtlog.c

-------------- next part --------------
============================================================
--- libpurple/htmllog.c	cc202c8cc731b7f07a1479827e9442cb365fa06a
+++ libpurple/htmllog.c	b8852478d6e2df800c8c9011ffab0973e9c29da4
@@ -65,7 +65,7 @@ purple_html_log_new(PurpleLogChatType ty
 purple_html_log_new(PurpleLogChatType type, const gchar *name, PurpleAccount *account,
 	PurpleConversation *conv, time_t time, const struct tm *tm)
 {
-	return purple_log_new(PURPLE_TYPE_HTML_LOG, type, name, account, conv, time, tm);
+	return purple_common_log_new(PURPLE_TYPE_HTML_LOG, type, name, account, conv, time, tm);
 }
 
 static gboolean
============================================================
--- libpurple/txtlog.c	826e680cd7f4afe55dad6cdfae534f1439971174
+++ libpurple/txtlog.c	52cc34116647eccf1d5ae5341ed29c52b9ac0ef8
@@ -61,7 +61,7 @@ purple_txt_log_new(PurpleLogChatType typ
 purple_txt_log_new(PurpleLogChatType type, const gchar *name, PurpleAccount *account,
 	PurpleConversation *conv, time_t time, const struct tm *tm)
 {
-	return purple_log_new(PURPLE_TYPE_TXT_LOG, type, name, account, conv, time, tm);
+	return purple_common_log_new(PURPLE_TYPE_TXT_LOG, type, name, account, conv, time, tm);
 }
 
 static gboolean
============================================================
--- libpurple/commonlog.c	eafb2644e4d53fcf12ead236aa3b01645b82f9f6
+++ libpurple/commonlog.c	00b287b7492ecbaecc8366a61f719f3c6995604c
@@ -28,7 +28,18 @@ G_DEFINE_TYPE (PurpleCommonLog, purple_c
 #include "commonlog.h"
 
 G_DEFINE_TYPE (PurpleCommonLog, purple_common_log, PURPLE_TYPE_LOG)
+static void purple_common_log_get_property(GObject *, guint, GValue *, GParamSpec *);
+static void purple_common_log_set_property(GObject *, guint, const GValue *, GParamSpec *);
+static void purple_common_log_finalize(GObject *);
 
+enum {
+	PROP_0,
+	PROP_COMMON_LOG_FILE,
+	LAST_PROP
+};
+
+static GParamSpec *properties[LAST_PROP] = { 0 };
+
 #define PURPLE_COMMON_LOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), PURPLE_TYPE_COMMON_LOG, PurpleCommonLogPrivate))
 typedef struct _PurpleCommonLogPrivate PurpleCommonLogPrivate;
 
@@ -58,7 +69,6 @@ static gssize purple_log_common_size(Pur
 static gboolean purple_log_common_remove(PurpleLog *, GCancellable *, GError **);
 static gboolean purple_log_common_is_removable(PurpleLog *, GCancellable *, GError **);
 static gssize purple_log_common_size(PurpleLog *, GCancellable *, GError **);
-static void purple_common_log_finalize(GObject *);
 
 static void
 purple_common_log_class_init(PurpleCommonLogClass *class)
@@ -66,6 +76,10 @@ purple_common_log_class_init(PurpleCommo
 	GObjectClass *gobject_class = G_OBJECT_CLASS(class);
 	PurpleLogClass *log_class = PURPLE_LOG_CLASS(class);
 
+	gobject_class->set_property = purple_common_log_set_property;
+	gobject_class->get_property = purple_common_log_get_property;
+	gobject_class->finalize = purple_common_log_finalize;
+
 	log_class->logger_name = _("Common");
 	log_class->logger_id = "common";
 
@@ -74,7 +88,18 @@ purple_common_log_class_init(PurpleCommo
 	log_class->is_removable_fn = purple_log_common_is_removable;
 	log_class->size_fn = purple_log_common_size;
 
-	gobject_class->finalize = purple_common_log_finalize;
+	properties[PROP_COMMON_LOG_FILE] =
+		g_param_spec_object("file",
+			"File",
+			"The log's file containing its path",
+			G_TYPE_FILE,
+			G_PARAM_READWRITE);
+
+	g_object_class_install_property(gobject_class,
+		PROP_COMMON_LOG_FILE,
+		properties[PROP_COMMON_LOG_FILE]);
+
+	g_type_class_add_private(gobject_class, sizeof(PurpleCommonLogPrivate));
 }
 
 static void
@@ -86,12 +111,61 @@ PurpleLog *
 }
 
 PurpleLog *
-purple_common_log_new(PurpleLogChatType type, const gchar *name, PurpleAccount *account,
+purple_common_log_new(GType log_type, PurpleLogChatType type, const gchar *name, PurpleAccount *account,
 	PurpleConversation *conv, time_t time, const struct tm *tm)
 {
-	return purple_log_new(PURPLE_TYPE_COMMON_LOG, type, name, account, conv, time, tm);
+	return purple_log_new(log_type, type, name, account, conv, time, tm);
 }
 
+static void
+purple_common_log_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+	PurpleCommonLog *common_log = PURPLE_COMMON_LOG(object);
+
+	switch (prop_id) {
+	case PROP_COMMON_LOG_FILE:
+		purple_common_log_set_file(common_log, g_value_get_object(value));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+purple_common_log_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+	PurpleCommonLog *common_log = PURPLE_COMMON_LOG(object);
+
+	switch (prop_id) {
+	case PROP_COMMON_LOG_FILE:
+		g_value_set_object(value, purple_common_log_get_file(common_log));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+		break;
+	}
+}
+
+void
+purple_common_log_set_file(PurpleCommonLog *common_log, GFile *file)
+{
+	PurpleCommonLogPrivate *priv;
+	
+	g_return_if_fail(PURPLE_IS_COMMON_LOG(common_log));
+	g_return_if_fail(file == NULL || G_IS_FILE(file));
+
+	priv = PURPLE_COMMON_LOG_GET_PRIVATE(log);
+
+	if (priv->file != NULL)
+		g_object_unref(priv->file);
+
+	if (file != NULL)
+		g_object_ref(file);
+
+	priv->file = file;
+}
+
 GFile *
 purple_common_log_get_file(PurpleCommonLog *common_log)
 {
============================================================
--- libpurple/commonlog.h	8bf62d8086d3c374ec6603dbab347c6edc9f794d
+++ libpurple/commonlog.h	1009aa0f53e6021355170fdf4aeb921522f9ecf0
@@ -59,7 +59,7 @@ GType purple_common_log_get_type(void);
 
 GType purple_common_log_get_type(void);
 
-PurpleLog *purple_common_log_new(PurpleLogChatType chat_type, const gchar *name, PurpleAccount *account,
+PurpleLog *purple_common_log_new(GType log_type, PurpleLogChatType chat_type, const gchar *name, PurpleAccount *account,
 	PurpleConversation *conv, time_t time, const struct tm *tm);
 
 
@@ -69,6 +69,9 @@ PurpleLog *purple_common_log_new(PurpleL
 
 /*@{*/
 
+//
+void purple_common_log_set_file(PurpleCommonLog *common_log, GFile *file);
+//
 GFile *purple_common_log_get_file(PurpleCommonLog *common_log);
 
 /**


More information about the Commits mailing list