cpw.nader.asynclogging-3: 0cf27327: Fixed most of the runtime errors/errors ..

morshed.nader at gmail.com morshed.nader at gmail.com
Thu Jan 13 02:56:49 EST 2011


----------------------------------------------------------------------
Revision: 0cf27327f4872967e10dd88cf5d2b3d2df052cdd
Parent:   48ad39d4edb4f40d65f618bf26bebfd50a0ac527
Author:   morshed.nader at gmail.com
Date:     01/13/11 02:53:00
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/0cf27327f4872967e10dd88cf5d2b3d2df052cdd

Changelog: 

Fixed most of the runtime errors/errors being logged
Made purple_log_common_total_sizer return -1 on error (Was 0 in a certain place)
Made the windows launching code properly handle combined flags (i.e. -ndm)

Changes against parent 48ad39d4edb4f40d65f618bf26bebfd50a0ac527

  patched  libpurple/commonlog.c
  patched  libpurple/log.c
  patched  pidgin/gtklog.c
  patched  pidgin/win32/winpidgin.c

-------------- next part --------------
============================================================
--- libpurple/log.c	c0aff6a06fad778099f59dd4d58806e52ab0a61e
+++ libpurple/log.c	df48dfad29d4263a23920969bd2be27d621ade4d
@@ -60,8 +60,8 @@ enum {
 	PROP_LOG_CHAT_TYPE,
 	PROP_LOG_NAME,
 	PROP_LOG_ACCOUNT,
+	PROP_LOG_CONV,
 	PROP_LOG_TIME,
-	PROP_LOG_CONV,
 	PROP_LOG_TM,
 	LAST_PROP
 };
@@ -72,12 +72,12 @@ struct _PurpleLogPrivate {
 typedef struct _PurpleLogPrivate PurpleLogPrivate;
 
 struct _PurpleLogPrivate {
-	PurpleLogChatType chat_type;  /**< The type of log this is */
-	gchar *name;                  /**< The name of this log */
-	PurpleAccount *account;       /**< The account this log is taking place on */
-	time_t time;                  /**< The time this conversation started, converted to the local timezone */
-	PurpleConversation *conv;     /**< The conversation being logged */
-	struct tm *tm;                /**< The time this conversation started */
+	PurpleLogChatType chat_type;       /**< The type of log this is */
+	gchar *name;                       /**< The name of this log */
+	PurpleAccount *account;            /**< The account this log is taking place on */
+	time_t time;                       /**< The time this conversation started, converted to the local timezone */
+	PurpleConversation *conversation;  /**< The conversation being logged */
+	struct tm *tm;                     /**< The time this conversation started */
 };
 
 typedef struct {
@@ -216,8 +216,8 @@ purple_log_chat_type_get_type(void)
 	if (G_UNLIKELY(etype == 0)) {
 		static const GEnumValue values[] = {
             { PURPLE_LOG_IM, "PURPLE_LOG_IM", "Purple Log IM" },
-            { PURPLE_LOG_IM, "PURPLE_LOG_CHAT", "Purple Log Chat" },
-            { PURPLE_LOG_IM, "PURPLE_LOG_SYSTEM", "Purple Log System" },
+            { PURPLE_LOG_CHAT, "PURPLE_LOG_CHAT", "Purple Log Chat" },
+            { PURPLE_LOG_SYSTEM, "PURPLE_LOG_SYSTEM", "Purple Log System" },
             { 0, NULL, NULL }
         };
 
@@ -297,14 +297,14 @@ purple_log_class_init(PurpleLogClass *cl
 			"The chat type of the log",
 			PURPLE_TYPE_LOG_CHAT_TYPE,
 			PURPLE_LOG_SYSTEM,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE);
+			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
 	properties[PROP_LOG_NAME] =
 		g_param_spec_string("name",
 			"Name",
 			"The name of the conversation (buddy name, chat name, etc.)",
 			"",
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE);
+			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
 	properties[PROP_LOG_ACCOUNT] =
 		//Ideally should be g_param_spec_object
@@ -312,8 +312,16 @@ purple_log_class_init(PurpleLogClass *cl
 			"Account",
 			"The account the conversation is occurring on",
 //			PURPLE_TYPE_ACCOUNT,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE);
+			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
+	properties[PROP_LOG_CONV] =
+		//Ideally should be g_param_spec_object
+		g_param_spec_pointer("conversation",
+			"Conversation",
+			"The conversation being logged",
+//			PURPLE_TYPE_CONVERSATION,
+			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
 	properties[PROP_LOG_TIME] =
 		g_param_spec_long("time",
 			"Time",
@@ -321,22 +329,14 @@ purple_log_class_init(PurpleLogClass *cl
 			0,
 			G_MAXLONG,
 			0,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE);
+			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
-	properties[PROP_LOG_CONV] =
-		//Ideally should be g_param_spec_object
-		g_param_spec_pointer("conv",
-			"Conversation",
-			"The conversation being logged",
-//			PURPLE_TYPE_CONVERSATION,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE);
-
 	properties[PROP_LOG_TM] =
 		g_param_spec_boxed("tm",
 			"Time (tm)",
 			"The time this conversation started",
 			PURPLE_TYPE_STRUCT_TM,
-			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE);
+			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
 	g_object_class_install_property(gobject_class,
 		PROP_LOG_CHAT_TYPE,
@@ -351,12 +351,12 @@ purple_log_class_init(PurpleLogClass *cl
 		properties[PROP_LOG_ACCOUNT]);
 
 	g_object_class_install_property(gobject_class,
-		PROP_LOG_TIME,
-		properties[PROP_LOG_TIME]);
+		PROP_LOG_CONV,
+		properties[PROP_LOG_CONV]);
 
 	g_object_class_install_property(gobject_class,
-		PROP_LOG_CONV,
-		properties[PROP_LOG_CONV]);
+		PROP_LOG_TIME,
+		properties[PROP_LOG_TIME]);
 
 	g_object_class_install_property(gobject_class,
 		PROP_LOG_TM,
@@ -374,52 +374,84 @@ purple_log_init(PurpleLog *log)
 	priv->name = NULL;
 	priv->account = NULL;
 	priv->time = 0;
-	priv->conv = NULL;
+	priv->conversation = NULL;
 	//These needed?
 	priv->tm = NULL;
 }
 
 static void
-purple_log_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+purple_log_set_chat_type(PurpleLog *log, PurpleLogChatType chat_type)
 {
-	// PurpleLog *log = PURPLE_LOG(object);
+	g_return_if_fail(PURPLE_IS_LOG(log));
 
-	switch (prop_id) {
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-		break;
-	}
+	PURPLE_LOG_GET_PRIVATE(log)->chat_type = chat_type;
 }
 
 static void
-purple_log_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+purple_log_set_name(PurpleLog *log, const gchar *name)
 {
-	PurpleLog *log = PURPLE_LOG(object);
+	g_return_if_fail(PURPLE_IS_LOG(log));
+	g_return_if_fail(name != NULL);
 
-	switch (prop_id) {
-	case PROP_LOG_CHAT_TYPE:
-		g_value_set_enum(value, purple_log_get_chat_type(log));
-		break;
-	case PROP_LOG_NAME:
-		g_value_set_string(value, purple_log_get_name(log));
-		break;
-	case PROP_LOG_ACCOUNT:
-		//g_value_set_object
-		g_value_set_pointer(value, purple_log_get_account(log));
-		break;
-	case PROP_LOG_TIME:
-		g_value_set_long(value, purple_log_get_time(log));
-		break;
-	case PROP_LOG_CONV:
-		//g_value_set_object
-		g_value_set_pointer(value, purple_log_get_conversation(log));
-		break;
-	case PROP_LOG_TM:
-		g_value_set_boxed(value, purple_log_get_tm(log));
-		break;
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-		break;
+	PURPLE_LOG_GET_PRIVATE(log)->name = g_strdup(name);
+}
+
+static void
+purple_log_set_account(PurpleLog *log, PurpleAccount *account)
+{
+	g_return_if_fail(PURPLE_IS_LOG(log));
+	/* Account can be NULL when we create our dummy logs */
+	// g_return_if_fail(account == NULL || PURPLE_IS_ACCOUNT(account));
+
+	PURPLE_LOG_GET_PRIVATE(log)->account = account; // g_object_ref
+}
+
+static void
+purple_log_set_conversation(PurpleLog *log, PurpleConversation *conversation)
+{
+	g_return_if_fail(PURPLE_IS_LOG(log));
+	// g_return_if_fail(conversation == NULL || PURPLE_IS_CONVERSATION(conversation));
+
+	PURPLE_LOG_GET_PRIVATE(log)->conversation = conversation; // g_object_ref
+}
+
+static void
+purple_log_set_time(PurpleLog *log, time_t log_time)
+{
+	g_return_if_fail(PURPLE_IS_LOG(log));
+
+	PURPLE_LOG_GET_PRIVATE(log)->time = log_time;
+}
+
+static void
+purple_log_set_tm(PurpleLog *log, struct tm *tm)
+{
+	PurpleLogPrivate *priv;
+
+	g_return_if_fail(PURPLE_IS_LOG(log));
+
+	priv = PURPLE_LOG_GET_PRIVATE(log);
+
+	if (tm == NULL)
+		priv->tm = NULL;
+	else {
+		/* There's no need to zero this as we immediately do a direct copy. */
+		priv->tm = g_slice_new(struct tm);
+
+		*(priv->tm) = *tm;
+
+#ifdef HAVE_STRUCT_TM_TM_ZONE
+		/* XXX: This is so wrong... */
+		if (priv->tm->tm_zone != NULL) {
+			gchar *tmp = g_locale_from_utf8(priv->tm->tm_zone, -1, NULL, NULL, NULL);
+
+			if (tmp != NULL)
+				priv->tm->tm_zone = tmp;
+			else
+				/* Just shove the UTF-8 bytes in and hope... */
+				priv->tm->tm_zone = g_strdup(priv->tm->tm_zone);
+		}
+#endif
 	}
 }
 
@@ -447,6 +479,14 @@ purple_log_get_account(const PurpleLog *
 	return PURPLE_LOG_GET_PRIVATE(log)->account;
 }
 
+PurpleConversation *
+purple_log_get_conversation(const PurpleLog *log)
+{
+	g_return_val_if_fail(PURPLE_IS_LOG(log), NULL);
+
+	return PURPLE_LOG_GET_PRIVATE(log)->conversation;
+}
+
 time_t
 purple_log_get_time(const PurpleLog *log)
 {
@@ -455,23 +495,79 @@ purple_log_get_time(const PurpleLog *log
 	return PURPLE_LOG_GET_PRIVATE(log)->time;
 }
 
-PurpleConversation *
-purple_log_get_conversation(const PurpleLog *log)
+G_CONST_RETURN struct tm *
+purple_log_get_tm(const PurpleLog *log)
 {
 	g_return_val_if_fail(PURPLE_IS_LOG(log), NULL);
 
-	return PURPLE_LOG_GET_PRIVATE(log)->conv;
+	return PURPLE_LOG_GET_PRIVATE(log)->tm;
 }
 
-G_CONST_RETURN struct tm *
-purple_log_get_tm(const PurpleLog *log)
+static void
+purple_log_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
-	g_return_val_if_fail(PURPLE_IS_LOG(log), NULL);
+	PurpleLog *log = PURPLE_LOG(object);
 
-	return PURPLE_LOG_GET_PRIVATE(log)->tm;
+	switch (prop_id) {
+	case PROP_LOG_CHAT_TYPE:
+		purple_log_set_chat_type(log, g_value_get_enum(value));
+		break;
+	case PROP_LOG_NAME:
+		purple_log_set_name(log, g_value_get_string(value));
+		break;
+	case PROP_LOG_ACCOUNT:
+		//g_value_get_object
+		purple_log_set_account(log, g_value_get_pointer(value));
+		break;
+	case PROP_LOG_CONV:
+		//g_value_get_object
+		purple_log_set_conversation(log, g_value_get_pointer(value));
+		break;
+	case PROP_LOG_TIME:
+		purple_log_set_time(log, g_value_get_long(value));
+		break;
+	case PROP_LOG_TM:
+		purple_log_set_tm(log, g_value_get_boxed(value));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+		break;
+	}
 }
 
 static void
+purple_log_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+	PurpleLog *log = PURPLE_LOG(object);
+
+	switch (prop_id) {
+	case PROP_LOG_CHAT_TYPE:
+		g_value_set_enum(value, purple_log_get_chat_type(log));
+		break;
+	case PROP_LOG_NAME:
+		g_value_set_string(value, purple_log_get_name(log));
+		break;
+	case PROP_LOG_ACCOUNT:
+		//g_value_set_object
+		g_value_set_pointer(value, purple_log_get_account(log));
+		break;
+	case PROP_LOG_TIME:
+		g_value_set_long(value, purple_log_get_time(log));
+		break;
+	case PROP_LOG_CONV:
+		//g_value_set_object
+		g_value_set_pointer(value, purple_log_get_conversation(log));
+		break;
+	case PROP_LOG_TM:
+		g_value_set_boxed(value, purple_log_get_tm(log));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
 thread_callback_data_free(gpointer userdata)
 {
 	_thread_callback_data *callback_data = userdata;
@@ -516,35 +612,13 @@ purple_log_new(GType log_type, PurpleLog
 		"chat-type", chat_type,
 		"name", g_strdup(purple_normalize(account, name)),
 		"account", account,
-		"conv", conv,
+		"conversation", conv,
 		"time", time,
 		"tm", tm,
 		NULL);
 
 	PURPLE_DBUS_REGISTER_POINTER(log, PurpleLog);
 
-	// if (tm == NULL)
-		// log->tm = NULL;
-	// else {
-		// /* There's no need to zero this as we immediately do a direct copy. */
-		// log->tm = g_slice_new(struct tm);
-
-		// *(log->tm) = *tm;
-
-// #ifdef HAVE_STRUCT_TM_TM_ZONE
-		// /* XXX: This is so wrong... */
-		// if (log->tm->tm_zone != NULL) {
-			// gchar *tmp = g_locale_from_utf8(log->tm->tm_zone, -1, NULL, NULL, NULL);
-
-			// if (tmp != NULL)
-				// log->tm->tm_zone = tmp;
-			// else
-				// /* Just shove the UTF-8 bytes in and hope... */
-				// log->tm->tm_zone = g_strdup(log->tm->tm_zone);
-		// }
-// #endif
-	// }
-
 	// TODO: Non-blocking create?
 	// if (log->logger->create)
 		// (log->logger->create_fn)(log);
@@ -2986,6 +3060,8 @@ log_hash_cb(GObject *object, GAsyncResul
 {
 	_purple_log_sets_callback_data *callback_data = userdata;
 
+	// g_hash_table_foreach_steal(one_set, steal_log_sets, sets);
+	// g_hash_table_destroy(one_set);
 	callback_data->counter--;
 
 	if (callback_data->counter < 1) {
============================================================
--- pidgin/gtklog.c	b40a2dda2726bdcb9c0fb71dd995c55840c23256
+++ pidgin/gtklog.c	ba608a1f97c946d3de8e504a8460f54b5502d16e
@@ -1067,10 +1067,6 @@ insert_log_viewer_log(PidginLogViewerEx 
 	struct tm *tm;
 	time_t log_time;
 
-	//g_return_if_fail(PURPLE_IS_LOG(log));
-	purple_debug_info("gtklog", "%u's refcount: %u", log, G_OBJECT(log)->ref_count);
-	return;
-
 	store = lv_ex->lv->treestore;
 	model = GTK_TREE_MODEL(store);
 	log_tm = purple_log_get_tm(log);
============================================================
--- pidgin/win32/winpidgin.c	b17aad9cc2ed8bfa7566c950fcd9fd38c18bd0fa
+++ pidgin/win32/winpidgin.c	311ac5dd549efd89b221d8325ed7ebeaa306641b
@@ -632,11 +632,11 @@ WinMain (struct HINSTANCE__ *hInstance, 
 			} else {
 				if (strchr(__argv[i], 'd'))
 					debug = TRUE;
-				else if (strchr(__argv[i], 'h'))
+				if (strchr(__argv[i], 'h'))
 					help = TRUE;
-				else if (strchr(__argv[i], 'v'))
+				if (strchr(__argv[i], 'v'))
 					version = TRUE;
-				else if (strchr(__argv[i], 'm'))
+				if (strchr(__argv[i], 'm'))
 					multiple = TRUE;
 			}
 		}
============================================================
--- libpurple/commonlog.c	e7ef5189abf96d7aa89078df2ca85ce28de6748b
+++ libpurple/commonlog.c	6e74339ca37dfd791ff6362042bfed42c62871c4
@@ -601,9 +601,9 @@ purple_log_common_total_sizer(PurpleLogC
 	gssize size = 0;//, total;
 	// gpointer ptrsize;
 
-	g_return_val_if_fail(name != NULL, 0);
-	g_return_val_if_fail(account != NULL, 0);
-	g_return_val_if_fail(ext != NULL, 0);
+	g_return_val_if_fail(name != NULL, -1);
+	g_return_val_if_fail(account != NULL, -1);
+	g_return_val_if_fail(ext != NULL, -1);
 
 	path = purple_log_get_log_dir(chat_type, name, account);
 


More information about the Commits mailing list