annotate console/plugins/gnthistory.c @ 14234:04bdbbefbd1d

[gaim-migrate @ 16916] Mark the messages from gnthistory as delayed, and don't print the timestamps for delayed messages (I think it makes sense). committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 20 Aug 2006 19:37:33 +0000
parents 7c560c01b8f9
children 9de2963a8184
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /**
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 * @file gnthistory.c Show log from previous conversation
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 *
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2006 Sadrul Habib Chowdhury <sadrul@users.sourceforge.net>
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 *
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * (at your option) any later version.
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 *
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * GNU General Public License for more details.
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 *
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 */
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 /* Ripped from gtk/plugins/history.c */
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 #include "internal.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 #include "gntgaim.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 #include "conversation.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 #include "debug.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 #include "log.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #include "notify.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #include "prefs.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #include "signals.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 #include "util.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 #include "version.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 #include "gntplugin.h"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 #include <gnttextview.h>
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 #define HISTORY_PLUGIN_ID "gnt-history"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 #define HISTORY_SIZE (4 * 1024)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 static void historize(GaimConversation *c)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 GaimAccount *account = gaim_conversation_get_account(c);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 const char *name = gaim_conversation_get_name(c);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 GaimConversationType convtype;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 GList *logs = NULL;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 const char *alias = name;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 guint flags;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 char *history;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 char *header;
14234
04bdbbefbd1d [gaim-migrate @ 16916]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
53 GaimMessageFlags mflag;
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 convtype = gaim_conversation_get_type(c);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 if (convtype == GAIM_CONV_TYPE_IM)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 GSList *buddies;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 GSList *cur;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 /* If we're not logging, don't show anything.
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 * Otherwise, we might show a very old log. */
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 if (!gaim_prefs_get_bool("/core/logging/log_ims"))
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 return;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 /* Find buddies for this conversation. */
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 buddies = gaim_find_buddies(account, name);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 /* If we found at least one buddy, save the first buddy's alias. */
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70 if (buddies != NULL)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 alias = gaim_buddy_get_contact_alias((GaimBuddy *)buddies->data);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 for (cur = buddies; cur != NULL; cur = cur->next)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 GaimBlistNode *node = cur->data;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL)))
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 GaimBlistNode *node2;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 alias = gaim_buddy_get_contact_alias((GaimBuddy *)node);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 /* We've found a buddy that matches this conversation. It's part of a
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 * GaimContact with more than one GaimBuddy. Loop through the GaimBuddies
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 * in the contact and get all the logs. */
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 for (node2 = node->parent->child ; node2 != NULL ; node2 = node2->next)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 logs = g_list_concat(
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 gaim_log_get_logs(GAIM_LOG_IM,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 gaim_buddy_get_name((GaimBuddy *)node2),
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 gaim_buddy_get_account((GaimBuddy *)node2)),
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 logs);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 break;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 g_slist_free(buddies);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 if (logs == NULL)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 logs = gaim_log_get_logs(GAIM_LOG_IM, name, account);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 else
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 logs = g_list_sort(logs, gaim_log_compare);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 else if (convtype == GAIM_CONV_TYPE_CHAT)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 /* If we're not logging, don't show anything.
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 * Otherwise, we might show a very old log. */
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 if (!gaim_prefs_get_bool("/core/logging/log_chats"))
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 return;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 logs = gaim_log_get_logs(GAIM_LOG_CHAT, name, account);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 if (logs == NULL)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 return;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115
14234
04bdbbefbd1d [gaim-migrate @ 16916]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
116 mflag = GAIM_MESSAGE_NO_LOG | GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_DELAYED;
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 history = gaim_log_read((GaimLog*)logs->data, &flags);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 header = g_strdup_printf(_("<b>Conversation with %s on %s:</b><br>"), alias,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 gaim_date_format_full(localtime(&((GaimLog *)logs->data)->time)));
14234
04bdbbefbd1d [gaim-migrate @ 16916]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
121 gaim_conversation_write(c, "", header, mflag, time(NULL));
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 g_free(header);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 g_strchomp(history);
14234
04bdbbefbd1d [gaim-migrate @ 16916]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
125 gaim_conversation_write(c, "", history, mflag, time(NULL));
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 g_free(history);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127
14234
04bdbbefbd1d [gaim-migrate @ 16916]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14223
diff changeset
128 gaim_conversation_write(c, "", "<hr>", mflag, time(NULL));
14223
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 g_list_foreach(logs, (GFunc)gaim_log_free, NULL);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 g_list_free(logs);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 static void
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 history_prefs_check(GaimPlugin *plugin)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 if (!gaim_prefs_get_bool("/core/logging/log_ims") &&
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 !gaim_prefs_get_bool("/core/logging/log_chats"))
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 gaim_notify_warning(plugin, NULL, _("History Plugin Requires Logging"),
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 _("Logging can be enabled from Tools -> Preferences -> Logging.\n\n"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 "Enabling logs for instant messages and/or chats will activate "
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 "history for the same conversation type(s)."));
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 static void history_prefs_cb(const char *name, GaimPrefType type,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 gconstpointer val, gpointer data)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 history_prefs_check((GaimPlugin *)data);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 static gboolean
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 plugin_load(GaimPlugin *plugin)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
155 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156 gaim_signal_connect(gaim_conversations_get_handle(),
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 "conversation-created",
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 plugin, GAIM_CALLBACK(historize), NULL);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 gaim_prefs_connect_callback(plugin, "/core/logging/log_ims",
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 history_prefs_cb, plugin);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 gaim_prefs_connect_callback(plugin, "/core/logging/log_chats",
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 history_prefs_cb, plugin);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 history_prefs_check(plugin);
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 return TRUE;
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 static GaimPluginInfo info =
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 GAIM_PLUGIN_MAGIC,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 GAIM_MAJOR_VERSION,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 GAIM_MINOR_VERSION,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 GAIM_PLUGIN_STANDARD,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 NULL,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 0,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 NULL,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 GAIM_PRIORITY_DEFAULT,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 HISTORY_PLUGIN_ID,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 N_("GntHistory"),
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 VERSION,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 N_("Shows recently logged conversations in new conversations."),
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 N_("When a new conversation is opened this plugin will insert "
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 "the last conversation into the current conversation."),
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 "Sean Egan <seanegan@gmail.com>\n"
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 "Sadrul H Chowdhury <sadrul@users.sourceforge.net>",
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 GAIM_WEBSITE,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 plugin_load,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 NULL,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 NULL,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 NULL,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 NULL,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 NULL,
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 NULL
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 };
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 static void
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 init_plugin(GaimPlugin *plugin)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 {
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 }
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 GAIM_INIT_PLUGIN(gnthistory, init_plugin, info)
7c560c01b8f9 [gaim-migrate @ 16904]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204