Mercurial > pidgin
comparison plugins/history.c @ 6485:70d5122bc3ff
[gaim-migrate @ 6999]
Removed the old event system and replaced it with a much better signal
system. There will most likely be some bugs in this, but it seems to be
working for now. Plugins can now generate their own signals, and other
plugins can find those plugins and connect to them. This could give
plugins a form of IPC. It's also useful for other things. It's rather
flexible, except for the damn marshalling, but there's no way around that
that I or the glib people can see.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 18 Aug 2003 01:03:43 +0000 |
parents | 8f94cce8faa5 |
children | 9ae5ce753d63 |
comparison
equal
deleted
inserted
replaced
6484:5ced8e111473 | 6485:70d5122bc3ff |
---|---|
4 #include "gtkinternal.h" | 4 #include "gtkinternal.h" |
5 | 5 |
6 #include "conversation.h" | 6 #include "conversation.h" |
7 #include "debug.h" | 7 #include "debug.h" |
8 #include "prefs.h" | 8 #include "prefs.h" |
9 #include "signals.h" | |
9 #include "util.h" | 10 #include "util.h" |
10 | 11 |
11 #include "gtkconv.h" | 12 #include "gtkconv.h" |
12 #include "gtkimhtml.h" | 13 #include "gtkimhtml.h" |
13 #include "gtkplugin.h" | 14 #include "gtkplugin.h" |
14 | 15 |
15 #define HISTORY_PLUGIN_ID "gtk-history" | 16 #define HISTORY_PLUGIN_ID "gtk-history" |
16 | 17 |
17 #define HISTORY_SIZE (4 * 1024) | 18 #define HISTORY_SIZE (4 * 1024) |
18 | 19 |
19 void historize (char *name, void *data) | 20 static void historize(GaimConversation *c) |
20 { | 21 { |
21 GaimConversation *c = gaim_find_conversation(name); | |
22 GaimGtkConversation *gtkconv; | 22 GaimGtkConversation *gtkconv; |
23 const char *name = gaim_conversation_get_name(c); | |
23 struct stat st; | 24 struct stat st; |
24 FILE *fd; | 25 FILE *fd; |
25 char *userdir = g_strdup(gaim_user_dir()); | 26 char *userdir = g_strdup(gaim_user_dir()); |
26 char *logfile = g_strdup_printf("%s.log", normalize(name)); | 27 char *logfile = g_strdup_printf("%s.log", normalize(name)); |
27 char *path = g_build_filename(userdir, "logs", logfile, NULL); | 28 char *path = g_build_filename(userdir, "logs", logfile, NULL); |
28 char buf[HISTORY_SIZE+1]; | 29 char buf[HISTORY_SIZE+1]; |
29 char *tmp, *tmp2; | 30 char *tmp, *tmp2; |
30 int size; | 31 int size; |
31 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; | 32 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; |
32 | 33 |
33 if (stat(path, &st) || S_ISDIR(st.st_mode) || st.st_size == 0 || | 34 if (stat(path, &st) || S_ISDIR(st.st_mode) || st.st_size == 0 || |
34 !(fd = fopen(path, "r"))) { | 35 !(fd = fopen(path, "r"))) { |
35 g_free(userdir); | 36 g_free(userdir); |
36 g_free(logfile); | 37 g_free(logfile); |
37 g_free(path); | 38 g_free(path); |
38 return; | 39 return; |
68 } | 69 } |
69 | 70 |
70 static gboolean | 71 static gboolean |
71 plugin_load(GaimPlugin *plugin) | 72 plugin_load(GaimPlugin *plugin) |
72 { | 73 { |
73 gaim_signal_connect(plugin, event_new_conversation, historize, NULL); | 74 gaim_signal_connect(gaim_conversations_get_handle(), |
75 "conversation-created", | |
76 plugin, GAIM_CALLBACK(historize), NULL); | |
74 | 77 |
75 return TRUE; | 78 return TRUE; |
76 } | 79 } |
77 | 80 |
78 static GaimPluginInfo info = | 81 static GaimPluginInfo info = |