changeset 11217:f854402837ba

[gaim-migrate @ 13349] The history plugin really should require logging be on. Otherwise, you can end up seeing a really old conversation instead of the "last" conversation. I've made this change. Now, the history plugin can't be silently failing to do its job if logging is disabled. I've coded it to display a warning dialog under the following conditions: 1) The user enables the history plugin and neither IM nor chat logging is enabled. 2) The user starts Gaim with the history plugin and no logging enabled. 3) The user disables logging while the history plugin is enabled. I thought about automatically disabling the history plugin after displaying the dialog, but I imagine (hope?) people will enable the history plugin, see the dialog, and enable logging. If this is what happens, they would be confused if the history plugin automatically disabled itself when it displayed the dialog. This should address RFE 1241878, "History plugin should have a more helpful description". committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 09 Aug 2005 05:20:07 +0000
parents 1b32ad61e114
children ed017b9c532d
files plugins/history.c
diffstat 1 files changed, 45 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/history.c	Tue Aug 09 04:28:59 2005 +0000
+++ b/plugins/history.c	Tue Aug 09 05:20:07 2005 +0000
@@ -7,6 +7,7 @@
 #include "conversation.h"
 #include "debug.h"
 #include "log.h"
+#include "notify.h"
 #include "prefs.h"
 #include "signals.h"
 #include "util.h"
@@ -49,6 +50,11 @@
 		GSList *buddies;
 		GSList *cur;
 
+		/* If we're not logging, don't show anything.
+		 * Otherwise, we might show a very old log. */
+		if (!gaim_prefs_get_bool("/core/logging/log_ims"))
+			return;
+
 		/* Find buddies for this conversation. */
 	        buddies = gaim_find_buddies(account, name);
 
@@ -87,7 +93,14 @@
         		logs = g_list_sort(logs, gaim_log_compare);
 	}
 	else if (convtype == GAIM_CONV_CHAT)
+	{
+		/* If we're not logging, don't show anything.
+		 * Otherwise, we might show a very old log. */
+		if (!gaim_prefs_get_bool("/core/logging/log_chats"))
+			return;
+
 		logs = gaim_log_get_logs(GAIM_LOG_CHAT, name, account);
+	}
 
 	if (logs == NULL)
 		return;
@@ -115,6 +128,24 @@
 	g_list_free(logs);
 }
 
+static void
+history_prefs_check(GaimPlugin *plugin)
+{
+	if (!gaim_prefs_get_bool("/core/logging/log_ims") &&
+	    !gaim_prefs_get_bool("/core/logging/log_chats"))
+	{
+		gaim_notify_warning(plugin, NULL, _("History Plugin Requires Logging"),
+							_("Logging can be enabled from Tools -> Preferences -> Logging.\n\n"
+							  "Enabling logs for instant messages and/or chats will activate "
+							  "history for the same conversation type(s)."));
+	}
+}
+
+static void history_prefs_cb(const char *name, GaimPrefType type, gpointer val, gpointer data)
+{
+	history_prefs_check((GaimPlugin *)data);
+}
+
 static gboolean
 plugin_load(GaimPlugin *plugin)
 {
@@ -122,6 +153,13 @@
 						"conversation-created",
 						plugin, GAIM_CALLBACK(historize), NULL);
 
+	gaim_prefs_connect_callback(plugin, "/core/logging/log_ims",
+								history_prefs_cb, plugin);
+	gaim_prefs_connect_callback(plugin, "/core/logging/log_chats",
+								history_prefs_cb, plugin);
+
+	history_prefs_check(plugin);
+
 	return TRUE;
 }
 
@@ -139,7 +177,13 @@
 	N_("History"),
 	VERSION,
 	N_("Shows recently logged conversations in new conversations."),
-	N_("When a new conversation is opened this plugin will insert the last conversation into the current conversation."),
+	N_("When a new conversation is opened this plugin will insert "
+	   "the last conversation into the current conversation.\n\n"
+       "The history plugin requires logging be enabled. Logging can "
+	   "be enabled from Tools -> Preferences -> Logging. Enabling logs "
+	   "for instant messages and/or chats will activate history for "
+	   "the same conversation type(s)."
+	),
 	"Sean Egan <bj91704@binghamton.edu>",
 	GAIM_WEBSITE,
 	plugin_load,