# HG changeset patch # User Eric Warmenhoven # Date 1000160867 0 # Node ID e243bf60f2d6d49ab9ba71da65fe4f07888d308c # Parent aa69e80298bbc9d5a8aa485d5564c20b1600e6d9 [gaim-migrate @ 2271] Stefan Weyergraf and Artem Litvinovich both submitted patches that do similar things. I ended up taking Stefan's patch because it did more things than Artem's did. committer: Tailor Script diff -r aa69e80298bb -r e243bf60f2d6 plugins/PERL-HOWTO --- a/plugins/PERL-HOWTO Mon Sep 10 19:45:19 2001 +0000 +++ b/plugins/PERL-HOWTO Mon Sep 10 22:27:47 2001 +0000 @@ -89,6 +89,13 @@ Since buddy lists are per-connection this goes through the connections until it finds a matching buddy name. +GAIM::write_to_conv(to, wflags, what, who) + This displays a message into a conversation window. is the + message-style and works like that: + wflags==0: display message as if received by + wflags==1: display message as if sent by + wflags==2: display system message + GAIM::print_to_conv(who, what, auto) The question is not what does this do, it's who does this do it as. The answer is "whatever the default is". It uses whichever connection is @@ -101,6 +108,8 @@ This goes through each connection. If it finds a room matching the name, it'll print the message to that room. +GAIM::serv_send_im(who, what, auto) + Same as print_to_conv, but it does not display the message. GAIM::add_event_handler(event, function) This is the most important of them all. This is basically exactly like diff -r aa69e80298bb -r e243bf60f2d6 src/perl.c --- a/src/perl.c Mon Sep 10 19:45:19 2001 +0000 +++ b/src/perl.c Mon Sep 10 22:27:47 2001 +0000 @@ -87,6 +87,7 @@ XS(XS_GAIM_register); /* set up hooks for script */ XS(XS_GAIM_get_info); /* version, last to attempt signon, protocol */ XS(XS_GAIM_print); /* lemme figure this one out... */ +XS(XS_GAIM_write_to_conv); /* write into conversation window */ /* list stuff */ XS(XS_GAIM_buddy_list); /* all buddies */ @@ -97,6 +98,7 @@ XS(XS_GAIM_user_info); /* given name, return struct buddy members */ XS(XS_GAIM_print_to_conv); /* send message to someone */ XS(XS_GAIM_print_to_chat); /* send message to chat room */ +XS(XS_GAIM_serv_send_im); /* send message to someone (but do not display) */ /* handler commands */ XS(XS_GAIM_add_event_handler); /* when servers talk */ @@ -216,6 +218,7 @@ newXS ("GAIM::register", XS_GAIM_register, "GAIM"); newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM"); newXS ("GAIM::print", XS_GAIM_print, "GAIM"); + newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM"); newXS ("GAIM::buddy_list", XS_GAIM_buddy_list, "GAIM"); newXS ("GAIM::online_list", XS_GAIM_online_list, "GAIM"); @@ -224,6 +227,7 @@ newXS ("GAIM::user_info", XS_GAIM_user_info, "GAIM"); newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM"); newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM"); + newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM"); newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM"); newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM"); @@ -502,6 +506,52 @@ XSRETURN(8); } +XS (XS_GAIM_write_to_conv) +{ + char *nick, *who, *what; + struct conversation *c; + int junk; + int send, wflags; + dXSARGS; + items = 0; + + nick = SvPV(ST(0), junk); + send = atoi(SvPV(ST(1), junk)); + what = SvPV(ST(2), junk); + who = SvPV(ST(3), junk); + + if (!*who) who=NULL; + + switch (send) { + case 0: wflags=WFLAG_SEND; break; + case 1: wflags=WFLAG_RECV; break; + case 2: wflags=WFLAG_SYSTEM; break; + default: wflags=WFLAG_RECV; + } + + c = find_conversation(nick); + if (!c) + c = new_conversation(nick); + + write_to_conv(c, what, wflags, who, time((time_t)NULL)); +} + +XS (XS_GAIM_serv_send_im) +{ + char *nick, *what, *isauto; + int junk; + dXSARGS; + items = 0; + + nick = SvPV(ST(0), junk); + what = SvPV(ST(1), junk); + isauto = SvPV(ST(2), junk); + + if (!connections) + return; + serv_send_im(connections->data, nick, what, atoi(isauto)); +} + XS (XS_GAIM_print_to_conv) { char *nick, *what, *isauto;