annotate plugins/history.c @ 7473:859e4cf4d472

[gaim-migrate @ 8086] This should take care of those C99 thinks wing mentioned committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 11 Nov 2003 05:41:44 +0000
parents 8c0527c91a92
children 66d6f5c4a14a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /* Puts last 4k of log in new conversations a la Everybuddy (and then
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * stolen by Trillian "Pro") */
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6063
diff changeset
4 #include "gtkinternal.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
5
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
6 #include "conversation.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
7 #include "debug.h"
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
8 #include "log.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
9 #include "prefs.h"
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
10 #include "signals.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
11 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
12
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
13 #include "gtkconv.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
14 #include "gtkimhtml.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
15 #include "gtkplugin.h"
4202
59751fe608c5 [gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents: 4113
diff changeset
16
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6063
diff changeset
17 #define HISTORY_PLUGIN_ID "gtk-history"
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
19 #define HISTORY_SIZE (4 * 1024)
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
21 static void historize(GaimConversation *c)
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 {
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5599
diff changeset
23 GaimGtkConversation *gtkconv;
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
24 char *history = NULL;
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7433
diff changeset
25 guint flags;
3602
a9cf9903bd74 [gaim-migrate @ 3713]
Luke Schierer <lschiere@pidgin.im>
parents: 3598
diff changeset
26 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS;
6824
9ae5ce753d63 [gaim-migrate @ 7368]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
27 GtkTextIter end;
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7433
diff changeset
28 GList *logs = gaim_log_get_logs(gaim_conversation_get_name(c),
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7433
diff changeset
29 gaim_conversation_get_account(c));
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7433
diff changeset
30
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
31 if (!logs)
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 return;
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
33 history = gaim_log_read((GaimLog*)logs->data, &flags);
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
34 gtkconv = GAIM_GTK_CONVERSATION(c);
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
35 if (flags & GAIM_LOG_READ_NO_NEWLINE)
3602
a9cf9903bd74 [gaim-migrate @ 3713]
Luke Schierer <lschiere@pidgin.im>
parents: 3598
diff changeset
36 options |= GTK_IMHTML_NO_NEWLINE;
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
37 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options);
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
38 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options);
7251
bdf0e5f71124 [gaim-migrate @ 7828]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
39 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->imhtml)->text_buffer,
bdf0e5f71124 [gaim-migrate @ 7828]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
40 &end);
bdf0e5f71124 [gaim-migrate @ 7828]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
41 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0,
bdf0e5f71124 [gaim-migrate @ 7828]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
42 TRUE, 0, 0);
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
43 g_free(history);
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 }
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
46 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
47 plugin_load(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
48 {
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
49 gaim_signal_connect(gaim_conversations_get_handle(),
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
50 "conversation-created",
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
51 plugin, GAIM_CALLBACK(historize), NULL);
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
53 return TRUE;
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 }
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
56 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
57 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
58 2,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
59 GAIM_PLUGIN_STANDARD,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
60 GAIM_GTK_PLUGIN_TYPE,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
61 0,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
62 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
63 GAIM_PRIORITY_DEFAULT,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
64 HISTORY_PLUGIN_ID,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
65 N_("History"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
66 VERSION,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
67 N_("Shows recently logged conversations in new conversations."),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
68 N_("When a new conversation is opened this plugin will insert the last XXX of the last conversation into the current conversation."),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
69 "Sean Egan <bj91704@binghamton.edu>",
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6063
diff changeset
70 GAIM_WEBSITE,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
71 plugin_load,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
72 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
73 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
74 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
75 NULL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
76 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
77
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
78 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5873
diff changeset
79 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
80 {
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
82
6063
5239a3b4ab33 [gaim-migrate @ 6513]
Nathan Walp <nwalp@pidgin.im>
parents: 5920
diff changeset
83 GAIM_INIT_PLUGIN(history, init_plugin, info)