Mercurial > pidgin
annotate plugins/timestamp.c @ 4212:bbd1236e9cc9
[gaim-migrate @ 4449]
Thanks, Brandon Scott.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Mon, 06 Jan 2003 04:33:13 +0000 |
parents | 59751fe608c5 |
children | 0cff8ec38935 |
rev | line source |
---|---|
3598 | 1 /* iChat-like timestamps by Sean Egan. |
2 * <INSERT GPL HERE> */ | |
3 | |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
4 #include "config.h" |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
5 |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
6 #ifndef GAIM_PLUGINS |
3598 | 7 #define GAIM_PLUGINS |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
8 #endif |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
9 |
3598 | 10 #include <time.h> |
11 #include "gaim.h" | |
12 #include "gtkimhtml.h" | |
13 | |
14 #define TIMESTAMP_DELAY (5 * 60 * 1000) | |
15 | |
16 GModule *handle; | |
17 GSList *timestamp_timeouts; | |
18 | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4168
diff
changeset
|
19 gboolean do_timestamp (gpointer data) |
3598 | 20 { |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4168
diff
changeset
|
21 struct conversation *c = data; |
3598 | 22 char *buf; |
23 char mdate[6]; | |
24 time_t tim = time(NULL); | |
25 | |
26 if (!g_list_find(conversations, c)) | |
27 return FALSE; | |
28 | |
29 strftime(mdate, sizeof(mdate), "%H:%M", localtime(&tim)); | |
30 buf = g_strdup_printf(" %s", mdate); | |
31 write_to_conv(c, buf, WFLAG_NOLOG, NULL, tim, -1); | |
32 g_free(buf); | |
33 return TRUE; | |
34 } | |
35 | |
36 void timestamp_new_convo(char *name) | |
37 { | |
38 struct conversation *c = find_conversation(name); | |
39 do_timestamp(c); | |
4168 | 40 |
3727 | 41 timestamp_timeouts = g_slist_append(timestamp_timeouts, |
4168 | 42 GINT_TO_POINTER(g_timeout_add(TIMESTAMP_DELAY, do_timestamp, c))); |
3598 | 43 |
44 } | |
45 char *gaim_plugin_init(GModule *h) { | |
46 GList *cnvs = conversations; | |
47 struct conversation *c; | |
48 handle = h; | |
49 | |
50 while (cnvs) { | |
51 c = cnvs->data; | |
52 timestamp_new_convo(c->name); | |
53 cnvs = cnvs->next; | |
54 } | |
55 gaim_signal_connect(handle, event_new_conversation, timestamp_new_convo, NULL); | |
56 | |
57 return NULL; | |
58 } | |
59 | |
60 void gaim_plugin_remove() { | |
61 GSList *to; | |
62 to = timestamp_timeouts; | |
63 while (to) { | |
4168 | 64 g_source_remove(GPOINTER_TO_INT(to->data)); |
3598 | 65 to = to->next; |
66 } | |
67 g_slist_free(timestamp_timeouts); | |
68 } | |
69 | |
70 struct gaim_plugin_description desc; | |
71 struct gaim_plugin_description *gaim_plugin_desc() { | |
72 desc.api_version = PLUGIN_API_VERSION; | |
4113 | 73 desc.name = g_strdup(_("Timestamp")); |
3598 | 74 desc.version = g_strdup(VERSION); |
4113 | 75 desc.description = g_strdup(_("Adds iChat-style timestamps to conversations every 5 minutes.")); |
3598 | 76 desc.authors = g_strdup("Sean Egan <bj91704@binghamton.edu>"); |
77 desc.url = g_strdup(WEBSITE); | |
78 return &desc; | |
79 } |