Mercurial > pidgin
comparison plugins/history.c @ 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 | 5290afac047c |
children | 519dc2186438 |
comparison
equal
deleted
inserted
replaced
11216:1b32ad61e114 | 11217:f854402837ba |
---|---|
5 #include "gtkgaim.h" | 5 #include "gtkgaim.h" |
6 | 6 |
7 #include "conversation.h" | 7 #include "conversation.h" |
8 #include "debug.h" | 8 #include "debug.h" |
9 #include "log.h" | 9 #include "log.h" |
10 #include "notify.h" | |
10 #include "prefs.h" | 11 #include "prefs.h" |
11 #include "signals.h" | 12 #include "signals.h" |
12 #include "util.h" | 13 #include "util.h" |
13 #include "version.h" | 14 #include "version.h" |
14 | 15 |
46 convtype = gaim_conversation_get_type(c); | 47 convtype = gaim_conversation_get_type(c); |
47 if (convtype == GAIM_CONV_IM) | 48 if (convtype == GAIM_CONV_IM) |
48 { | 49 { |
49 GSList *buddies; | 50 GSList *buddies; |
50 GSList *cur; | 51 GSList *cur; |
52 | |
53 /* If we're not logging, don't show anything. | |
54 * Otherwise, we might show a very old log. */ | |
55 if (!gaim_prefs_get_bool("/core/logging/log_ims")) | |
56 return; | |
51 | 57 |
52 /* Find buddies for this conversation. */ | 58 /* Find buddies for this conversation. */ |
53 buddies = gaim_find_buddies(account, name); | 59 buddies = gaim_find_buddies(account, name); |
54 | 60 |
55 /* If we found at least one buddy, save the first buddy's alias. */ | 61 /* If we found at least one buddy, save the first buddy's alias. */ |
85 logs = gaim_log_get_logs(GAIM_LOG_IM, name, account); | 91 logs = gaim_log_get_logs(GAIM_LOG_IM, name, account); |
86 else | 92 else |
87 logs = g_list_sort(logs, gaim_log_compare); | 93 logs = g_list_sort(logs, gaim_log_compare); |
88 } | 94 } |
89 else if (convtype == GAIM_CONV_CHAT) | 95 else if (convtype == GAIM_CONV_CHAT) |
96 { | |
97 /* If we're not logging, don't show anything. | |
98 * Otherwise, we might show a very old log. */ | |
99 if (!gaim_prefs_get_bool("/core/logging/log_chats")) | |
100 return; | |
101 | |
90 logs = gaim_log_get_logs(GAIM_LOG_CHAT, name, account); | 102 logs = gaim_log_get_logs(GAIM_LOG_CHAT, name, account); |
103 } | |
91 | 104 |
92 if (logs == NULL) | 105 if (logs == NULL) |
93 return; | 106 return; |
94 | 107 |
95 history = gaim_log_read((GaimLog*)logs->data, &flags); | 108 history = gaim_log_read((GaimLog*)logs->data, &flags); |
113 | 126 |
114 g_list_foreach(logs, (GFunc)gaim_log_free, NULL); | 127 g_list_foreach(logs, (GFunc)gaim_log_free, NULL); |
115 g_list_free(logs); | 128 g_list_free(logs); |
116 } | 129 } |
117 | 130 |
131 static void | |
132 history_prefs_check(GaimPlugin *plugin) | |
133 { | |
134 if (!gaim_prefs_get_bool("/core/logging/log_ims") && | |
135 !gaim_prefs_get_bool("/core/logging/log_chats")) | |
136 { | |
137 gaim_notify_warning(plugin, NULL, _("History Plugin Requires Logging"), | |
138 _("Logging can be enabled from Tools -> Preferences -> Logging.\n\n" | |
139 "Enabling logs for instant messages and/or chats will activate " | |
140 "history for the same conversation type(s).")); | |
141 } | |
142 } | |
143 | |
144 static void history_prefs_cb(const char *name, GaimPrefType type, gpointer val, gpointer data) | |
145 { | |
146 history_prefs_check((GaimPlugin *)data); | |
147 } | |
148 | |
118 static gboolean | 149 static gboolean |
119 plugin_load(GaimPlugin *plugin) | 150 plugin_load(GaimPlugin *plugin) |
120 { | 151 { |
121 gaim_signal_connect(gaim_conversations_get_handle(), | 152 gaim_signal_connect(gaim_conversations_get_handle(), |
122 "conversation-created", | 153 "conversation-created", |
123 plugin, GAIM_CALLBACK(historize), NULL); | 154 plugin, GAIM_CALLBACK(historize), NULL); |
155 | |
156 gaim_prefs_connect_callback(plugin, "/core/logging/log_ims", | |
157 history_prefs_cb, plugin); | |
158 gaim_prefs_connect_callback(plugin, "/core/logging/log_chats", | |
159 history_prefs_cb, plugin); | |
160 | |
161 history_prefs_check(plugin); | |
124 | 162 |
125 return TRUE; | 163 return TRUE; |
126 } | 164 } |
127 | 165 |
128 static GaimPluginInfo info = | 166 static GaimPluginInfo info = |
137 GAIM_PRIORITY_DEFAULT, | 175 GAIM_PRIORITY_DEFAULT, |
138 HISTORY_PLUGIN_ID, | 176 HISTORY_PLUGIN_ID, |
139 N_("History"), | 177 N_("History"), |
140 VERSION, | 178 VERSION, |
141 N_("Shows recently logged conversations in new conversations."), | 179 N_("Shows recently logged conversations in new conversations."), |
142 N_("When a new conversation is opened this plugin will insert the last conversation into the current conversation."), | 180 N_("When a new conversation is opened this plugin will insert " |
181 "the last conversation into the current conversation.\n\n" | |
182 "The history plugin requires logging be enabled. Logging can " | |
183 "be enabled from Tools -> Preferences -> Logging. Enabling logs " | |
184 "for instant messages and/or chats will activate history for " | |
185 "the same conversation type(s)." | |
186 ), | |
143 "Sean Egan <bj91704@binghamton.edu>", | 187 "Sean Egan <bj91704@binghamton.edu>", |
144 GAIM_WEBSITE, | 188 GAIM_WEBSITE, |
145 plugin_load, | 189 plugin_load, |
146 NULL, | 190 NULL, |
147 NULL, | 191 NULL, |