comparison plugins/statenotify.c @ 5267:3cd24f012091

[gaim-migrate @ 5639] This neat little plugin, which may not have the best name, I dunno, what do you think? I just picked it. Anyhow, it will notify you in a conversation window when the buddy you're talking to has become away, returned from away, gone idle, or returned from idle. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 01 May 2003 07:46:09 +0000
parents
children 1c55b1540e18
comparison
equal deleted inserted replaced
5266:b3a03b86b09b 5267:3cd24f012091
1 #include "gaim.h"
2
3 static void
4 write_status(struct gaim_connection *gc, char *who, const char *message)
5 {
6 struct gaim_conversation *conv;
7 struct buddy *b;
8 char buf[256];
9
10 conv = gaim_find_conversation_with_account(who, gc->account);
11
12 if (conv == NULL)
13 return;
14
15 if ((b = gaim_find_buddy(gc->account, who)) != NULL)
16 who = gaim_get_buddy_alias(b);
17
18 g_snprintf(buf, sizeof(buf), "%s %s", who, message);
19
20 gaim_conversation_write(conv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
21 }
22
23 static void
24 buddy_away_cb(struct gaim_connection *gc, char *who, void *data)
25 {
26 write_status(gc, who, "has gone away.");
27 }
28
29 static void
30 buddy_unaway_cb(struct gaim_connection *gc, char *who, void *data)
31 {
32 write_status(gc, who, "is no longer away.");
33 }
34
35 static void
36 buddy_idle_cb(struct gaim_connection *gc, char *who, void *data)
37 {
38 write_status(gc, who, "has become idle.");
39 }
40
41 static void
42 buddy_unidle_cb(struct gaim_connection *gc, char *who, void *data)
43 {
44 write_status(gc, who, "is no longer idle.");
45 }
46
47 static gboolean
48 plugin_load(GaimPlugin *plugin)
49 {
50 gaim_signal_connect(plugin, event_buddy_away, buddy_away_cb, NULL);
51 gaim_signal_connect(plugin, event_buddy_back, buddy_unaway_cb, NULL);
52 gaim_signal_connect(plugin, event_buddy_idle, buddy_idle_cb, NULL);
53 gaim_signal_connect(plugin, event_buddy_unidle, buddy_unidle_cb, NULL);
54
55 return TRUE;
56 }
57
58 static GaimPluginInfo info =
59 {
60 2, /**< api_version */
61 GAIM_PLUGIN_STANDARD, /**< type */
62 NULL, /**< ui_requirement */
63 0, /**< flags */
64 NULL, /**< dependencies */
65 GAIM_PRIORITY_DEFAULT, /**< priority */
66
67 NULL, /**< id */
68 N_("Buddy State Notification"), /**< name */
69 VERSION, /**< version */
70 /** summary */
71 N_("Notifies in a conversation window when a buddy goes or returns from "
72 "away or idle."),
73 /** description */
74 N_("Notifies in a conversation window when a buddy goes or returns from "
75 "away or idle."),
76 "Christian Hammond <chipx86@gnupdate.org>", /**< author */
77 WEBSITE, /**< homepage */
78
79 plugin_load, /**< load */
80 NULL, /**< unload */
81 NULL, /**< destroy */
82
83 NULL, /**< ui_info */
84 NULL /**< extra_info */
85 };
86
87 static void
88 __init_plugin(GaimPlugin *plugin)
89 {
90 }
91
92 GAIM_INIT_PLUGIN(statenotify, __init_plugin, info);