cpw.nader.asynclogging-3: 00a2a8fa: Got rid of PURPLE_SUBTYPE_LOG in value.h...

morshed.nader at gmail.com morshed.nader at gmail.com
Wed Mar 30 14:02:32 EDT 2011


----------------------------------------------------------------------
Revision: 00a2a8fadb9b08522a39733057f60c8f24c038d4
Parent:   abc387563059e1bb747958b5f371c10a8a1f2794
Author:   morshed.nader at gmail.com
Date:     03/30/11 13:57:29
Branch:   im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/00a2a8fadb9b08522a39733057f60c8f24c038d4

Changelog: 

Got rid of PURPLE_SUBTYPE_LOG in value.h and replaced the occurances with PURPLE_TYPE_OBJECT
Got rid of purple_(html|txt|old)_log_system_get_handle, as those modules do not register any signals
Cleaned up oldlog.c

Changes against parent abc387563059e1bb747958b5f371c10a8a1f2794

  patched  finch/gntlog.c
  patched  libpurple/commonlog.h
  patched  libpurple/htmllog.c
  patched  libpurple/htmllog.h
  patched  libpurple/log.c
  patched  libpurple/oldlog.c
  patched  libpurple/oldlog.h
  patched  libpurple/txtlog.c
  patched  libpurple/txtlog.h
  patched  libpurple/value.h
  patched  pidgin/gtklog.c

-------------- next part --------------
============================================================
--- libpurple/log.c	388304937e945a6f024771ef729635b5ceabea20
+++ libpurple/log.c	a38886da463eaa94472d64e153d5cc9d3b167c02
@@ -2366,7 +2366,7 @@ purple_log_system_init(void)
 #error Unknown size of time_t
 #endif
 		purple_value_new(PURPLE_TYPE_STRING), 3,
-		purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_LOG),
+		purple_value_new(PURPLE_TYPE_OBJECT),
 #if SIZEOF_TIME_T == 4
 		purple_value_new(PURPLE_TYPE_INT),
 #elif SIZEOF_TIME_T == 8
@@ -2376,7 +2376,8 @@ purple_log_system_init(void)
 #endif
 		purple_value_new(PURPLE_TYPE_BOOLEAN));
 
-	purple_prefs_connect_callback(NULL, "/purple/logging/format", logger_pref_cb, NULL);
+	purple_prefs_connect_callback(NULL, "/purple/logging/format",
+		logger_pref_cb, NULL);
 	purple_prefs_trigger_callback("/purple/logging/format");
 
 	G_LOCK(logsize_users);
@@ -2436,8 +2437,8 @@ _log_get_timestamp(PurpleLog *log, time_
 	show_date = purple_log_get_chat_type(log) == PURPLE_LOG_SYSTEM ||
 		time(NULL) > when + 20 * 60;
 
-	date = purple_signal_emit_return_1(purple_log_system_get_handle(), "log-timestamp",
-		log, when, show_date);
+	date = purple_signal_emit_return_1(purple_log_system_get_handle(),
+		"log-timestamp", log, when, show_date);
 
 	if (date != NULL)
 		return date;
============================================================
--- libpurple/value.h	3a7b6a6dd8106466d5a438203706c2bc0c2b6cd9
+++ libpurple/value.h	409d8ec6838e0d6a080d9392dad4852c47e0d048
@@ -73,7 +73,6 @@ typedef enum
 	PURPLE_SUBTYPE_BLIST_NODE,
 	PURPLE_SUBTYPE_CIPHER,
 	PURPLE_SUBTYPE_STATUS,
-	PURPLE_SUBTYPE_LOG,
 	PURPLE_SUBTYPE_XFER,
 	PURPLE_SUBTYPE_SAVEDSTATUS,
 	PURPLE_SUBTYPE_XMLNODE,
============================================================
--- pidgin/gtklog.c	e1d92ca5347c39b5f490e0ce0f50947e7cef186e
+++ pidgin/gtklog.c	72eb41792b836c88c6a5f589de20c25a6d334898
@@ -2291,8 +2291,8 @@ pidgin_log_init(void)
 	purple_signal_register(handle, "log-displaying",
 		purple_marshal_VOID__POINTER_POINTER,
 		NULL, 2,
-		purple_value_new(PURPLE_TYPE_BOXED, "PidginLogViewer *"),
-		purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_LOG));
+		purple_value_new(PURPLE_TYPE_OBJECT),
+		purple_value_new(PURPLE_TYPE_OBJECT));
 }
 
 void
============================================================
--- finch/gntlog.c	cbe3668f901a6cd2f0932b9067e5698c2b3144ac
+++ finch/gntlog.c	4cbd8d2832ffd8b6a27dd4140e698e3e2fb9de30
@@ -1655,8 +1655,8 @@ finch_log_init(void)
 	purple_signal_register(handle, "log-displaying",
 		purple_marshal_VOID__POINTER_POINTER,
 		NULL, 2,
-		purple_value_new(PURPLE_TYPE_BOXED, "FinchLogViewer *"),
-		purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_LOG));
+		purple_value_new(PURPLE_TYPE_OBJECT),
+		purple_value_new(PURPLE_TYPE_OBJECT));
 }
 
 void
============================================================
--- libpurple/htmllog.c	3c6b4cea5ab5ea309d4c045dfc82de9ff1a6e917
+++ libpurple/htmllog.c	08ebd87762fb3793424b7b975337bcc019dacb94
@@ -336,14 +336,6 @@ purple_html_log_system_init(void)
 	purple_log_logger_add(PURPLE_TYPE_HTML_LOG);
 }
 
-void *
-purple_html_log_system_get_handle(void)
-{
-	static gint handle;
-
-	return &handle;
-}
-
 void
 purple_html_log_system_uninit(void)
 {
============================================================
--- libpurple/htmllog.h	59f8a50ecafe6aed88570ebd8ef2397190a7548c
+++ libpurple/htmllog.h	23547a5079e241a1d05fb256516bca65b2f57932
@@ -59,11 +59,11 @@ GType purple_html_log_get_type(void);
 
 GType purple_html_log_get_type(void);
 
-PurpleLog *purple_html_log_new(PurpleLogChatType chat_type, const gchar *name, PurpleAccount *account,
-	PurpleConversation *conv, time_t time, const struct tm *tm);
+PurpleLog *purple_html_log_new(PurpleLogChatType chat_type, const gchar *name,
+	PurpleAccount *account, PurpleConversation *conv, time_t time,
+	const struct tm *tm);
 
 void purple_html_log_system_init(void);
-void *purple_html_log_system_get_handle(void);
 void purple_html_log_system_uninit(void);
 
 G_END_DECLS
============================================================
--- libpurple/oldlog.c	b78ca5eb7dc8a643406b48055de078f5eab0dffc
+++ libpurple/oldlog.c	9034368587f4511a0741b6cfc7bb090ca397213d
@@ -30,16 +30,20 @@ G_DEFINE_TYPE (PurpleOldLog, purple_old_
 
 G_DEFINE_TYPE (PurpleOldLog, purple_old_log, PURPLE_TYPE_COMMON_LOG)
 
-static GList *purple_old_log_list(PurpleLog *, PurpleLogChatType, const gchar *, PurpleAccount *, GCancellable *, GError **);
-static gint purple_old_log_total_size(PurpleLog *, PurpleLogChatType, const gchar *, PurpleAccount *, GCancellable *, GError **);
-static gchar *purple_old_log_read(PurpleLog *, PurpleLogReadFlags *, GCancellable *, GError **);
-static GHashTable *purple_old_log_get_log_sets(PurpleLog *, GCancellable *, GError **);
+static GList *purple_old_log_list(PurpleLog *, PurpleLogChatType, const gchar *,
+	PurpleAccount *, GCancellable *, GError **);
+static gint purple_old_log_total_size(PurpleLog *, PurpleLogChatType,
+	const gchar *, PurpleAccount *, GCancellable *, GError **);
+static gchar *purple_old_log_read(PurpleLog *, PurpleLogReadFlags *,
+	GCancellable *, GError **);
+static GHashTable *purple_old_log_get_log_sets(PurpleLog *, GCancellable *,
+	GError **);
 
 
-/* The old logger doesn't write logs, only reads them.  This is to include
+/**
+ * The old logger doesn't write logs, only reads them.  This is to include
  * old logs in the log viewer transparently.
  */
-
 static void
 purple_old_log_class_init(PurpleOldLogClass *class)
 {
@@ -60,15 +64,19 @@ PurpleLog *
 }
 
 PurpleLog *
-purple_old_log_new(PurpleLogChatType type, const gchar *name, PurpleAccount *account,
-	PurpleConversation *conv, time_t time, const struct tm *tm)
+purple_old_log_new(PurpleLogChatType type, const gchar *name,
+	PurpleAccount *account, PurpleConversation *conv, time_t time,
+	const struct tm *tm)
 {
-	return purple_common_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!!!
 static GList *
-purple_old_log_list(PurpleLog *log, PurpleLogChatType chat_type, const gchar *sn, PurpleAccount *account, GCancellable *cancellable, GError **error)
+purple_old_log_list(PurpleLog *log, PurpleLogChatType chat_type,
+	const gchar *sn, PurpleAccount *account, GCancellable *cancellable,
+	GError **error)
 {
 	GDataInputStream *data_stream;
 	GError *err = NULL;
@@ -108,10 +116,14 @@ purple_old_log_list(PurpleLog *log, Purp
 		return NULL;
 	}
 
-	log_last_modified = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+	log_last_modified = g_file_info_get_attribute_uint64(info,
+		G_FILE_ATTRIBUTE_TIME_MODIFIED);
 	g_object_unref(info);
 
-	/* Check for the index file, which would save us from having to parse the log itself */
+	/**
+	 * Check for the index file, which would save us from having to parse the
+	 * log itself
+	 */
 	strcpy(pathstr + strlen(pathstr) - 3, "idx");
 	file_idx = g_file_new_for_path(pathstr);
 
@@ -132,7 +144,8 @@ purple_old_log_list(PurpleLog *log, Purp
 
 		g_clear_error(&err);
 	} else {
-		idx_last_modified = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+		idx_last_modified = g_file_info_get_attribute_uint64(info,
+			G_FILE_ATTRIBUTE_TIME_MODIFIED);
 		g_object_unref(info);
 
 		if (idx_last_modified >= log_last_modified) {
@@ -155,15 +168,19 @@ purple_old_log_list(PurpleLog *log, Purp
 			while ((buffer = g_data_input_stream_read_line(data_stream, NULL,
 				cancellable, &err)) != NULL)
 			{
-				if (sscanf(buffer, "%d\t%d\t%lu", &lastoff, &newlen, &idx_time) == 3) {
+				if (sscanf(buffer, "%d\t%d\t%lu", &lastoff, &newlen,
+					&idx_time) == 3)
+				{
 					PurpleLog *log;
 
 					log = purple_old_log_new(PURPLE_LOG_IM,
 						sn, account, NULL, idx_time, NULL);
 
 					purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
-					purple_common_log_set_offset(PURPLE_COMMON_LOG(log), lastoff);
-					purple_common_log_set_length(PURPLE_COMMON_LOG(log), newlen);
+					purple_common_log_set_offset(PURPLE_COMMON_LOG(log),
+						lastoff);
+					purple_common_log_set_length(PURPLE_COMMON_LOG(log),
+						newlen);
 
 					list = g_list_prepend(list, log);
 				}
@@ -187,7 +204,9 @@ purple_old_log_list(PurpleLog *log, Purp
 			return list;
 		}
 
-		// purple_debug_warning("log", "Index \"%s\" exists, but is older than the log.\n", pathstr);
+		/* purple_debug_warning is not thread-safe (At the moment)
+		purple_debug_warning("log", "Index \"%s\" exists, but is older "
+			"than the log.\n", pathstr);*/
 		g_object_unref(file_idx);
 	}
 
@@ -204,8 +223,9 @@ purple_old_log_list(PurpleLog *log, Purp
 	index_tmp = g_strdup_printf("%s.XXXXXX", pathstr);
 
 	if ((index_fd = g_mkstemp(index_tmp)) == -1) {
-		// purple_debug_error("log", "Failed to open index temp file: %s\n",
-			// g_strerror(errno));
+		/* purple_debug_error is not thread-safe (At the moment)
+		purple_debug_error("log", "Failed to open index temp file: %s\n",
+			g_strerror(errno));*/
 
 		g_free(pathstr);
 		g_free(index_tmp);
@@ -214,8 +234,9 @@ purple_old_log_list(PurpleLog *log, Purp
 		index = fdopen(index_fd, "wb");
 
 		if (index == NULL) {
-			// purple_debug_error("log", "Failed to fdopen() index temp file: %s\n",
-				// g_strerror(errno));
+			/* purple_debug_error is not thread-safe (At the moment)
+			purple_debug_error("log", "Failed to fdopen() index temp file: %s\n",
+				g_strerror(errno));*/
 			close(index_fd);
 
 			if (index_tmp != NULL) {
@@ -248,8 +269,8 @@ purple_old_log_list(PurpleLog *log, Purp
 
 				if (strstr(buffer, "----</H3><BR>"))
 					newlen -=
-						sizeof("<HR><BR><H3 Align=Center> ---- New Conversation @ "
-							"----</H3><BR>") - 2;
+						sizeof("<HR><BR><H3 Align=Center> ---- New Conversation"
+							"@ ----</H3><BR>") - 2;
 				else
 					newlen -= sizeof("---- New Conversation @ ----") - 2;
 
@@ -257,12 +278,14 @@ purple_old_log_list(PurpleLog *log, Purp
 					newlen--;
 
 				if (newlen != 0) {
-					PurpleLog *log = purple_log_new(PURPLE_TYPE_OLD_LOG, PURPLE_LOG_IM, sn,
-						account, NULL, lasttime, NULL);
+					PurpleLog *log = purple_log_new(PURPLE_TYPE_OLD_LOG,
+						PURPLE_LOG_IM, sn, account, NULL, lasttime, NULL);
 
 					purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
-					purple_common_log_set_offset(PURPLE_COMMON_LOG(log), lastoff);
-					purple_common_log_set_length(PURPLE_COMMON_LOG(log), newlen);
+					purple_common_log_set_offset(PURPLE_COMMON_LOG(log),
+						lastoff);
+					purple_common_log_set_length(PURPLE_COMMON_LOG(log),
+						newlen);
 
 					list = g_list_prepend(list, log);
 
@@ -315,8 +338,8 @@ purple_old_log_list(PurpleLog *log, Purp
 
 	if (log_found) {
 		if ((newlen = offset - lastoff) != 0) {
-			PurpleLog *log = purple_log_new(PURPLE_TYPE_OLD_LOG, PURPLE_LOG_IM, sn,
-				account, NULL, lasttime, NULL);
+			PurpleLog *log = purple_log_new(PURPLE_TYPE_OLD_LOG, PURPLE_LOG_IM,
+				sn, account, NULL, lasttime, NULL);
 
 			purple_common_log_set_file(PURPLE_COMMON_LOG(log), file);
 			purple_common_log_set_offset(PURPLE_COMMON_LOG(log), lastoff);
@@ -335,11 +358,15 @@ purple_old_log_list(PurpleLog *log, Purp
 		fclose(index);
 
 		if (g_rename(index_tmp, pathstr)) {
-			// purple_debug_warning("log", "Failed to rename index temp file \"%s\" to \"%s\": %s\n",
-				// index_tmp, pathstr, g_strerror(errno));
+			/* purple_debug_warning is not thread-safe (At the moment)
+			purple_debug_warning("log", "Failed to rename index temp file "
+				"\"%s\" to \"%s\": %s\n",
+				index_tmp, pathstr, g_strerror(errno));*/
 			g_unlink(index_tmp);
 		} else {
-			; // purple_debug_info("log", "Built index: %s\n", pathstr);
+			/* purple_debug_info is not thread-safe (At the moment)
+			purple_debug_info("log", "Built index: %s\n", pathstr);*/
+			; 
 		}
 
 		g_free(index_tmp);
@@ -352,7 +379,9 @@ static gssize
 }
 
 static gssize
-purple_old_log_total_size(PurpleLog *log, PurpleLogChatType chat_type, const gchar *name, PurpleAccount *account, GCancellable *cancellable, GError **error)
+purple_old_log_total_size(PurpleLog *log, PurpleLogChatType chat_type,
+	const gchar *name, PurpleAccount *account, GCancellable *cancellable,
+	GError **error)
 {
 	/* Yes, only one file. */
 	GError *err = NULL;
@@ -395,7 +424,8 @@ static gchar *
 }
 
 static gchar *
-purple_old_log_read(PurpleLog *log, PurpleLogReadFlags *flags, GCancellable *cancellable, GError **error)
+purple_old_log_read(PurpleLog *log, PurpleLogReadFlags *flags,
+	GCancellable *cancellable, GError **error)
 {
 	GFile *file;
 	GFileInputStream *file_stream;
@@ -447,7 +477,8 @@ static GHashTable *
 }
 
 static GHashTable *
-purple_old_log_get_log_sets(PurpleLog *log, GCancellable *cancellable, GError **error)
+purple_old_log_get_log_sets(PurpleLog *log, GCancellable *cancellable,
+	GError **error)
 {
 	PurpleBlistNode *gnode, *cnode, *bnode;
 	PurpleBuddy *buddy;
@@ -516,7 +547,10 @@ purple_old_log_get_log_sets(PurpleLog *l
 
 		set->name = set->normalized_name = name;
 
-		/* Search the buddy list to find the account and to determine if this is a buddy. */
+		/**
+		 * Search the buddy list to find the account and to determine
+		 * if this is a buddy.
+		 */
 		for (gnode = purple_blist_get_root();
 			!found && gnode != NULL;
 			gnode = purple_blist_node_get_sibling_next(gnode))
@@ -567,14 +601,6 @@ purple_old_log_system_init(void)
 	purple_log_logger_add(PURPLE_TYPE_OLD_LOG);
 }
 
-void *
-purple_old_log_system_get_handle(void)
-{
-	static gint handle;
-
-	return &handle;
-}
-
 void
 purple_old_log_system_uninit(void)
 {
============================================================
--- libpurple/oldlog.h	c8fad548bf6ae53aa548698245fb5b6cc3842535
+++ libpurple/oldlog.h	e5f8c4503b340d6c2ee2bf53f6960f5d419235e1
@@ -59,11 +59,11 @@ GType purple_old_log_get_type(void);
 
 GType purple_old_log_get_type(void);
 
-PurpleLog *purple_old_log_new(PurpleLogChatType chat_type, const gchar *name, PurpleAccount *account,
-	PurpleConversation *conv, time_t time, const struct tm *tm);
+PurpleLog *purple_old_log_new(PurpleLogChatType chat_type, const gchar *name,
+	PurpleAccount *account, PurpleConversation *conv, time_t time,
+	const struct tm *tm);
 
 void purple_old_log_system_init(void);
-void *purple_old_log_system_get_handle(void);
 void purple_old_log_system_uninit(void);
 
 G_END_DECLS
============================================================
--- libpurple/txtlog.c	f07b77c2103b30628aa489b5786166d464b5b69b
+++ libpurple/txtlog.c	536cc48eecf638af3c55f0bdd9325a2ada7fc048
@@ -258,14 +258,6 @@ purple_txt_log_system_init(void)
 	purple_log_logger_add(PURPLE_TYPE_TXT_LOG);
 }
 
-void *
-purple_txt_log_system_get_handle(void)
-{
-	static gint handle;
-
-	return &handle;
-}
-
 void
 purple_txt_log_system_uninit(void)
 {
============================================================
--- libpurple/txtlog.h	5071e96791c31a889d9c88f5e44c62b6a7657e64
+++ libpurple/txtlog.h	361d125532b2df3906360de9d94dcfaa0bd71465
@@ -59,11 +59,11 @@ GType purple_txt_log_get_type(void);
 
 GType purple_txt_log_get_type(void);
 
-PurpleLog *purple_txt_log_new(PurpleLogChatType chat_type, const gchar *name, PurpleAccount *account,
-	PurpleConversation *conv, time_t time, const struct tm *tm);
+PurpleLog *purple_txt_log_new(PurpleLogChatType chat_type, const gchar *name,
+	PurpleAccount *account, PurpleConversation *conv, time_t time,
+	const struct tm *tm);
 
 void purple_txt_log_system_init(void);
-void *purple_txt_log_system_get_handle(void);
 void purple_txt_log_system_uninit(void);
 
 G_END_DECLS
============================================================
--- libpurple/commonlog.h	14458e75e6526e580d1b6a726b3456b1b2a54a61
+++ libpurple/commonlog.h	41be5fcdcd16dc0a1f1bd5662858e4fcc2ef20ad
@@ -125,7 +125,6 @@ void purple_log_common_writer_async(Purp
 
 /**
  * Asynchronously opens a new log in the standard log location
- *
  * See purple_log_common_writer() for more details.
  *
  * @param log          The log to write to


More information about the Commits mailing list