changeset 2261:e243bf60f2d6

[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 <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 10 Sep 2001 22:27:47 +0000
parents aa69e80298bb
children 9c8f353331e7
files plugins/PERL-HOWTO src/perl.c
diffstat 2 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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. <wflags> is the
+	message-style and works like that:
+		wflags==0: display message as if received by <who>
+		wflags==1: display message as if sent by <who>
+		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
--- 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;