Mon, 05 May 2003 23:30:42 +0000
[gaim-migrate @ 5672]
<malsyned> Hey, is this a bug? when I block someone and then close their
window, I'm told "Your message to (null) did not get sent: In local permit/deny"
<faceprint> malsyned: what protocol?
<malsyned> Oscar
<faceprint> yes, that's a bug
<SeanEgan> probably a typing notification thing?
This fixes that.
And now I should get back to the how you say... ah yes, "studying."
| 3598 | 1 | /* Puts last 4k of log in new conversations a la Everybuddy (and then |
| 2 | * stolen by Trillian "Pro") */ | |
| 3 | ||
|
4202
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
4 | #include "config.h" |
|
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
5 | |
| 3598 | 6 | #include "gaim.h" |
| 7 | #include "gtkimhtml.h" | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
8 | #include "gtkplugin.h" |
| 3598 | 9 | #include <sys/stat.h> |
| 10 | #include <unistd.h> | |
| 4235 | 11 | #include <string.h> |
| 3598 | 12 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
13 | #define HISTORY_PLUGIN_ID "core-history" |
| 3598 | 14 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
15 | #define HISTORY_SIZE (4 * 1024) |
| 3598 | 16 | |
| 17 | void historize (char *name, void *data) | |
| 18 | { | |
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4235
diff
changeset
|
19 | struct gaim_conversation *c = gaim_find_conversation(name); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4235
diff
changeset
|
20 | struct gaim_gtk_conversation *gtkconv; |
| 3598 | 21 | struct stat st; |
| 22 | FILE *fd; | |
| 3655 | 23 | char *userdir = g_strdup(gaim_user_dir()); |
| 3598 | 24 | char *logfile = g_strdup_printf("%s.log", normalize(name)); |
| 25 | char *path = g_build_filename(userdir, "logs", logfile, NULL); | |
| 26 | char buf[HISTORY_SIZE+1]; | |
| 27 | char *tmp; | |
| 28 | int size; | |
| 3602 | 29 | GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
30 | |
| 3598 | 31 | if (stat(path, &st) || S_ISDIR(st.st_mode) || st.st_size == 0 || |
| 32 | !(fd = fopen(path, "r"))) { | |
| 33 | g_free(userdir); | |
| 34 | g_free(logfile); | |
| 35 | g_free(path); | |
| 36 | return; | |
| 37 | } | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
38 | |
| 3981 | 39 | fseek(fd, st.st_size > HISTORY_SIZE ? st.st_size - HISTORY_SIZE : 0, SEEK_SET); |
| 3598 | 40 | size = fread(buf, 1, HISTORY_SIZE, fd); |
| 41 | tmp = buf; | |
| 42 | tmp[size] = 0; | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
43 | |
| 3598 | 44 | /* start the history at a newline */ |
| 45 | while (*tmp && *tmp != '\n') | |
| 46 | tmp++; | |
| 47 | ||
| 48 | if (*tmp) tmp++; | |
| 3602 | 49 | |
| 50 | if(*tmp == '<') | |
| 51 | options |= GTK_IMHTML_NO_NEWLINE; | |
| 52 | ||
|
4359
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4235
diff
changeset
|
53 | gtkconv = GAIM_GTK_CONVERSATION(c); |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4235
diff
changeset
|
54 | |
|
cf899ee07d1d
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4235
diff
changeset
|
55 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), tmp, strlen(tmp), options); |
| 3598 | 56 | |
| 57 | g_free(userdir); | |
| 58 | g_free(logfile); | |
| 59 | g_free(path); | |
| 60 | } | |
| 61 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
62 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
63 | plugin_load(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
64 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
65 | gaim_signal_connect(plugin, event_new_conversation, historize, NULL); |
| 3598 | 66 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
67 | return TRUE; |
| 3598 | 68 | } |
| 69 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
70 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
71 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
72 | 2, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
73 | GAIM_PLUGIN_STANDARD, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
74 | GAIM_GTK_PLUGIN_TYPE, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
75 | 0, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
76 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
77 | GAIM_PRIORITY_DEFAULT, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
78 | HISTORY_PLUGIN_ID, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
79 | N_("History"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
80 | VERSION, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
81 | N_("Shows recently logged conversations in new conversations."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
82 | 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
|
83 | "Sean Egan <bj91704@binghamton.edu>", |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
84 | WEBSITE, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
85 | plugin_load, |
|
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 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
88 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
89 | NULL |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
90 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
91 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
92 | static void |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
93 | __init_plugin(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
94 | { |
| 3598 | 95 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
96 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
97 | GAIM_INIT_PLUGIN(history, __init_plugin, info); |