annotate finch/plugins/gnthistory.c @ 24994:50309309bc4d

Use the state-changed signal.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Mon, 05 Jan 2009 09:48:39 +0000
parents 6bb29f94862c
children bd84462b0e17 cc1e35fa774d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gnthistory.c Show log from previous conversation
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2006 Sadrul Habib Chowdhury <sadrul@users.sourceforge.net>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * (at your option) any later version.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * GNU General Public License for more details.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16669
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 /* Ripped from gtk/plugins/history.c */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "internal.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "conversation.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "debug.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "log.h"
21487
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
28 #include "request.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "prefs.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "signals.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "util.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "version.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "gntplugin.h"
21487
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
35 #include "gntrequest.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #define HISTORY_PLUGIN_ID "gnt-history"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #define HISTORY_SIZE (4 * 1024)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
41 static void historize(PurpleConversation *c)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
43 PurpleAccount *account = purple_conversation_get_account(c);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
44 const char *name = purple_conversation_get_name(c);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
45 PurpleConversationType convtype;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 GList *logs = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 const char *alias = name;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
48 PurpleLogReadFlags flags;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 char *history;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 char *header;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
51 PurpleMessageFlags mflag;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
53 convtype = purple_conversation_get_type(c);
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
54 if (convtype == PURPLE_CONV_TYPE_IM) {
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 GSList *buddies;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 GSList *cur;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 /* If we're not logging, don't show anything.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 * Otherwise, we might show a very old log. */
16424
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
60 if (!purple_prefs_get_bool("/purple/logging/log_ims"))
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 /* Find buddies for this conversation. */
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
64 buddies = purple_find_buddies(account, name);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 /* If we found at least one buddy, save the first buddy's alias. */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 if (buddies != NULL)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
68 alias = purple_buddy_get_contact_alias((PurpleBuddy *)buddies->data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
70 for (cur = buddies; cur != NULL; cur = cur->next) {
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
71 PurpleBlistNode *node = cur->data;
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
72 if ((node != NULL) &&
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
73 ((purple_blist_node_get_sibling_prev(node) != NULL) ||
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
74 (purple_blist_node_get_sibling_next(node) != NULL))) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
75 PurpleBlistNode *node2;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
77 alias = purple_buddy_get_contact_alias((PurpleBuddy *)node);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 /* We've found a buddy that matches this conversation. It's part of a
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
80 * PurpleContact with more than one PurpleBuddy. Loop through the PurpleBuddies
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 * in the contact and get all the logs. */
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
82 for (node2 = purple_blist_node_get_first_child(purple_blist_node_get_parent(node));
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
83 node2 != NULL ; node2 = purple_blist_node_get_sibling_next(node2)) {
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 logs = g_list_concat(
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
85 purple_log_get_logs(PURPLE_LOG_IM,
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
86 purple_buddy_get_name((PurpleBuddy *)node2),
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
87 purple_buddy_get_account((PurpleBuddy *)node2)),
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
88 logs);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 break;
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
91 }
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
92 }
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
93 g_slist_free(buddies);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 if (logs == NULL)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
96 logs = purple_log_get_logs(PURPLE_LOG_IM, name, account);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
98 logs = g_list_sort(logs, purple_log_compare);
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
99 } else if (convtype == PURPLE_CONV_TYPE_CHAT) {
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 /* If we're not logging, don't show anything.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 * Otherwise, we might show a very old log. */
16424
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
102 if (!purple_prefs_get_bool("/purple/logging/log_chats"))
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
105 logs = purple_log_get_logs(PURPLE_LOG_CHAT, name, account);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 if (logs == NULL)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
111 mflag = PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_DELAYED;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
112 history = purple_log_read((PurpleLog*)logs->data, &flags);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 header = g_strdup_printf(_("<b>Conversation with %s on %s:</b><br>"), alias,
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
115 purple_date_format_full(localtime(&((PurpleLog *)logs->data)->time)));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
116 purple_conversation_write(c, "", header, mflag, time(NULL));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 g_free(header);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
119 if (flags & PURPLE_LOG_READ_NO_NEWLINE)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
120 purple_str_strip_char(history, '\n');
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
121 purple_conversation_write(c, "", history, mflag, time(NULL));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 g_free(history);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
124 purple_conversation_write(c, "", "<hr>", mflag, time(NULL));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
126 g_list_foreach(logs, (GFunc)purple_log_free, NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 g_list_free(logs);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
131 history_prefs_check(PurplePlugin *plugin)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 {
16424
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
133 if (!purple_prefs_get_bool("/purple/logging/log_ims") &&
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
134 !purple_prefs_get_bool("/purple/logging/log_chats"))
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 {
21487
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
136 PurpleRequestFields *fields = purple_request_fields_new();
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
137 PurpleRequestFieldGroup *group;
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
138 PurpleRequestField *field;
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
139 struct {
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
140 const char *pref;
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
141 const char *label;
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
142 } prefs[] = {
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
143 {"/purple/logging/log_ims", N_("Log IMs")},
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
144 {"/purple/logging/log_chats", N_("Log chats")},
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
145 {NULL, NULL}
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
146 };
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
147 int iter;
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
148 GList *list = purple_log_logger_get_options();
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
149 const char *system = purple_prefs_get_string("/purple/logging/format");
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
150
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
151 group = purple_request_field_group_new(_("Logging"));
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
152
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
153 field = purple_request_field_list_new("/purple/logging/format", _("Log format"));
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
154 while (list) {
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
155 const char *label = _(list->data);
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
156 list = g_list_delete_link(list, list);
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
157 purple_request_field_list_add(field, label, list->data);
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
158 if (system && strcmp(system, list->data) == 0)
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
159 purple_request_field_list_add_selected(field, label);
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
160 list = g_list_delete_link(list, list);
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
161 }
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
162 purple_request_field_group_add_field(group, field);
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
163
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
164 for (iter = 0; prefs[iter].pref; iter++) {
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
165 field = purple_request_field_bool_new(prefs[iter].pref, _(prefs[iter].label),
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
166 purple_prefs_get_bool(prefs[iter].pref));
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
167 purple_request_field_group_add_field(group, field);
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
168 }
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
169
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
170 purple_request_fields_add_group(fields, group);
f2e42e09e635 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21030
diff changeset
171
21560
665e04562de0 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@wiktel.com>
parents: 21487
diff changeset
172 purple_request_fields(plugin, NULL, _("History Plugin Requires Logging"),
665e04562de0 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@wiktel.com>
parents: 21487
diff changeset
173 _("Logging can be enabled from Tools -> Preferences -> Logging.\n\n"
665e04562de0 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@wiktel.com>
parents: 21487
diff changeset
174 "Enabling logs for instant messages and/or chats will activate "
665e04562de0 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@wiktel.com>
parents: 21487
diff changeset
175 "history for the same conversation type(s)."),
665e04562de0 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@wiktel.com>
parents: 21487
diff changeset
176 fields,
665e04562de0 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@wiktel.com>
parents: 21487
diff changeset
177 _("OK"), G_CALLBACK(finch_request_save_in_prefs),
665e04562de0 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@wiktel.com>
parents: 21487
diff changeset
178 _("Cancel"), NULL,
665e04562de0 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@wiktel.com>
parents: 21487
diff changeset
179 NULL, NULL, NULL, plugin);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
183 static void history_prefs_cb(const char *name, PurplePrefType type,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 gconstpointer val, gpointer data)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
186 history_prefs_check((PurplePlugin *)data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 static gboolean
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
190 plugin_load(PurplePlugin *plugin)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
192 purple_signal_connect(purple_conversations_get_handle(),
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 "conversation-created",
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
194 plugin, PURPLE_CALLBACK(historize), NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195
16424
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
196 purple_prefs_connect_callback(plugin, "/purple/logging/log_ims",
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 history_prefs_cb, plugin);
16424
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
198 purple_prefs_connect_callback(plugin, "/purple/logging/log_chats",
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 history_prefs_cb, plugin);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 history_prefs_check(plugin);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 return TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
206 static PurplePluginInfo info =
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
208 PURPLE_PLUGIN_MAGIC,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
209 PURPLE_MAJOR_VERSION,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
210 PURPLE_MINOR_VERSION,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
211 PURPLE_PLUGIN_STANDARD,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 0,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 NULL,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
215 PURPLE_PRIORITY_DEFAULT,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 HISTORY_PLUGIN_ID,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 N_("GntHistory"),
21030
3cc856ca2338 Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents: 19681
diff changeset
218 DISPLAY_VERSION,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 N_("Shows recently logged conversations in new conversations."),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 N_("When a new conversation is opened this plugin will insert "
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 "the last conversation into the current conversation."),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 "Sean Egan <seanegan@gmail.com>\n"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 "Sadrul H Chowdhury <sadrul@users.sourceforge.net>",
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
224 PURPLE_WEBSITE,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 plugin_load,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 NULL,
16669
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16424
diff changeset
231 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16424
diff changeset
232
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16424
diff changeset
233 /* padding */
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16424
diff changeset
234 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16424
diff changeset
235 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16424
diff changeset
236 NULL,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 NULL
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
241 init_plugin(PurplePlugin *plugin)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
245 PURPLE_INIT_PLUGIN(gnthistory, init_plugin, info)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246