finch/plugins/gnthistory.c

Wed, 04 Aug 2021 04:42:29 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 04 Aug 2021 04:42:29 -0500
changeset 41011
90dd69fd1372
parent 40895
9406fe45ca7b
child 41078
84e48180ef67
permissions
-rw-r--r--

Remove the option to disable compiling plugins.

This is a niche feature at best but we can revisit it when we re-enable static
protocol plugins.

Testing Done:
Compiled

Reviewed at https://reviews.imfreedom.org/r/873/

14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
1 /**
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
2 * Copyright (C) 2006 Sadrul Habib Chowdhury <sadrul@users.sourceforge.net>
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
3 *
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
7 * (at your option) any later version.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
8 *
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
12 * GNU General Public License for more details.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
13 *
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16748
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
17 */
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
18
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
19 /* Ripped from gtk/plugins/history.c */
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
20
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
21 #include <glib/gi18n-lib.h>
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
22
40359
ca141ea93b83 Make all of finch use purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 39897
diff changeset
23 #include <purple.h>
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
24
40508
2ebcb8eb5c01 create a global header for finch
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
25 #include <finch.h>
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
26
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 #define HISTORY_PLUGIN_ID "gnt-history"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
28
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
29 #define HISTORY_SIZE (4 * 1024)
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
30
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
31 static void historize(PurpleConversation *c)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
32 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
33 PurpleAccount *account = purple_conversation_get_account(c);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
34 const char *name = purple_conversation_get_name(c);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
35 GList *logs = NULL;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
36 const char *alias = name;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
37 PurpleLogReadFlags flags;
38649
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
38 GDateTime *dt;
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
39 char *date;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
40 char *history;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
41 char *header;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
42 PurpleMessageFlags mflag;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
43
34657
b10d6297ffd5 Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents: 29304
diff changeset
44 if (PURPLE_IS_IM_CONVERSATION(c)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
45 GSList *buddies;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
46 GSList *cur;
27333
49e77c0167d2 Do not blurt out the history if there's already a conversation open.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22334
diff changeset
47 FinchConv *fc = FINCH_CONV(c);
49e77c0167d2 Do not blurt out the history if there's already a conversation open.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22334
diff changeset
48 if (fc->list && fc->list->next) /* We were already in the middle of a conversation. */
49e77c0167d2 Do not blurt out the history if there's already a conversation open.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22334
diff changeset
49 return;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
50
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
51 /* If we're not logging, don't show anything.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
52 * Otherwise, we might show a very old log. */
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 15906
diff changeset
53 if (!purple_prefs_get_bool("/purple/logging/log_ims"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
54 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
55
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
56 /* Find buddies for this conversation. */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34699
diff changeset
57 buddies = purple_blist_find_buddies(account, name);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
58
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
59 /* If we found at least one buddy, save the first buddy's alias. */
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
60 if (buddies != NULL)
34740
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
61 alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(buddies->data));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
62
22334
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
63 for (cur = buddies; cur != NULL; cur = cur->next) {
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
64 PurpleBlistNode *node = cur->data;
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
65 if ((node != NULL) &&
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
66 ((purple_blist_node_get_sibling_prev(node) != NULL) ||
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
67 (purple_blist_node_get_sibling_next(node) != NULL))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
68 PurpleBlistNode *node2;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
69
34740
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
70 alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(node));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
71
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
72 /* We've found a buddy that matches this conversation. It's part of a
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
73 * PurpleContact with more than one PurpleBuddy. Loop through the PurpleBuddies
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
74 * in the contact and get all the logs. */
22334
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
75 for (node2 = purple_blist_node_get_first_child(purple_blist_node_get_parent(node));
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
76 node2 != NULL ; node2 = purple_blist_node_get_sibling_next(node2)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
77 logs = g_list_concat(
22334
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
78 purple_log_get_logs(PURPLE_LOG_IM,
34740
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
79 purple_buddy_get_name(PURPLE_BUDDY(node2)),
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
80 purple_buddy_get_account(PURPLE_BUDDY(node2))),
22334
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
81 logs);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
82 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
83 break;
22334
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
84 }
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
85 }
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
86 g_slist_free(buddies);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
87
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
88 if (logs == NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
89 logs = purple_log_get_logs(PURPLE_LOG_IM, name, account);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
90 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
91 logs = g_list_sort(logs, purple_log_compare);
34657
b10d6297ffd5 Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents: 29304
diff changeset
92 } else if (PURPLE_IS_CHAT_CONVERSATION(c)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
93 /* If we're not logging, don't show anything.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
94 * Otherwise, we might show a very old log. */
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 15906
diff changeset
95 if (!purple_prefs_get_bool("/purple/logging/log_chats"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
96 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
97
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
98 logs = purple_log_get_logs(PURPLE_LOG_CHAT, name, account);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
99 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
100
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
101 if (logs == NULL)
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
102 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
103
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
104 mflag = PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_DELAYED;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
105 history = purple_log_read((PurpleLog*)logs->data, &flags);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
106
38649
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
107 dt = g_date_time_to_local(((PurpleLog *)logs->data)->time);
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
108 date = g_date_time_format(dt, "%c");
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
109 header = g_strdup_printf(_("<b>Conversation with %s on %s:</b><br>"), alias, date);
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34940
diff changeset
110 purple_conversation_write_system_message(c, header, mflag);
38649
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
111 g_free(date);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
112 g_free(header);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
113
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
114 if (flags & PURPLE_LOG_READ_NO_NEWLINE)
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
115 purple_str_strip_char(history, '\n');
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34940
diff changeset
116 purple_conversation_write_system_message(c, history, mflag);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
117 g_free(history);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
118
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34940
diff changeset
119 purple_conversation_write_system_message(c, "<hr>", mflag);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
120
39897
16b440d4ab36 Use g_list_free_full instead of g_list_foreach+g_list_free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39886
diff changeset
121 g_list_free_full(logs, (GDestroyNotify)purple_log_free);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
122 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
123
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
124 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
125 history_prefs_check(PurplePlugin *plugin)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
126 {
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 15906
diff changeset
127 if (!purple_prefs_get_bool("/purple/logging/log_ims") &&
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 15906
diff changeset
128 !purple_prefs_get_bool("/purple/logging/log_chats"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
129 {
21577
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
130 PurpleRequestFields *fields = purple_request_fields_new();
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
131 PurpleRequestFieldGroup *group;
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
132 PurpleRequestField *field;
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
133 struct {
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
134 const char *pref;
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
135 const char *label;
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
136 } prefs[] = {
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
137 {"/purple/logging/log_ims", N_("Log IMs")},
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
138 {"/purple/logging/log_chats", N_("Log chats")},
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
139 {NULL, NULL}
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
140 };
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
141 int iter;
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
142 GList *list = purple_log_logger_get_options();
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
143 const char *system = purple_prefs_get_string("/purple/logging/format");
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
144
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
145 group = purple_request_field_group_new(_("Logging"));
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
146
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
147 field = purple_request_field_list_new("/purple/logging/format", _("Log format"));
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
148 while (list) {
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
149 const char *label = _(list->data);
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
150 list = g_list_delete_link(list, list);
24900
a19d983918c2 Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents: 22334
diff changeset
151 purple_request_field_list_add_icon(field, label, NULL, list->data);
38268
ad4bed105c9f Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
152 if (purple_strequal(system, list->data))
21577
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
153 purple_request_field_list_add_selected(field, label);
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
154 list = g_list_delete_link(list, list);
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
155 }
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
156 purple_request_field_group_add_field(group, field);
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
157
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
158 for (iter = 0; prefs[iter].pref; iter++) {
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
159 field = purple_request_field_bool_new(prefs[iter].pref, _(prefs[iter].label),
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
160 purple_prefs_get_bool(prefs[iter].pref));
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
161 purple_request_field_group_add_field(group, field);
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
162 }
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
163
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
164 purple_request_fields_add_group(fields, group);
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
165
39562
40dca5c3593a Update plugins that were referring to menus with ->'s to use the unicode arrows as well
Gary Kramlich <grim@reaperworld.com>
parents: 38649
diff changeset
166 /* Translators: Please maintain the use of ⇦ or ⇨ to represent the menu hierarchy */
21630
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
167 purple_request_fields(plugin, NULL, _("History Plugin Requires Logging"),
39562
40dca5c3593a Update plugins that were referring to menus with ->'s to use the unicode arrows as well
Gary Kramlich <grim@reaperworld.com>
parents: 38649
diff changeset
168 _("Logging can be enabled from Tools ⇨ Preferences ⇨ Logging.\n\n"
21630
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
169 "Enabling logs for instant messages and/or chats will activate "
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
170 "history for the same conversation type(s)."),
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
171 fields,
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
172 _("OK"), G_CALLBACK(finch_request_save_in_prefs),
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
173 _("Cancel"), NULL,
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 29304
diff changeset
174 NULL, plugin);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
175 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
176 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
177
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
178 static void history_prefs_cb(const char *name, PurplePrefType type,
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
179 gconstpointer val, gpointer data)
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
180 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
181 history_prefs_check((PurplePlugin *)data);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
182 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
183
40895
9406fe45ca7b Convert the Finch plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents: 40508
diff changeset
184 static GPluginPluginInfo *
9406fe45ca7b Convert the Finch plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents: 40508
diff changeset
185 gnt_history_query(GError **error) {
36751
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
186 const gchar * const authors[] = {
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
187 "Sean Egan <seanegan@gmail.com>",
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
188 "Sadrul H Chowdhury <sadrul@users.sourceforge.net>",
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
189 NULL
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
190 };
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
191
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
192 return finch_plugin_info_new(
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
193 "id", HISTORY_PLUGIN_ID,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
194 "name", N_("GntHistory"),
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
195 "version", DISPLAY_VERSION,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
196 "category", N_("User interface"),
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
197 "summary", N_("Shows recently logged conversations in new "
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
198 "conversations."),
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
199 "description", N_("When a new conversation is opened this plugin will "
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
200 "insert the last conversation into the current "
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
201 "conversation."),
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
202 "authors", authors,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
203 "website", PURPLE_WEBSITE,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
204 "abi-version", PURPLE_ABI_VERSION,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
205 NULL
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
206 );
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
207 }
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
208
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
209 static gboolean
40895
9406fe45ca7b Convert the Finch plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents: 40508
diff changeset
210 gnt_history_load(GPluginPlugin *plugin, GError **error) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
211 purple_signal_connect(purple_conversations_get_handle(),
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
212 "conversation-created",
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
213 plugin, PURPLE_CALLBACK(historize), NULL);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
214
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 15906
diff changeset
215 purple_prefs_connect_callback(plugin, "/purple/logging/log_ims",
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
216 history_prefs_cb, plugin);
16478
19107605c565 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents: 15906
diff changeset
217 purple_prefs_connect_callback(plugin, "/purple/logging/log_chats",
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
218 history_prefs_cb, plugin);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
219
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
220 history_prefs_check(plugin);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
221
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
222 return TRUE;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
223 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
224
36751
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
225 static gboolean
40895
9406fe45ca7b Convert the Finch plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents: 40508
diff changeset
226 gnt_history_unload(GPluginPlugin *plugin, GError **error) {
36751
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
227 return TRUE;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
228 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
229
40895
9406fe45ca7b Convert the Finch plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents: 40508
diff changeset
230 GPLUGIN_NATIVE_PLUGIN_DECLARE(gnt_history)

mercurial