Mercurial > pidgin.yaz
comparison plugins/statenotify.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 | 3683471e1417 |
children | aefe4067d3a3 |
comparison
equal
deleted
inserted
replaced
6484:5ced8e111473 | 6485:70d5122bc3ff |
---|---|
1 #include "internal.h" | 1 #include "internal.h" |
2 | 2 |
3 #include "blist.h" | 3 #include "blist.h" |
4 #include "conversation.h" | 4 #include "conversation.h" |
5 #include "debug.h" | 5 #include "debug.h" |
6 #include "signals.h" | |
6 | 7 |
7 static void | 8 static void |
8 write_status(GaimConnection *gc, char *who, const char *message) | 9 write_status(struct buddy *buddy, const char *message) |
9 { | 10 { |
10 GaimConversation *conv; | 11 GaimConversation *conv; |
11 struct buddy *b; | 12 const char *who; |
12 char buf[256]; | 13 char buf[256]; |
13 | 14 |
14 conv = gaim_find_conversation_with_account(who, gc->account); | 15 conv = gaim_find_conversation_with_account(buddy->name, buddy->account); |
15 | 16 |
16 if (conv == NULL) | 17 if (conv == NULL) |
17 return; | 18 return; |
18 | 19 |
19 if ((b = gaim_find_buddy(gc->account, who)) != NULL) | 20 who = gaim_get_buddy_alias(buddy); |
20 who = gaim_get_buddy_alias(b); | |
21 | 21 |
22 g_snprintf(buf, sizeof(buf), "%s %s", who, message); | 22 g_snprintf(buf, sizeof(buf), "%s %s", who, message); |
23 | 23 |
24 gaim_conversation_write(conv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); | 24 gaim_conversation_write(conv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
25 } | 25 } |
26 | 26 |
27 static void | 27 static void |
28 buddy_away_cb(GaimConnection *gc, char *who, void *data) | 28 buddy_away_cb(struct buddy *buddy, void *data) |
29 { | 29 { |
30 write_status(gc, who, _("has gone away.")); | 30 write_status(buddy, _("has gone away.")); |
31 } | 31 } |
32 | 32 |
33 static void | 33 static void |
34 buddy_unaway_cb(GaimConnection *gc, char *who, void *data) | 34 buddy_unaway_cb(struct buddy *buddy, void *data) |
35 { | 35 { |
36 write_status(gc, who, _("is no longer away.")); | 36 write_status(buddy, _("is no longer away.")); |
37 } | 37 } |
38 | 38 |
39 static void | 39 static void |
40 buddy_idle_cb(GaimConnection *gc, char *who, void *data) | 40 buddy_idle_cb(struct buddy *buddy, void *data) |
41 { | 41 { |
42 write_status(gc, who, _("has become idle.")); | 42 write_status(buddy, _("has become idle.")); |
43 } | 43 } |
44 | 44 |
45 static void | 45 static void |
46 buddy_unidle_cb(GaimConnection *gc, char *who, void *data) | 46 buddy_unidle_cb(struct buddy *buddy, void *data) |
47 { | 47 { |
48 write_status(gc, who, _("is no longer idle.")); | 48 write_status(buddy, _("is no longer idle.")); |
49 } | 49 } |
50 | 50 |
51 static gboolean | 51 static gboolean |
52 plugin_load(GaimPlugin *plugin) | 52 plugin_load(GaimPlugin *plugin) |
53 { | 53 { |
54 gaim_signal_connect(plugin, event_buddy_away, buddy_away_cb, NULL); | 54 void *blist_handle = gaim_blist_get_handle(); |
55 gaim_signal_connect(plugin, event_buddy_back, buddy_unaway_cb, NULL); | 55 |
56 gaim_signal_connect(plugin, event_buddy_idle, buddy_idle_cb, NULL); | 56 gaim_signal_connect(blist_handle, "buddy-away", |
57 gaim_signal_connect(plugin, event_buddy_unidle, buddy_unidle_cb, NULL); | 57 plugin, GAIM_CALLBACK(buddy_away_cb), NULL); |
58 gaim_signal_connect(blist_handle, "buddy-back", | |
59 plugin, GAIM_CALLBACK(buddy_unaway_cb), NULL); | |
60 gaim_signal_connect(blist_handle, "buddy-idle", | |
61 plugin, GAIM_CALLBACK(buddy_idle_cb), NULL); | |
62 gaim_signal_connect(blist_handle, "buddy-unidle", | |
63 plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); | |
58 | 64 |
59 return TRUE; | 65 return TRUE; |
60 } | 66 } |
61 | 67 |
62 static GaimPluginInfo info = | 68 static GaimPluginInfo info = |
76 "away or idle."), | 82 "away or idle."), |
77 /** description */ | 83 /** description */ |
78 N_("Notifies in a conversation window when a buddy goes or returns from " | 84 N_("Notifies in a conversation window when a buddy goes or returns from " |
79 "away or idle."), | 85 "away or idle."), |
80 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | 86 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ |
81 GAIM_WEBSITE, /**< homepage */ | 87 GAIM_WEBSITE, /**< homepage */ |
82 | 88 |
83 plugin_load, /**< load */ | 89 plugin_load, /**< load */ |
84 NULL, /**< unload */ | 90 NULL, /**< unload */ |
85 NULL, /**< destroy */ | 91 NULL, /**< destroy */ |
86 | 92 |