finch/plugins/gnthistory.c

Fri, 13 Sep 2013 18:54:07 +0530

author
Ankit Vani <a@nevitus.org>
date
Fri, 13 Sep 2013 18:54:07 +0530
branch
soc.2013.gobjectification.plugins
changeset 36707
ace4d80b11cd
parent 34940
c0aef3b64c56
child 36089
c035b9a63457
child 36751
a9f6ae7c308e
permissions
-rw-r--r--

Backed out changeset 2961685df856

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 * @file gnthistory.c Show log from previous conversation
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 * Copyright (C) 2006 Sadrul Habib Chowdhury <sadrul@users.sourceforge.net>
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
5 *
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
6 * 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
7 * 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
8 * the Free Software Foundation; either version 2 of the License, or
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
10 *
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
11 * 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
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
15 *
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
16 * 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
17 * 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
18 * 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
19 */
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 /* Ripped from gtk/plugins/history.c */
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
22
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
23 #include "internal.h"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
24
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
25 #include "conversation.h"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
26 #include "debug.h"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
27 #include "log.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
28 #include "request.h"
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
29 #include "prefs.h"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
30 #include "signals.h"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
31 #include "util.h"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
32 #include "version.h"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
33
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
34 #include "gntconv.h"
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
35 #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
36 #include "gntrequest.h"
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
37
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
38 #define HISTORY_PLUGIN_ID "gnt-history"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
39
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
40 #define HISTORY_SIZE (4 * 1024)
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
41
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
42 static void historize(PurpleConversation *c)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
43 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
44 PurpleAccount *account = purple_conversation_get_account(c);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
45 const char *name = purple_conversation_get_name(c);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
46 GList *logs = NULL;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
47 const char *alias = name;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
48 PurpleLogReadFlags flags;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
49 char *history;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
50 char *header;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
51 PurpleMessageFlags mflag;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
52
34657
b10d6297ffd5 Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents: 29304
diff changeset
53 if (PURPLE_IS_IM_CONVERSATION(c)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
54 GSList *buddies;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
55 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
56 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
57 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
58 return;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
59
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
60 /* If we're not logging, don't show anything.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
61 * 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
62 if (!purple_prefs_get_bool("/purple/logging/log_ims"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
63 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
64
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
65 /* 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
66 buddies = purple_blist_find_buddies(account, name);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
67
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
68 /* 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
69 if (buddies != NULL)
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(buddies->data));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
71
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
72 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
73 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
74 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
75 ((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
76 (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
77 PurpleBlistNode *node2;
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
78
34740
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
79 alias = purple_buddy_get_contact_alias(PURPLE_BUDDY(node));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
80
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
81 /* 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
82 * PurpleContact with more than one PurpleBuddy. Loop through the PurpleBuddies
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
83 * 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
84 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
85 node2 != NULL ; node2 = purple_blist_node_get_sibling_next(node2)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
86 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
87 purple_log_get_logs(PURPLE_LOG_IM,
34740
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
88 purple_buddy_get_name(PURPLE_BUDDY(node2)),
9401f9b1ca68 Used GObject-style casts in plugins.
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
89 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
90 logs);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
91 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
92 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
93 }
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
94 }
6eec04817c0d Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21630
diff changeset
95 g_slist_free(buddies);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
96
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
97 if (logs == NULL)
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_IM, name, account);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
99 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
100 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
101 } else if (PURPLE_IS_CHAT_CONVERSATION(c)) {
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
102 /* If we're not logging, don't show anything.
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
103 * 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
104 if (!purple_prefs_get_bool("/purple/logging/log_chats"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
105 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
106
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
107 logs = purple_log_get_logs(PURPLE_LOG_CHAT, name, account);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
108 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
109
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
110 if (logs == NULL)
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
111 return;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
112
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
113 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
114 history = purple_log_read((PurpleLog*)logs->data, &flags);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
115
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
116 header = g_strdup_printf(_("<b>Conversation with %s on %s:</b><br>"), alias,
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
117 purple_date_format_full(localtime(&((PurpleLog *)logs->data)->time)));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
118 purple_conversation_write(c, "", header, mflag, time(NULL));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
119 g_free(header);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
120
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
121 if (flags & PURPLE_LOG_READ_NO_NEWLINE)
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
122 purple_str_strip_char(history, '\n');
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
123 purple_conversation_write(c, "", history, mflag, time(NULL));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
124 g_free(history);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
125
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
126 purple_conversation_write(c, "", "<hr>", mflag, time(NULL));
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
127
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
128 g_list_foreach(logs, (GFunc)purple_log_free, NULL);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
129 g_list_free(logs);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
130 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
131
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
132 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
133 history_prefs_check(PurplePlugin *plugin)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
134 {
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
135 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
136 !purple_prefs_get_bool("/purple/logging/log_chats"))
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
137 {
21577
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
138 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
139 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
140 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
141 struct {
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
142 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
143 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
144 } prefs[] = {
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
145 {"/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
146 {"/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
147 {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
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 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
150 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
151 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
152
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
153 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
154
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
155 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
156 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
157 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
158 list = g_list_delete_link(list, list);
24900
a19d983918c2 Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents: 22334
diff changeset
159 purple_request_field_list_add_icon(field, label, NULL, 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
160 if (system && strcmp(system, list->data) == 0)
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_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
162 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
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_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
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 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
167 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
168 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
169 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
170 }
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
171
bb3567e8bb75 Allow turning on logging when enabling the gnthistory plugin. (this doesn't
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20288
diff changeset
172 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
173
21630
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
174 purple_request_fields(plugin, NULL, _("History Plugin Requires Logging"),
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
175 _("Logging can be enabled from Tools -> Preferences -> Logging.\n\n"
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
176 "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
177 "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
178 fields,
591a79c1b295 This merge has the effect of reverting the hinting code from trunk.
Richard Laager <rlaager@pidgin.im>
parents: 21577
diff changeset
179 _("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
180 _("Cancel"), NULL,
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 29304
diff changeset
181 NULL, plugin);
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 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
184
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
185 static void history_prefs_cb(const char *name, PurplePrefType type,
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
186 gconstpointer val, gpointer data)
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
187 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
188 history_prefs_check((PurplePlugin *)data);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
189 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
190
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
191 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
192 plugin_load(PurplePlugin *plugin)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
193 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
194 purple_signal_connect(purple_conversations_get_handle(),
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
195 "conversation-created",
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
196 plugin, PURPLE_CALLBACK(historize), NULL);
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
197
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
198 purple_prefs_connect_callback(plugin, "/purple/logging/log_ims",
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
199 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
200 purple_prefs_connect_callback(plugin, "/purple/logging/log_chats",
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
201 history_prefs_cb, plugin);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
202
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
203 history_prefs_check(plugin);
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
204
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
205 return TRUE;
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
206 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
207
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
208 static PurplePluginInfo info =
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
209 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
210 PURPLE_PLUGIN_MAGIC,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
211 PURPLE_MAJOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
212 PURPLE_MINOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
213 PURPLE_PLUGIN_STANDARD,
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
214 NULL,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
215 0,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
216 NULL,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
217 PURPLE_PRIORITY_DEFAULT,
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
218 HISTORY_PLUGIN_ID,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
219 N_("GntHistory"),
20288
5ca925a094e2 applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
220 DISPLAY_VERSION,
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
221 N_("Shows recently logged conversations in new conversations."),
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
222 N_("When a new conversation is opened this plugin will insert "
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
223 "the last conversation into the current conversation."),
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
224 "Sean Egan <seanegan@gmail.com>\n"
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
225 "Sadrul H Chowdhury <sadrul@users.sourceforge.net>",
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
226 PURPLE_WEBSITE,
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
227 plugin_load,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
228 NULL,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
229 NULL,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
230 NULL,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
231 NULL,
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
232 NULL,
16748
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16478
diff changeset
233 NULL,
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16478
diff changeset
234
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16478
diff changeset
235 /* padding */
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16478
diff changeset
236 NULL,
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16478
diff changeset
237 NULL,
f8e1573bfde0 And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16478
diff changeset
238 NULL,
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
239 NULL
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
240 };
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
241
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
242 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
243 init_plugin(PurplePlugin *plugin)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
244 {
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
245 }
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
246
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15878
diff changeset
247 PURPLE_INIT_PLUGIN(gnthistory, init_plugin, info)
14285
f8331daf743d [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff changeset
248

mercurial