annotate plugins/statenotify.c @ 5788:8c237274189f

[gaim-migrate @ 6213] Forgot to add this function. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 07 Jun 2003 04:25:34 +0000
parents dae79aefac8d
children 059d95c67cda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5267
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 #include "gaim.h"
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 static void
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5267
diff changeset
4 write_status(GaimConnection *gc, char *who, const char *message)
5267
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 {
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5587
diff changeset
6 GaimConversation *conv;
5267
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 struct buddy *b;
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 char buf[256];
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 conv = gaim_find_conversation_with_account(who, gc->account);
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 if (conv == NULL)
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 return;
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 if ((b = gaim_find_buddy(gc->account, who)) != NULL)
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 who = gaim_get_buddy_alias(b);
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 g_snprintf(buf, sizeof(buf), "%s %s", who, message);
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 gaim_conversation_write(conv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL));
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 }
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 static void
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5267
diff changeset
24 buddy_away_cb(GaimConnection *gc, char *who, void *data)
5267
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 {
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 write_status(gc, who, "has gone away.");
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 }
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 static void
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5267
diff changeset
30 buddy_unaway_cb(GaimConnection *gc, char *who, void *data)
5267
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 {
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 write_status(gc, who, "is no longer away.");
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 }
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 static void
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5267
diff changeset
36 buddy_idle_cb(GaimConnection *gc, char *who, void *data)
5267
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 {
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 write_status(gc, who, "has become idle.");
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 }
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 static void
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5267
diff changeset
42 buddy_unidle_cb(GaimConnection *gc, char *who, void *data)
5267
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 {
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 write_status(gc, who, "is no longer idle.");
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 }
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 static gboolean
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 plugin_load(GaimPlugin *plugin)
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 {
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 gaim_signal_connect(plugin, event_buddy_away, buddy_away_cb, NULL);
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 gaim_signal_connect(plugin, event_buddy_back, buddy_unaway_cb, NULL);
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 gaim_signal_connect(plugin, event_buddy_idle, buddy_idle_cb, NULL);
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 gaim_signal_connect(plugin, event_buddy_unidle, buddy_unidle_cb, NULL);
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 return TRUE;
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 }
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 static GaimPluginInfo info =
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 {
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 2, /**< api_version */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 GAIM_PLUGIN_STANDARD, /**< type */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 NULL, /**< ui_requirement */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 0, /**< flags */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 NULL, /**< dependencies */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 GAIM_PRIORITY_DEFAULT, /**< priority */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 NULL, /**< id */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 N_("Buddy State Notification"), /**< name */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 VERSION, /**< version */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 /** summary */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 N_("Notifies in a conversation window when a buddy goes or returns from "
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 "away or idle."),
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 /** description */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 N_("Notifies in a conversation window when a buddy goes or returns from "
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 "away or idle."),
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 "Christian Hammond <chipx86@gnupdate.org>", /**< author */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 WEBSITE, /**< homepage */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 plugin_load, /**< load */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 NULL, /**< unload */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 NULL, /**< destroy */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 NULL, /**< ui_info */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 NULL /**< extra_info */
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 };
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 static void
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 __init_plugin(GaimPlugin *plugin)
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 {
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 }
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91
3cd24f012091 [gaim-migrate @ 5639]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 GAIM_INIT_PLUGIN(statenotify, __init_plugin, info);