Mercurial > pidgin.yaz
comparison src/pounce.c @ 6837:f098765ac919
[gaim-migrate @ 7382]
The pounces subsystem now registers signal callbacks for all the pounce
types. The calls to pounce code in server.c, and therefore in all the rest
of gaim, have been removed. The pounce code is now more like its own
separate island.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 14 Sep 2003 21:05:11 +0000 |
parents | 3cc4d5e55a69 |
children | 9220c7490cd1 |
comparison
equal
deleted
inserted
replaced
6836:e2483c5f53bd | 6837:f098765ac919 |
---|---|
1 /** | 1 /** |
2 * @file pounce.c Buddy Pounce API | 2 * @file pounce.c Buddy Pounce API |
3 * @ingroup core | |
3 * | 4 * |
4 * gaim | 5 * gaim |
5 * | 6 * |
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | 7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> |
7 * | 8 * |
8 * This program is free software; you can redistribute it and/or modify | 9 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | 10 * it under the terms of the GNU General Public License as published by |
10 * the Free Software Foundation; either version 2 of the License, or | 11 * the Free Software Foundation; either version 2 of the License, or |
11 * (at your option) any later version. | 12 * (at your option) any later version. |
12 * | 13 * |
16 * GNU General Public License for more details. | 17 * GNU General Public License for more details. |
17 * | 18 * |
18 * You should have received a copy of the GNU General Public License | 19 * You should have received a copy of the GNU General Public License |
19 * along with this program; if not, write to the Free Software | 20 * along with this program; if not, write to the Free Software |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 * | |
22 */ | 22 */ |
23 #include "internal.h" | 23 #include "internal.h" |
24 #include "conversation.h" | |
24 #include "debug.h" | 25 #include "debug.h" |
25 #include "pounce.h" | 26 #include "pounce.h" |
26 | 27 |
27 #include "debug.h" | 28 #include "debug.h" |
28 #include "pounce.h" | 29 #include "pounce.h" |
927 | 928 |
928 g_free(handler->ui); | 929 g_free(handler->ui); |
929 g_free(handler); | 930 g_free(handler); |
930 } | 931 } |
931 | 932 |
933 static void | |
934 buddy_state_cb(GaimBuddy *buddy, GaimPounceEvent event) | |
935 { | |
936 gaim_pounce_execute(buddy->account, buddy->name, event); | |
937 } | |
938 | |
939 static void | |
940 buddy_typing_cb(GaimConversation *conv, void *data) | |
941 { | |
942 GaimAccount *account = gaim_conversation_get_account(conv); | |
943 const char *name = gaim_conversation_get_name(conv); | |
944 | |
945 if (gaim_find_buddy(account, name) != NULL) | |
946 { | |
947 GaimPounceEvent event; | |
948 | |
949 event = (gaim_im_get_typing_state(GAIM_IM(conv)) == GAIM_TYPING | |
950 ? GAIM_POUNCE_TYPING : GAIM_POUNCE_TYPING_STOPPED); | |
951 | |
952 gaim_pounce_execute(account, name, event); | |
953 } | |
954 } | |
955 | |
956 void * | |
957 gaim_pounces_get_handle(void) | |
958 { | |
959 static int pounce_handle; | |
960 | |
961 return &pounce_handle; | |
962 } | |
963 | |
932 void | 964 void |
933 gaim_pounces_init(void) | 965 gaim_pounces_init(void) |
934 { | 966 { |
967 void *blist_handle = gaim_blist_get_handle(); | |
968 void *conv_handle = gaim_conversations_get_handle(); | |
969 void *handle = gaim_pounces_get_handle(); | |
970 | |
935 pounce_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, | 971 pounce_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, |
936 g_free, free_pounce_handler); | 972 g_free, free_pounce_handler); |
937 } | 973 |
974 gaim_signal_connect(blist_handle, "buddy-idle", | |
975 handle, GAIM_CALLBACK(buddy_state_cb), | |
976 GINT_TO_POINTER(GAIM_POUNCE_IDLE)); | |
977 gaim_signal_connect(blist_handle, "buddy-unidle", | |
978 handle, GAIM_CALLBACK(buddy_state_cb), | |
979 GINT_TO_POINTER(GAIM_POUNCE_IDLE)); | |
980 gaim_signal_connect(blist_handle, "buddy-away", | |
981 handle, GAIM_CALLBACK(buddy_state_cb), | |
982 GINT_TO_POINTER(GAIM_POUNCE_AWAY)); | |
983 gaim_signal_connect(blist_handle, "buddy-back", | |
984 handle, GAIM_CALLBACK(buddy_state_cb), | |
985 GINT_TO_POINTER(GAIM_POUNCE_AWAY_RETURN)); | |
986 gaim_signal_connect(blist_handle, "buddy-signed-on", | |
987 handle, GAIM_CALLBACK(buddy_state_cb), | |
988 GINT_TO_POINTER(GAIM_POUNCE_SIGNON)); | |
989 gaim_signal_connect(blist_handle, "buddy-signed-off", | |
990 handle, GAIM_CALLBACK(buddy_state_cb), | |
991 GINT_TO_POINTER(GAIM_POUNCE_SIGNOFF)); | |
992 | |
993 gaim_signal_connect(conv_handle, "buddy-typing", | |
994 handle, GAIM_CALLBACK(buddy_typing_cb), NULL); | |
995 gaim_signal_connect(conv_handle, "buddy-typing-stopped", | |
996 handle, GAIM_CALLBACK(buddy_typing_cb), NULL); | |
997 } | |
998 | |
999 void | |
1000 gaim_pounces_uninit() | |
1001 { | |
1002 gaim_signals_disconnect_by_handle(gaim_pounces_get_handle()); | |
1003 } |