comparison src/perl.c @ 3456:b48065e52337

[gaim-migrate @ 3503] A few patches. Brian--tell me what your last name is, and I'll put it in. ;) committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 28 Aug 2002 02:38:19 +0000
parents 8fa61405af2b
children e23909729192
comparison
equal deleted inserted replaced
3455:8de4f34a1bd7 3456:b48065e52337
104 XS(XS_GAIM_print_to_chat); /* send message to chat room */ 104 XS(XS_GAIM_print_to_chat); /* send message to chat room */
105 XS(XS_GAIM_serv_send_im); /* send message to someone (but do not display) */ 105 XS(XS_GAIM_serv_send_im); /* send message to someone (but do not display) */
106 106
107 /* handler commands */ 107 /* handler commands */
108 XS(XS_GAIM_add_event_handler); /* when servers talk */ 108 XS(XS_GAIM_add_event_handler); /* when servers talk */
109 XS(XS_GAIM_remove_event_handler); /* remove a handler */
109 XS(XS_GAIM_add_timeout_handler); /* figure it out */ 110 XS(XS_GAIM_add_timeout_handler); /* figure it out */
110 111
111 /* play sound */ 112 /* play sound */
112 XS(XS_GAIM_play_sound); /*play a sound*/ 113 XS(XS_GAIM_play_sound); /*play a sound*/
113 114
242 newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM"); 243 newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM");
243 newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM"); 244 newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM");
244 newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM"); 245 newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM");
245 246
246 newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM"); 247 newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM");
248 newXS ("GAIM::remove_event_handler", XS_GAIM_remove_event_handler, "GAIM");
247 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM"); 249 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM");
248 250
249 newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM"); 251 newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM");
250 } 252 }
251 253
812 perl_event_handlers = g_list_append(perl_event_handlers, handler); 814 perl_event_handlers = g_list_append(perl_event_handlers, handler);
813 debug_printf("registered perl event handler for %s\n", handler->event_type); 815 debug_printf("registered perl event handler for %s\n", handler->event_type);
814 XSRETURN_EMPTY; 816 XSRETURN_EMPTY;
815 } 817 }
816 818
819 XS (XS_GAIM_remove_event_handler)
820 {
821 unsigned int junk;
822 struct _perl_event_handlers *ehn;
823 GList *cur = perl_event_handlers;
824 dXSARGS;
825
826 while (cur) {
827 GList *next = cur->next;
828 ehn = cur->data;
829
830 if (!strcmp(ehn->event_type, SvPV(ST(0), junk)) &&
831 !strcmp(ehn->handler_name, SvPV(ST(1), junk)))
832 {
833 perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
834 g_free(ehn->event_type);
835 g_free(ehn->handler_name);
836 g_free(ehn);
837 }
838
839 cur = next;
840 }
841 }
842
817 static int perl_timeout(gpointer data) 843 static int perl_timeout(gpointer data)
818 { 844 {
819 struct _perl_timeout_handlers *handler = data; 845 struct _perl_timeout_handlers *handler = data;
820 execute_perl(handler->handler_name, escape_quotes(handler->handler_args)); 846 execute_perl(handler->handler_name, escape_quotes(handler->handler_args));
821 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler); 847 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler);