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