Mercurial > pidgin.yaz
diff 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 |
line wrap: on
line diff
--- a/plugins/statenotify.c Sun Aug 17 17:55:46 2003 +0000 +++ b/plugins/statenotify.c Mon Aug 18 01:03:43 2003 +0000 @@ -3,21 +3,21 @@ #include "blist.h" #include "conversation.h" #include "debug.h" +#include "signals.h" static void -write_status(GaimConnection *gc, char *who, const char *message) +write_status(struct buddy *buddy, const char *message) { GaimConversation *conv; - struct buddy *b; + const char *who; char buf[256]; - conv = gaim_find_conversation_with_account(who, gc->account); + conv = gaim_find_conversation_with_account(buddy->name, buddy->account); if (conv == NULL) return; - if ((b = gaim_find_buddy(gc->account, who)) != NULL) - who = gaim_get_buddy_alias(b); + who = gaim_get_buddy_alias(buddy); g_snprintf(buf, sizeof(buf), "%s %s", who, message); @@ -25,36 +25,42 @@ } static void -buddy_away_cb(GaimConnection *gc, char *who, void *data) +buddy_away_cb(struct buddy *buddy, void *data) { - write_status(gc, who, _("has gone away.")); + write_status(buddy, _("has gone away.")); } static void -buddy_unaway_cb(GaimConnection *gc, char *who, void *data) +buddy_unaway_cb(struct buddy *buddy, void *data) { - write_status(gc, who, _("is no longer away.")); + write_status(buddy, _("is no longer away.")); } static void -buddy_idle_cb(GaimConnection *gc, char *who, void *data) +buddy_idle_cb(struct buddy *buddy, void *data) { - write_status(gc, who, _("has become idle.")); + write_status(buddy, _("has become idle.")); } static void -buddy_unidle_cb(GaimConnection *gc, char *who, void *data) +buddy_unidle_cb(struct buddy *buddy, void *data) { - write_status(gc, who, _("is no longer idle.")); + write_status(buddy, _("is no longer idle.")); } static gboolean plugin_load(GaimPlugin *plugin) { - gaim_signal_connect(plugin, event_buddy_away, buddy_away_cb, NULL); - gaim_signal_connect(plugin, event_buddy_back, buddy_unaway_cb, NULL); - gaim_signal_connect(plugin, event_buddy_idle, buddy_idle_cb, NULL); - gaim_signal_connect(plugin, event_buddy_unidle, buddy_unidle_cb, NULL); + void *blist_handle = gaim_blist_get_handle(); + + gaim_signal_connect(blist_handle, "buddy-away", + plugin, GAIM_CALLBACK(buddy_away_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-back", + plugin, GAIM_CALLBACK(buddy_unaway_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-idle", + plugin, GAIM_CALLBACK(buddy_idle_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-unidle", + plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); return TRUE; } @@ -78,7 +84,7 @@ N_("Notifies in a conversation window when a buddy goes or returns from " "away or idle."), "Christian Hammond <chipx86@gnupdate.org>", /**< author */ - GAIM_WEBSITE, /**< homepage */ + GAIM_WEBSITE, /**< homepage */ plugin_load, /**< load */ NULL, /**< unload */