Tue, 31 Aug 2004 18:28:35 +0000
[gaim-migrate @ 10815]
(14:24:22) datallah: LSchiere2:
http://www.butfer.com/gaim-patches/log_filename_escaping.patch deals with
creating logs for screennames that have characters that are not valid for
filenames
(14:25:34) datallah: i may write a conversion script for existing log files
(particularly because it will cause all irc and yahoo chats not to be
found)
(14:25:49) datallah: oh.. not irc chats... only yahoo chats
(14:26:10) LSchiere2: can yahoo chats be found now?
(14:26:35) datallah: yeah... they all have a ':' in them which is not a
valid filename character in win32
(14:26:51) LSchiere2: i see. so they can be found on unix but not on win32
(14:27:51) datallah: LSchiere2: yeah, as far as i know
committer: Luke Schierer <lschiere@pidgin.im>
| 3598 | 1 | /* Puts last 4k of log in new conversations a la Everybuddy (and then |
| 2 | * stolen by Trillian "Pro") */ | |
| 3 | ||
| 9791 | 4 | #include "internal.h" |
| 5 | #include "gtkgaim.h" | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
6 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
7 | #include "conversation.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
8 | #include "debug.h" |
| 7433 | 9 | #include "log.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
10 | #include "prefs.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
11 | #include "signals.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
12 | #include "util.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
13 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
14 | #include "gtkconv.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
15 | #include "gtkimhtml.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
16 | #include "gtkplugin.h" |
|
4202
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
17 | |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
18 | #define HISTORY_PLUGIN_ID "gtk-history" |
| 3598 | 19 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
20 | #define HISTORY_SIZE (4 * 1024) |
| 3598 | 21 | |
| 8913 | 22 | static gboolean _scroll_imhtml_to_end(gpointer data) |
| 23 | { | |
| 24 | GtkIMHtml *imhtml = data; | |
| 25 | gtk_imhtml_scroll_to_end(GTK_IMHTML(imhtml)); | |
| 26 | g_object_unref(G_OBJECT(imhtml)); | |
| 27 | return FALSE; | |
| 28 | } | |
| 29 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
30 | static void historize(GaimConversation *c) |
| 3598 | 31 | { |
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5599
diff
changeset
|
32 | GaimGtkConversation *gtkconv; |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
33 | GaimConversationType convtype; |
| 7433 | 34 | char *history = NULL; |
| 7440 | 35 | guint flags; |
| 3602 | 36 | GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
37 | GList *logs = NULL; |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
38 | |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
39 | convtype = gaim_conversation_get_type(c); |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
40 | if (convtype == GAIM_CONV_IM) |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
41 | logs = gaim_log_get_logs(GAIM_LOG_IM, |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
42 | gaim_conversation_get_name(c), gaim_conversation_get_account(c)); |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
43 | else if (convtype == GAIM_CONV_CHAT) |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
44 | logs = gaim_log_get_logs(GAIM_LOG_CHAT, |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
45 | gaim_conversation_get_name(c), gaim_conversation_get_account(c)); |
| 7440 | 46 | |
| 7433 | 47 | if (!logs) |
| 3598 | 48 | return; |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
49 | |
| 7433 | 50 | history = gaim_log_read((GaimLog*)logs->data, &flags); |
| 51 | gtkconv = GAIM_GTK_CONVERSATION(c); | |
| 52 | if (flags & GAIM_LOG_READ_NO_NEWLINE) | |
| 3602 | 53 | options |= GTK_IMHTML_NO_NEWLINE; |
| 7433 | 54 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options); |
| 55 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options); | |
| 8913 | 56 | g_object_ref(G_OBJECT(gtkconv->imhtml)); |
| 57 | g_idle_add(_scroll_imhtml_to_end, gtkconv->imhtml); | |
| 7433 | 58 | g_free(history); |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
59 | |
| 7535 | 60 | while (logs) { |
| 7533 | 61 | GaimLog *log = logs->data; |
| 7535 | 62 | GList *logs2; |
| 7685 | 63 | gaim_log_free(log); |
| 7535 | 64 | logs2 = logs->next; |
| 65 | g_list_free_1(logs); | |
| 66 | logs = logs2; | |
| 7533 | 67 | } |
| 3598 | 68 | } |
| 69 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
70 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
71 | plugin_load(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
72 | { |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
73 | gaim_signal_connect(gaim_conversations_get_handle(), |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
74 | "conversation-created", |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
75 | plugin, GAIM_CALLBACK(historize), NULL); |
| 3598 | 76 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
77 | return TRUE; |
| 3598 | 78 | } |
| 79 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
80 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
81 | { |
|
8749
fb487e9e101a
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8729
diff
changeset
|
82 | GAIM_PLUGIN_API_VERSION, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
83 | GAIM_PLUGIN_STANDARD, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
84 | GAIM_GTK_PLUGIN_TYPE, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
85 | 0, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
86 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
87 | GAIM_PRIORITY_DEFAULT, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
88 | HISTORY_PLUGIN_ID, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
89 | N_("History"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
90 | VERSION, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
91 | N_("Shows recently logged conversations in new conversations."), |
| 7666 | 92 | N_("When a new conversation is opened this plugin will insert the last conversation into the current conversation."), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
93 | "Sean Egan <bj91704@binghamton.edu>", |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
94 | GAIM_WEBSITE, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
95 | plugin_load, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
96 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
97 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
98 | NULL, |
| 8993 | 99 | NULL, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
100 | NULL |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
101 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
102 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
103 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
104 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
105 | { |
| 3598 | 106 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
107 | |
| 6063 | 108 | GAIM_INIT_PLUGIN(history, init_plugin, info) |