finch/plugins/gnthistory.c

Fri, 01 May 2020 04:51:01 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 01 May 2020 04:51:01 -0500
changeset 40359
ca141ea93b83
parent 39897
16b440d4ab36
child 40439
e9838d634d5e
permissions
-rw-r--r--

Make all of finch use purple.h

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
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
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
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
25 #include "gntconv.h"
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
26 #include "gntplugin.h"
21577
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
27 #include "gntrequest.h"
14285
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_PLUGIN_ID "gnt-history"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
30
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
31 #define HISTORY_SIZE (4 * 1024)
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 static void historize(PurpleConversation *c)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
34 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
35 PurpleAccount *account = purple_conversation_get_account(c);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
36 const char *name = purple_conversation_get_name(c);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
37 GList *logs = NULL;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
38 const char *alias = name;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
39 PurpleLogReadFlags flags;
38649
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
40 GDateTime *dt;
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
41 char *date;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
42 char *history;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
43 char *header;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
44 PurpleMessageFlags mflag;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
45
34657
b10d6297ffd5 Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents: 29304
diff changeset
46 if (PURPLE_IS_IM_CONVERSATION(c)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
47 GSList *buddies;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
48 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
49 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
50 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
51 return;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
52
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
53 /* If we're not logging, don't show anything.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
54 * 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
55 if (!purple_prefs_get_bool("/purple/logging/log_ims"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
56 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
57
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
58 /* 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
59 buddies = purple_blist_find_buddies(account, name);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
60
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
61 /* 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
62 if (buddies != NULL)
34740
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
63 alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(buddies->data));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
64
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
65 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
66 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
67 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
68 ((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
69 (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
70 PurpleBlistNode *node2;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
71
34740
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
72 alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(node));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
73
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
74 /* 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
75 * PurpleContact with more than one PurpleBuddy. Loop through the PurpleBuddies
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
76 * 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
77 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
78 node2 != NULL ; node2 = purple_blist_node_get_sibling_next(node2)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
79 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
80 purple_log_get_logs(PURPLE_LOG_IM,
34740
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
81 purple_buddy_get_name(PURPLE_BUDDY(node2)),
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
82 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
83 logs);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
84 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
85 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
86 }
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
87 }
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
88 g_slist_free(buddies);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
89
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
90 if (logs == NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
91 logs = purple_log_get_logs(PURPLE_LOG_IM, name, account);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
92 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
93 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
94 } else if (PURPLE_IS_CHAT_CONVERSATION(c)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
95 /* If we're not logging, don't show anything.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
96 * 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
97 if (!purple_prefs_get_bool("/purple/logging/log_chats"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
98 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
99
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
100 logs = purple_log_get_logs(PURPLE_LOG_CHAT, name, account);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
101 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
102
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
103 if (logs == NULL)
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
104 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
105
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
106 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
107 history = purple_log_read((PurpleLog*)logs->data, &flags);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
108
38649
0491c21146e5 Fix one last use of time_t for logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38358
diff changeset
109 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
110 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
111 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
112 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
113 g_free(date);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
114 g_free(header);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
115
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
116 if (flags & PURPLE_LOG_READ_NO_NEWLINE)
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
117 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
118 purple_conversation_write_system_message(c, history, mflag);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
119 g_free(history);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
120
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34940
diff changeset
121 purple_conversation_write_system_message(c, "<hr>", mflag);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
122
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
123 g_list_free_full(logs, (GDestroyNotify)purple_log_free);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
124 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
125
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
126 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
127 history_prefs_check(PurplePlugin *plugin)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
128 {
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
129 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
130 !purple_prefs_get_bool("/purple/logging/log_chats"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
131 {
21577
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
132 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
133 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
134 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
135 struct {
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
136 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
137 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
138 } prefs[] = {
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
139 {"/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
140 {"/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
141 {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
142 };
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
143 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
144 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
145 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
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 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
148
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
149 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
150 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
151 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
152 list = g_list_delete_link(list, list);
24900
a19d983918c2 Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents: 22334
diff changeset
153 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
154 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
155 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
156 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
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 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
159
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
160 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
161 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
162 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
163 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
164 }
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
165
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
166 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
167
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 /* 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
169 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
170 _("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
171 "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
172 "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
173 fields,
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
174 _("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
175 _("Cancel"), NULL,
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 29304
diff changeset
176 NULL, plugin);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
177 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
178 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
179
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
180 static void history_prefs_cb(const char *name, PurplePrefType type,
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
181 gconstpointer val, gpointer data)
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
182 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
183 history_prefs_check((PurplePlugin *)data);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
184 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
185
36751
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
186 static FinchPluginInfo *
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
187 plugin_query(GError **error)
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
188 {
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
189 const gchar * const authors[] = {
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
190 "Sean Egan <seanegan@gmail.com>",
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
191 "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
192 NULL
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
193 };
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
194
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
195 return finch_plugin_info_new(
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
196 "id", HISTORY_PLUGIN_ID,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
197 "name", N_("GntHistory"),
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
198 "version", DISPLAY_VERSION,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
199 "category", N_("User interface"),
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
200 "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
201 "conversations."),
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
202 "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
203 "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
204 "conversation."),
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
205 "authors", authors,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
206 "website", PURPLE_WEBSITE,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
207 "abi-version", PURPLE_ABI_VERSION,
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
208 NULL
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
209 );
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
210 }
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
211
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
212 static gboolean
36751
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
213 plugin_load(PurplePlugin *plugin, GError **error)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
214 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
215 purple_signal_connect(purple_conversations_get_handle(),
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
216 "conversation-created",
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
217 plugin, PURPLE_CALLBACK(historize), NULL);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
218
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
219 purple_prefs_connect_callback(plugin, "/purple/logging/log_ims",
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
220 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
221 purple_prefs_connect_callback(plugin, "/purple/logging/log_chats",
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
222 history_prefs_cb, plugin);
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 history_prefs_check(plugin);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
225
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
226 return TRUE;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
227 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
228
36751
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
229 static gboolean
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
230 plugin_unload(PurplePlugin *plugin, GError **error)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
231 {
36751
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
232 return TRUE;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
233 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
234
36751
a9f6ae7c308e Refactored finch plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
235 PURPLE_PLUGIN_INIT(gnthistory, plugin_query, plugin_load, plugin_unload);

mercurial