Wed, 05 Nov 2003 06:39:05 +0000
[gaim-migrate @ 8038]
Because all the log reading and writing is abstracted, it makes it real easy
to tell Gaim, "give me entire contents of the last conversation," which is
useful for, say, a history.c plugin. This code is now much simpler, and it
took no time at all to port it.
Sort-by-log will be a bit harder.
And because two people asked me within a minute of me committing it, there
exists an "old log" GaimLogLogger that doesn't write logs, but can list and
read them. So, you'll be able to seamlessly see your old logs along with
your new logs together in the log viewer.
| 3598 | 1 | /* Puts last 4k of log in new conversations a la Everybuddy (and then |
| 2 | * stolen by Trillian "Pro") */ | |
| 3 | ||
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
4 | #include "gtkinternal.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
6 | #include "conversation.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
7 | #include "debug.h" |
| 7433 | 8 | #include "log.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
9 | #include "prefs.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
10 | #include "signals.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
11 | #include "util.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
12 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
13 | #include "gtkconv.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
14 | #include "gtkimhtml.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
15 | #include "gtkplugin.h" |
|
4202
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
16 | |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
17 | #define HISTORY_PLUGIN_ID "gtk-history" |
| 3598 | 18 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
19 | #define HISTORY_SIZE (4 * 1024) |
| 3598 | 20 | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
21 | static void historize(GaimConversation *c) |
| 3598 | 22 | { |
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5599
diff
changeset
|
23 | GaimGtkConversation *gtkconv; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
24 | const char *name = gaim_conversation_get_name(c); |
| 7433 | 25 | char *history = NULL; |
| 26 | int flags; | |
| 3602 | 27 | GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; |
| 6824 | 28 | GtkTextIter end; |
| 7433 | 29 | GList *logs = gaim_log_get_logs(gaim_conversation_get_name(c), gaim_conversation_get_account(c)); |
| 30 | if (!logs) | |
| 3598 | 31 | return; |
| 7433 | 32 | history = gaim_log_read((GaimLog*)logs->data, &flags); |
| 33 | gtkconv = GAIM_GTK_CONVERSATION(c); | |
| 34 | if (flags & GAIM_LOG_READ_NO_NEWLINE) | |
| 3602 | 35 | options |= GTK_IMHTML_NO_NEWLINE; |
| 7433 | 36 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options); |
| 37 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options); | |
| 7251 | 38 | gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
| 39 | &end); | |
| 40 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, | |
| 41 | TRUE, 0, 0); | |
| 7433 | 42 | g_free(history); |
| 3598 | 43 | } |
| 44 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
45 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
46 | plugin_load(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
47 | { |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
48 | gaim_signal_connect(gaim_conversations_get_handle(), |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
49 | "conversation-created", |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
50 | plugin, GAIM_CALLBACK(historize), NULL); |
| 3598 | 51 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
52 | return TRUE; |
| 3598 | 53 | } |
| 54 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
55 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
56 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
57 | 2, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
58 | GAIM_PLUGIN_STANDARD, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
59 | GAIM_GTK_PLUGIN_TYPE, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
60 | 0, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
61 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
62 | GAIM_PRIORITY_DEFAULT, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
63 | HISTORY_PLUGIN_ID, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
64 | N_("History"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
65 | VERSION, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
66 | N_("Shows recently logged conversations in new conversations."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
67 | N_("When a new conversation is opened this plugin will insert the last XXX of the last conversation into the current conversation."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
68 | "Sean Egan <bj91704@binghamton.edu>", |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
69 | GAIM_WEBSITE, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
70 | plugin_load, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
71 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
72 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
73 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
74 | NULL |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
75 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
76 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
77 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
78 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
79 | { |
| 3598 | 80 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
81 | |
| 6063 | 82 | GAIM_INIT_PLUGIN(history, init_plugin, info) |