changeset 15568:fd5e7ac7f2fa

merge of '27c17e92071c391b099220ce5cac417ea8695587' and 'f5ec66d0e5f00c3c237d178403dcda3bc8b2496e'
author Mark Doliner <mark@kingant.net>
date Mon, 05 Feb 2007 05:49:03 +0000
parents 3b6ce2116f74 (diff) bcdf8880564b (current diff)
children c4e19bea83c1
files
diffstat 8 files changed, 384 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/console/libgnt/gnttree.c	Mon Feb 05 05:48:07 2007 +0000
+++ b/console/libgnt/gnttree.c	Mon Feb 05 05:49:03 2007 +0000
@@ -1195,17 +1195,16 @@
 				tree->top = get_prev(row);
 			else
 				tree->top = get_next(row);
-			if (tree->current == row)
-				tree->current = tree->top;
 		}
-		else if (tree->current == row)
+		if (tree->current == row)
 		{
 			if (tree->current != tree->root)
 				tree->current = get_prev(row);
 			else
 				tree->current = get_next(row);
+			tree_selection_changed(tree, row, tree->current);
 		}
-		else if (tree->bottom == row)
+		if (tree->bottom == row)
 		{
 			tree->bottom = get_prev(row);
 		}
--- a/libpurple/plugins/Makefile.am	Mon Feb 05 05:48:07 2007 +0000
+++ b/libpurple/plugins/Makefile.am	Mon Feb 05 05:49:03 2007 +0000
@@ -28,6 +28,7 @@
 autoreply_la_LDFLAGS        = -module -avoid-version
 buddynote_la_LDFLAGS        = -module -avoid-version
 idle_la_LDFLAGS             = -module -avoid-version
+joinpart_la_LDFLAGS         = -module -avoid-version
 log_reader_la_LDFLAGS       = -module -avoid-version
 newline_la_LDFLAGS          = -module -avoid-version
 offlinemsg_la_LDFLAGS       = -module -avoid-version
@@ -44,6 +45,7 @@
 	autoreply.la        \
 	buddynote.la        \
 	idle.la             \
+	joinpart.la         \
 	log_reader.la       \
 	newline.la          \
 	offlinemsg.la       \
@@ -55,6 +57,7 @@
 autoreply_la_SOURCES        = autoreply.c
 buddynote_la_SOURCES        = buddynote.c
 idle_la_SOURCES             = idle.c
+joinpart_la_SOURCES         = joinpart.c
 log_reader_la_SOURCES       = log_reader.c
 newline_la_SOURCES          = newline.c
 offlinemsg_la_SOURCES       = offlinemsg.c
@@ -65,6 +68,7 @@
 autoreply_la_LIBADD         = $(GLIB_LIBS)
 buddynote_la_LIBADD         = $(GLIB_LIBS)
 idle_la_LIBADD              = $(GLIB_LIBS)
+joinpart_la_LIBADD          = $(GLIB_LIBS)
 log_reader_la_LIBADD        = $(GLIB_LIBS)
 newline_la_LIBADD           = $(GLIB_LIBS)
 offlinemsg_la_LIBADD        = $(GLIB_LIBS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/plugins/joinpart.c	Mon Feb 05 05:49:03 2007 +0000
@@ -0,0 +1,294 @@
+/**
+ * gaim
+ *
+ * Gaim is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "internal.h"
+#include "conversation.h"
+#include "debug.h"
+#include "plugin.h"
+#include "version.h"
+
+#define JOINPART_PLUGIN_ID "core-rlaager-joinpart"
+
+
+/* Preferences */
+
+/* The number of minutes before a person is considered
+ * to have stopped being part of active conversation. */
+#define DELAY_PREF "/plugins/core/joinpart/delay"
+#define DELAY_DEFAULT 10
+
+/* The number of people that must be in a room for this
+ * plugin to have any effect */
+#define THRESHOLD_PREF "/plugins/core/joinpart/threshold"
+#define THRESHOLD_DEFAULT 20
+
+struct joinpart_key
+{
+	GaimConversation *conv;
+	char *user;
+};
+
+static guint joinpart_key_hash(const struct joinpart_key *key)
+{
+	g_return_val_if_fail(key != NULL, 0);
+
+	return g_direct_hash(key->conv) + g_str_hash(key->user);
+}
+
+static gboolean joinpart_key_equal(const struct joinpart_key *a, const struct joinpart_key *b)
+{
+	if (a == NULL)
+		return (b == NULL);
+	else if (b == NULL)
+		return FALSE;
+
+	return (a->conv == b->conv) && !strcmp(a->user, b->user);
+}
+
+static void joinpart_key_destroy(struct joinpart_key *key)
+{
+	g_return_if_fail(key != NULL);
+
+	g_free(key->user);
+	g_free(key);
+}
+
+static gboolean should_hide_notice(GaimConversation *conv, const char *name,
+                                   GHashTable *users)
+{
+	GaimConvChat *chat;
+	int threshold;
+	struct joinpart_key *key;
+	time_t *last_said;
+
+	g_return_val_if_fail(conv != NULL, FALSE);
+	g_return_val_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT, FALSE);
+
+	/* If the room is small, don't bother. */
+	chat = GAIM_CONV_CHAT(conv);
+	threshold = gaim_prefs_get_int(THRESHOLD_PREF);
+	if (g_list_length(gaim_conv_chat_get_users(chat)) < threshold)
+		return FALSE;
+
+	/* We always care about our buddies! */
+	if (gaim_find_buddy(gaim_conversation_get_account(conv), name))
+		return FALSE;
+
+	/* Only show the notice if the user has spoken recently. */
+	key = g_new(struct joinpart_key, 1);
+	key->conv = conv;
+	key->user = g_strdup(name);
+	last_said = g_hash_table_lookup(users, key);
+	if (last_said != NULL)
+	{
+		int delay = gaim_prefs_get_int(DELAY_PREF);
+		if (delay > 0 && (*last_said + (delay * 60)) >= time(NULL))
+			return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean chat_buddy_leaving_cb(GaimConversation *conv, const char *name,
+                               const char *reason, GHashTable *users)
+{
+	return should_hide_notice(conv, name, users);
+}
+
+static gboolean chat_buddy_joining_cb(GaimConversation *conv, const char *name,
+                                      GaimConvChatBuddyFlags flags,
+                                      GHashTable *users)
+{
+	return should_hide_notice(conv, name, users);
+}
+
+static void received_chat_msg_cb(GaimAccount *account, char *sender,
+                                 char *message, GaimConversation *conv,
+                                 GaimMessageFlags flags, GHashTable *users)
+{
+	struct joinpart_key key;
+	time_t *last_said;
+
+	/* Most of the time, we'll already have tracked the user,
+	 * so we avoid memory allocation here. */
+	key.conv = conv;
+	key.user = sender;
+	last_said = g_hash_table_lookup(users, &key);
+	if (last_said != NULL)
+	{
+		/* They just said something, so update the time. */
+		time(last_said);
+	}
+	else
+	{
+		struct joinpart_key *key2;
+
+		key2 = g_new(struct joinpart_key, 1);
+		key2->conv = conv;
+		key2->user = g_strdup(sender);
+
+		last_said = g_new(time_t, 1);
+		time(last_said);
+
+		g_hash_table_insert(users, key2, last_said);
+	}
+}
+
+static gboolean check_expire_time(struct joinpart_key *key,
+                                  time_t *last_said, time_t *limit)
+{
+	gaim_debug_info("joinpart", "Removing key for %s/%s\n", key->conv->name, key->user);
+	return (*last_said < *limit);
+}
+
+static gboolean clean_users_hash(GHashTable *users)
+{
+	int delay = gaim_prefs_get_int(DELAY_PREF);
+	time_t limit = time(NULL) - (60 * delay);
+
+	g_hash_table_foreach_remove(users, (GHRFunc)check_expire_time, &limit);
+
+	return TRUE;
+}
+
+static gboolean plugin_load(GaimPlugin *plugin)
+{
+	void *conv_handle;
+	GHashTable *users;
+	guint id;
+	gpointer *data;
+
+	users = g_hash_table_new_full((GHashFunc)joinpart_key_hash,
+	                              (GEqualFunc)joinpart_key_equal,
+	                              (GDestroyNotify)joinpart_key_destroy,
+	                              g_free);
+
+	conv_handle = gaim_conversations_get_handle();
+	gaim_signal_connect(conv_handle, "chat-buddy-joining", plugin,
+	                    GAIM_CALLBACK(chat_buddy_joining_cb), users);
+	gaim_signal_connect(conv_handle, "chat-buddy-leaving", plugin,
+	                    GAIM_CALLBACK(chat_buddy_leaving_cb), users);
+	gaim_signal_connect(conv_handle, "received-chat-msg", plugin,
+	                    GAIM_CALLBACK(received_chat_msg_cb), users);
+
+	/* Cleanup every 5 minutes */
+	id = gaim_timeout_add(1000 * 60 * 5, (GSourceFunc)clean_users_hash, users);
+
+	data = g_new(gpointer, 2);
+	data[0] = users;
+	data[1] = GUINT_TO_POINTER(id);
+	plugin->extra = data;
+
+	return TRUE;
+}
+
+static gboolean plugin_unload(GaimPlugin *plugin)
+{
+	gpointer *data = plugin->extra;
+
+	/* Destroy the hash table. The core plugin code will
+	 * disconnect the signals, and since Gaim is single-threaded,
+	 * we don't have to worry one will be called after this. */
+	g_hash_table_destroy((GHashTable *)data[0]);
+
+	g_source_remove(GPOINTER_TO_UINT(data[1]));
+	g_free(data);
+
+	return TRUE;
+}
+
+static GaimPluginPrefFrame *
+get_plugin_pref_frame(GaimPlugin *plugin)
+{
+	GaimPluginPrefFrame *frame;
+	GaimPluginPref *ppref;
+
+	g_return_val_if_fail(plugin != NULL, FALSE);
+
+	frame = gaim_plugin_pref_frame_new();
+
+	ppref = gaim_plugin_pref_new_with_label(_("Join/Part Hiding Configuration"));
+	gaim_plugin_pref_frame_add(frame, ppref);
+
+	ppref = gaim_plugin_pref_new_with_name_and_label(THRESHOLD_PREF,
+	                                                 _("Minimum Room Size"));
+	gaim_plugin_pref_set_bounds(ppref, 0, 1000);
+	gaim_plugin_pref_frame_add(frame, ppref);
+
+
+	ppref = gaim_plugin_pref_new_with_name_and_label(DELAY_PREF,
+	                                                 _("User Inactivity Timeout (in minutes)"));
+	gaim_plugin_pref_set_bounds(ppref, 0, 8 * 60); /* 8 Hours */
+	gaim_plugin_pref_frame_add(frame, ppref);
+
+	return frame;
+}
+
+static GaimPluginUiInfo prefs_info = {
+	get_plugin_pref_frame,
+	0,   /* page_num (reserved) */
+	NULL /* frame (reserved) */
+};
+
+static GaimPluginInfo info =
+{
+	GAIM_PLUGIN_MAGIC,
+	GAIM_MAJOR_VERSION,
+	GAIM_MINOR_VERSION,
+	GAIM_PLUGIN_STANDARD,                             /**< type           */
+	NULL,                                             /**< ui_requirement */
+	0,                                                /**< flags          */
+	NULL,                                             /**< dependencies   */
+	GAIM_PRIORITY_DEFAULT,                            /**< priority       */
+
+	JOINPART_PLUGIN_ID,                               /**< id             */
+	N_("Join/Part Hiding"),                           /**< name           */
+	VERSION,                                          /**< version        */
+	                                                  /**  summary        */
+	N_("Hides extraneous join/part messages."),
+	                                                  /**  description    */
+	N_("This plugin hides join/part messages in large "
+	   "rooms, except for those users actively taking "
+	   "part in a conversation."),
+	"Richard Laager <rlaager@pidgin.im>",             /**< author         */
+	GAIM_WEBSITE,                                     /**< homepage       */
+
+	plugin_load,                                      /**< load           */
+	plugin_unload,                                    /**< unload         */
+	NULL,                                             /**< destroy        */
+
+	NULL,                                             /**< ui_info        */
+	NULL,                                             /**< extra_info     */
+	&prefs_info,                                      /**< prefs_info     */
+	NULL                                              /**< actions        */
+};
+
+static void
+init_plugin(GaimPlugin *plugin)
+{
+	gaim_prefs_add_none("/plugins/core/joinpart");
+
+	gaim_prefs_add_int(DELAY_PREF, DELAY_DEFAULT);
+	gaim_prefs_add_int(THRESHOLD_PREF, THRESHOLD_DEFAULT);
+}
+
+GAIM_INIT_PLUGIN(joinpart, init_plugin, info)
--- a/libpurple/plugins/perl/libgaimperl.c	Mon Feb 05 05:48:07 2007 +0000
+++ b/libpurple/plugins/perl/libgaimperl.c	Mon Feb 05 05:49:03 2007 +0000
@@ -1,7 +1,16 @@
 #include <gmodule.h>
+
+#ifdef  __SUNPRO_C
+#pragma init (my_init)
+void my_init(void);
+
+void my_init() {
+#else
 void __attribute__ ((constructor)) my_init(void);
 
 void __attribute__ ((constructor)) my_init() {
+#endif
+
 	/* Very evil hack...puts perl.so's symbols in the global table
 	 * but does not create a circular dependancy because g_module_open
 	 * will only open the library once. */
--- a/pidgin/gtkblist.c	Mon Feb 05 05:48:07 2007 +0000
+++ b/pidgin/gtkblist.c	Mon Feb 05 05:49:03 2007 +0000
@@ -2717,9 +2717,9 @@
 	/* Buddies menu */
 	{ N_("/_Buddies"), NULL, NULL, 0, "<Branch>", NULL },
 	{ N_("/Buddies/New Instant _Message..."), "<CTL>M", pidgindialogs_im, 0, "<StockItem>", PIDGIN_STOCK_IM },
-	{ N_("/Buddies/Join a _Chat..."), "<CTL>C", pidgin_blist_joinchat_show, 0, "<StockItem>", PIDGIN_STOCK_CHAT },
+	{ N_("/Buddies/Join a _Chat..."), "<CTL>C", pidgin_blist_joinchat_show, 0, "<Item>", NULL },
 	{ N_("/Buddies/Get User _Info..."), "<CTL>I", pidgindialogs_info, 0, "<StockItem>", PIDGIN_STOCK_INFO },
-	{ N_("/Buddies/View User _Log..."), "<CTL>L", pidgindialogs_log, 0, "<StockItem>", PIDGIN_STOCK_LOG },
+	{ N_("/Buddies/View User _Log..."), "<CTL>L", pidgindialogs_log, 0, "<Item>", NULL },
 	{ "/Buddies/sep1", NULL, NULL, 0, "<Separator>", NULL },
 	{ N_("/Buddies/Show _Offline Buddies"), NULL, pidgin_blist_edit_mode_cb, 1, "<CheckItem>", NULL },
 	{ N_("/Buddies/Show _Empty Groups"), NULL, pidgin_blist_show_empty_groups_cb, 1, "<CheckItem>", NULL },
@@ -2735,25 +2735,25 @@
 
 	/* Accounts menu */
 	{ N_("/_Accounts"), NULL, NULL, 0, "<Branch>", NULL },
-	{ N_("/Accounts/Add\\/Edit"), "<CTL>A", pidgin_accounts_window_show, 0, "<StockItem>", PIDGIN_STOCK_ACCOUNTS },
+	{ N_("/Accounts/Add\\/Edit"), "<CTL>A", pidgin_accounts_window_show, 0, "<Item>", NULL },
 
 	/* Tools */
 	{ N_("/_Tools"), NULL, NULL, 0, "<Branch>", NULL },
-	{ N_("/Tools/Buddy _Pounces"), NULL, pidgin_pounces_manager_show, 0, "<StockItem>", PIDGIN_STOCK_POUNCE },
+	{ N_("/Tools/Buddy _Pounces"), NULL, pidgin_pounces_manager_show, 0, "<Item>", NULL },
 	{ N_("/Tools/Plu_gins"), "<CTL>U", pidgin_plugin_dialog_show, 0, "<StockItem>", PIDGIN_STOCK_PLUGIN },
 	{ N_("/Tools/Pr_eferences"), "<CTL>P", pidgin_prefs_show, 0, "<StockItem>", GTK_STOCK_PREFERENCES },
-	{ N_("/Tools/Pr_ivacy"), NULL, pidgin_privacy_dialog_show, 0, "<StockItem>", PIDGIN_STOCK_DIALOG_ERROR },
+	{ N_("/Tools/Pr_ivacy"), NULL, pidgin_privacy_dialog_show, 0, "<Item>", NULL },
 	{ "/Tools/sep2", NULL, NULL, 0, "<Separator>", NULL },
-	{ N_("/Tools/_File Transfers"), "<CTL>T", pidginxfer_dialog_show, 0, "<StockItem>", PIDGIN_STOCK_FILE_TRANSFER },
-	{ N_("/Tools/R_oom List"), NULL, pidgin_roomlist_dialog_show, 0, "<StockItem>", GTK_STOCK_INDEX },
-	{ N_("/Tools/System _Log"), NULL, gtk_blist_show_systemlog_cb, 0, "<StockItem>", PIDGIN_STOCK_LOG },
+	{ N_("/Tools/_File Transfers"), "<CTL>T", pidginxfer_dialog_show, 0, "<Item>", NULL },
+	{ N_("/Tools/R_oom List"), NULL, pidgin_roomlist_dialog_show, 0, "<Item>", NULL },
+	{ N_("/Tools/System _Log"), NULL, gtk_blist_show_systemlog_cb, 0, "<Item>", NULL },
 	{ "/Tools/sep3", NULL, NULL, 0, "<Separator>", NULL },
 	{ N_("/Tools/Mute _Sounds"), "<CTL>S", pidgin_blist_mute_sounds_cb, 0, "<CheckItem>", NULL },
 
 	/* Help */
 	{ N_("/_Help"), NULL, NULL, 0, "<Branch>", NULL },
 	{ N_("/Help/Online _Help"), "F1", gtk_blist_show_onlinehelp_cb, 0, "<StockItem>", GTK_STOCK_HELP },
-	{ N_("/Help/_Debug Window"), NULL, toggle_debug, 0, "<StockItem>", PIDGIN_STOCK_DEBUG },
+	{ N_("/Help/_Debug Window"), NULL, toggle_debug, 0, "<Item>", NULL },
 	{ N_("/Help/_About"), NULL, pidgindialogs_about, 0,  "<StockItem>", PIDGIN_STOCK_ABOUT },
 };
 
--- a/pidgin/gtkconv.c	Mon Feb 05 05:48:07 2007 +0000
+++ b/pidgin/gtkconv.c	Mon Feb 05 05:49:03 2007 +0000
@@ -2731,7 +2731,7 @@
 
 	{ N_("/Conversation/_Find..."), NULL, menu_find_cb, 0,
 			"<StockItem>", GTK_STOCK_FIND },
-	{ N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", PIDGIN_STOCK_LOG },
+	{ N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<Item>", NULL },
 	{ N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0,
 			"<StockItem>", GTK_STOCK_SAVE_AS },
 	{ N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR },
@@ -2740,17 +2740,17 @@
 
 	{ N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_FILE_TRANSFER },
 	{ N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb,
-			0, "<StockItem>", PIDGIN_STOCK_POUNCE },
+			0, "<Item>", NULL },
 	{ N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0,
 			"<StockItem>", PIDGIN_STOCK_INFO },
 	{ N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0,
-			"<StockItem>", PIDGIN_STOCK_INVITE },
+			"<Item>", NULL },
 	{ N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL },
 
 	{ "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL },
 
 	{ N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0,
-			"<StockItem>", PIDGIN_STOCK_EDIT },
+			"<Item>", NULL },
 	{ N_("/Conversation/_Block..."), NULL, menu_block_cb, 0,
 			"<StockItem>", PIDGIN_STOCK_BLOCK },
 	{ N_("/Conversation/_Unblock..."), NULL, menu_unblock_cb, 0,
@@ -2762,13 +2762,6 @@
 
 	{ "/Conversation/sep3", NULL, NULL, 0, "<Separator>", NULL },
 
-	{ N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0,
-			"<StockItem>", PIDGIN_STOCK_LINK },
-	{ N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0,
-			"<StockItem>", PIDGIN_STOCK_IMAGE },
-
-	{ "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL },
-
 	{ N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0,
 			"<StockItem>", GTK_STOCK_CLOSE },
 
@@ -5700,6 +5693,7 @@
 		gtk_widget_show(win->menu.invite);
 		gtk_widget_show(win->menu.alias);
 		gtk_widget_hide(win->menu.block);
+		gtk_widget_hide(win->menu.unblock);
 		gtk_widget_hide(win->menu.show_icon);
 
 		if ((account == NULL) || gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) {
--- a/pidgin/gtklog.c	Mon Feb 05 05:48:07 2007 +0000
+++ b/pidgin/gtklog.c	Mon Feb 05 05:49:03 2007 +0000
@@ -205,13 +205,40 @@
 		gtk_tree_view_expand_row(tv, path, FALSE);
 }
 
-static void delete_log_cb(GaimLog *log)
+static void delete_log_cleanup_cb(gpointer *data)
 {
-	if (!gaim_log_delete(log))
+	g_free(data[1]); /* iter */
+	g_free(data);
+}
+
+static void delete_log_cb(gpointer *data)
+{
+	if (!gaim_log_delete((GaimLog *)data[2]))
 	{
 		gaim_notify_error(NULL, NULL, "Log Deletion Failed",
 		                  "Check permissions and try again.");
 	}
+	else
+	{
+		GtkTreeStore *treestore = data[0];
+		GtkTreeIter *iter = (GtkTreeIter *)data[1];
+		GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), iter);
+		gboolean first = !gtk_tree_path_prev(path);
+
+		if (!gtk_tree_store_remove(treestore, iter) && first)
+		{
+			/* iter was the last child at its level */
+
+			if (gtk_tree_path_up(path))
+			{
+				gtk_tree_model_get_iter(GTK_TREE_MODEL(treestore), iter, path);
+				gtk_tree_store_remove(treestore, iter);
+			}
+		}
+		gtk_tree_path_free(path);
+	}
+
+	delete_log_cleanup_cb(data);
 }
 
 static void log_delete_log_cb(GtkWidget *menuitem, gpointer *data)
@@ -221,6 +248,7 @@
 	const char *time = log_get_date(log);
 	const char *name;
 	char *tmp;
+	gpointer *data2;
 
 	if (log->type == GAIM_LOG_IM)
 	{
@@ -252,8 +280,17 @@
 	else
 		g_return_if_reached();
 
+	/* The only way to free data in all cases is to tie it to the menuitem with
+	 * g_object_set_data_full().  But, since we need to get some data down to
+	 * delete_log_cb() to delete the log from the log viewer after the file is
+	 * deleted, we have to allocate a new data array and make sure it gets freed
+	 * either way. */
+	data2 = g_new(gpointer, 3);
+	data2[0] = lv->treestore;
+	data2[1] = data[3]; /* iter */
+	data2[2] = log;
 	gaim_request_action(lv, NULL, "Delete Log?", tmp,
-	                    0, log, 2, _("Delete"), delete_log_cb, _("Cancel"), NULL);
+	                    0, data2, 2, _("Delete"), delete_log_cb, _("Cancel"), delete_log_cleanup_cb);
 	g_free(tmp);
 }
 
@@ -266,11 +303,11 @@
 		gtk_widget_set_sensitive(menuitem, FALSE);
 
 	g_signal_connect(menuitem, "activate", G_CALLBACK(log_delete_log_cb), data);
-	g_object_set_data_full(menuitem, "log-viewer-data", data, g_free);
+	g_object_set_data_full(G_OBJECT(menuitem), "log-viewer-data", data, g_free);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 	gtk_widget_show_all(menu);
 
-	gtk_menu_popup(GTK_MENU(menu), NULL, (GtkMenuPositionFunc)data[2], NULL, NULL,
+	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, (GtkMenuPositionFunc)data[2], NULL,
 	               (event != NULL) ? event->button : 0,
 	               gdk_event_get_time((GdkEvent *)event));
 }
@@ -280,26 +317,31 @@
 	if (event->type == GDK_BUTTON_PRESS && event->button == 3)
 	{
 		GtkTreePath *path;
-		GtkTreeIter iter;
+		GtkTreeIter *iter;
 		GValue val;
 		GaimLog *log;
 		gpointer *data;
 
 		if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), event->x, event->y, &path, NULL, NULL, NULL))
 			return FALSE;
-		gtk_tree_model_get_iter(GTK_TREE_MODEL(lv->treestore), &iter, path);
+		iter = g_new(GtkTreeIter, 1);
+		gtk_tree_model_get_iter(GTK_TREE_MODEL(lv->treestore), iter, path);
 		val.g_type = 0;
-		gtk_tree_model_get_value(GTK_TREE_MODEL(lv->treestore), &iter, 1, &val);
+		gtk_tree_model_get_value(GTK_TREE_MODEL(lv->treestore), iter, 1, &val);
 
 		log = g_value_get_pointer(&val);
 
 		if (log == NULL)
+		{
+			g_free(iter);
 			return FALSE;
+		}
 
-		data = g_new(gpointer, 3);
+		data = g_new(gpointer, 4);
 		data[0] = lv;
 		data[1] = log;
 		data[2] = NULL;
+		data[3] = iter;
 
 		log_show_popup_menu(treeview, event, data);
 		return TRUE;
@@ -311,28 +353,32 @@
 static gboolean log_popup_menu_cb(GtkWidget *treeview, PidginLogViewer *lv)
 {
 	GtkTreeSelection *sel;
-	GtkTreeIter iter;
+	GtkTreeIter *iter;
 	GValue val;
 	GaimLog *log;
 	gpointer *data;
 
+	iter = g_new(GtkTreeIter, 1);
 	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(lv));
-	if (!gtk_tree_selection_get_selected(sel, NULL, &iter))
+	if (!gtk_tree_selection_get_selected(sel, NULL, iter))
+	{
 		return FALSE;
+	}
 
 	val.g_type = 0;
 	gtk_tree_model_get_value(GTK_TREE_MODEL(lv->treestore),
-	                         &iter, NODE_COLUMN, &val);
+	                         iter, NODE_COLUMN, &val);
 
 	log = g_value_get_pointer(&val);
 
 	if (log == NULL)
 		return FALSE;
 
-	data = g_new(gpointer, 3);
+	data = g_new(gpointer, 4);
 	data[0] = lv;
 	data[1] = log;
 	data[2] = pidgin_treeview_popup_menu_position_func;
+	data[3] = iter;
 
 	log_show_popup_menu(treeview, NULL, data);
 	return TRUE;
--- a/pidgin/plugins/timestamp_format.c	Mon Feb 05 05:48:07 2007 +0000
+++ b/pidgin/plugins/timestamp_format.c	Mon Feb 05 05:49:03 2007 +0000
@@ -57,12 +57,11 @@
                                  gboolean force,
                                  const char *dates)
 {
-	g_return_val_if_fail(conv != NULL, NULL);
 	g_return_val_if_fail(dates != NULL, NULL);
 
 	if (show_date ||
 	    !strcmp(dates, "always") ||
-	    (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && !strcmp(dates, "chats")))
+	    (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && !strcmp(dates, "chats")))
 	{
 		struct tm *tm = localtime(&t);
 		if (force)