From 4afcfb39adcb9c7c7f080ffcf9937b40fbba7163 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Fri, 11 Aug 2017 19:35:26 -0300 Subject: [PATCH] Import Upstream version 0.0.8+cvs20061115 --- Changes | 14 ++ Makefile.PL | 2 +- README | 16 ++- examples/send-url.xml | 6 + examples/sendxmpp-raw-messages | 28 ++++ sendxmpp | 238 ++++++++++++++++++++++----------- 6 files changed, 217 insertions(+), 87 deletions(-) create mode 100644 examples/send-url.xml create mode 100644 examples/sendxmpp-raw-messages diff --git a/Changes b/Changes index bfae7c4..edb8650 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,17 @@ +2006-10-17: + - Added support for raw XML messages. Thanks to David Ammouial + - Documentation enhancement. Thanks to David Ammouial + +2006-10-04: + - Fixed sending of UTF-8 messages: patch from Denis Shaposhnikov [2006-03-31] + - Print error message on connect error. Patch from Jean-Baptiste Quenot [2006-07-17] + - Added multiple recipient patch by Lubomir Host 'rajo' [2006-08-30] + - Fixed bug with -message parameter. Thanks to Thomas Warnick [2005-09-06] + - Homepage URL changed to http://sendxmpp.platon.sk + +2006-09-25: maintainer change + - New maintainer is Lubomir Host 'rajo' , jabber: + 2005-05-07: version 0.0.8 released. - add options to specify non-default ports - updated documentation diff --git a/Makefile.PL b/Makefile.PL index 1cfca54..4b19bc2 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -9,7 +9,7 @@ $ENV{'PREFIX'}='/usr/local/' unless ($ENV{'PREFIX'}); WriteMakefile (NAME => 'sendxmpp', - AUTHOR => 'Dirk-Jan C. Binnema (djcb@djcbsoftware.nl)', + AUTHOR => 'Lubomir Host \'rajo\' ', ABSTRACT => 'Script for sending xmpp messages', PREREQ_PM => {'Getopt::Long'=>2.00, 'Net::XMPP'=>1.0}, diff --git a/README b/README index 357e9d9..e132c82 100644 --- a/README +++ b/README @@ -1,5 +1,3 @@ -Time-stamp: <2004-11-20 22:52:12 (djcb)>; -*-mode:text-*- - README ------ @@ -7,10 +5,11 @@ sendxmpp is a perl-script to send XMPP (jabber) messages, similar to what mail(1) does for mail. XMPP is an open, non-proprietary protocol for instant messaging. See www.jabber.org for more information. -sendxmpp was written by me, Dirk-Jan C. Binnema, and is available -under the term of the GNU General Public License v2. The hard work is -done by Ryan Eatmon's Net::XMPP-modules, and you need have them -installed for sendxmpp to work. +sendxmpp was written by me, Dirk-Jan C. Binnema, and is available under +the term of the GNU General Public License v2. The hard work is done by +Ryan Eatmon's Net::XMPP-modules, and you need have them installed for +sendxmpp to work. Current maintainer is Lubomir Host 'rajo' Obviously, you also need a jabber account; they are freely available at jabber.org, but you can also install your own servers. @@ -22,5 +21,8 @@ sent. I am interested in hearing about other uses. -Dirk-Jan Binnema , or djcb@jabber.org (IM). +Homepage: http://sendxmpp.platon.sk + +Lubomir Host 'rajo' +Jabber: (IM) diff --git a/examples/send-url.xml b/examples/send-url.xml new file mode 100644 index 0000000..ac20bde --- /dev/null +++ b/examples/send-url.xml @@ -0,0 +1,6 @@ + + Check out the new sendxmpp website! + + http://sendxmpp.platon.sk/ + + diff --git a/examples/sendxmpp-raw-messages b/examples/sendxmpp-raw-messages new file mode 100644 index 0000000..dde029e --- /dev/null +++ b/examples/sendxmpp-raw-messages @@ -0,0 +1,28 @@ +# +# RAW XMPP messages, which can be used with sendxmpp +# +# Thanks to David Ammouial +# +# cat examples/send-url.xml | sendxmpp --raw +# + +# Sending an URL along with a message: + + Check out the new sendxmpp website! + + http://sendxmpp.platon.sk/ + + + +# Adding an item to the roster + + + + + + +# Sending a presence subscription request + + Please authorize me :) + + diff --git a/sendxmpp b/sendxmpp index fd6523e..4954cec 100755 --- a/sendxmpp +++ b/sendxmpp @@ -1,25 +1,32 @@ #!/usr/bin/perl -w eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}' - if 0; # not running under some shell -#-*-mode:perl-*- -#Time-stamp: <2005-05-07 19:24:09 (djcb)> +if 0; # not running under some shell +# # script to send message using xmpp (aka jabber), -# somewhat resembling mail(1) - +# somewhat resembling mail(1) +# # Author: Dirk-Jan C. Binnema -# Copyright (c) 2004,2005 Dirk-Jan C. Binnema - +# Copyright (c) 2004, 2005 Dirk-Jan C. Binnema +# +# Maintainer: Lubomir Host 'rajo' +# Homepage: http://sendxmpp.platon.sk +# # Released under the terms of the GNU General Public License v2 +# use Net::XMPP; use Getopt::Long; use strict; +use open ':utf8'; +use open ':std'; + # subroutines decls sub xmpp_login($$$$$$$); sub xmpp_send ($$$); +sub xmpp_send_raw_xml($$); sub xmpp_send_message($$$$); sub xmpp_send_chatroom_message($$$$$); sub xmpp_logout($); @@ -177,7 +184,7 @@ sub parse_cmdline () { usage() unless (scalar(@ARGV)); my ($subject,$file,$resource,$jserver,$port,$username,$password, - $message,$chatroom,$debug,$tls,$interactive,$help,$verbose); + $message, $chatroom, $debug, $tls, $interactive, $help, $raw, $verbose); my $res = GetOptions ('subject|s=s' => \$subject, 'file|f=s' => \$file, 'resource|r=s' => \$resource, @@ -190,23 +197,33 @@ sub parse_cmdline () { 'interactive|i' => \$interactive, 'help|usage|h' => \$help, 'debug|d' => \$debug, + 'raw|w' => \$raw, 'verbose|v' => \$verbose); - usage () - if ($help); + usage () if ($help); - my $rcpt = $ARGV[0] - or error_exit "no recipient specified"; - - if ($message && $interactive) { - error_exit "cannot have both -m (--message) and -i (--interactive)\n"; - } - - if ($jserver && $jserver =~ /(.*):(\d+)/) { - $jserver = $1; - $port = $2; - } - + my @rcpt = @ARGV; + + if (defined($raw) && scalar(@rcpt) > 0) { + error_exit "You must give a recipient or --raw (but not both)"; + } + if ($raw && $subject) { + error_exit("You cannot specify a subject in raw XML mode"); + } + if ($raw && $chatroom) { + error_exit("The chatroom option is pointless in raw XML mode"); + } + + if ($message && $interactive) { + error_exit "Cannot have both -m (--message) and -i (--interactive)"; + } + + if ($jserver && $jserver =~ /(.*):(\d+)/) { + $jserver = $1; + $port = $2; + } + my %dict = ('subject' => ($subject or ''), + 'message' => ($message or ''), 'resource' => ($resource or $RESOURCE), 'jserver' => ($jserver or ''), 'port' => ($port or 0), @@ -217,8 +234,9 @@ sub parse_cmdline () { 'tls' => ($tls or 0), 'debug' => ($debug or 0), 'verbose' => ($verbose or 0), + 'raw' => ($raw or 0), 'file' => ($file or ($ENV{'HOME'}.'/.sendxmpprc')), - 'recipient' => $rcpt); + 'recipient' => \@rcpt); if ($DEBUG || $VERBOSE) { while (my ($key,$val) = each %dict) { @@ -243,11 +261,13 @@ sub xmpp_login ($$$$$$$) { unless ($cnx); my @res; - if (!$port) { - @res = $cnx->Connect(hostname=>$host,tls=>$tls); - } else { - @res = $cnx->Connect(hostname=>$host,port=>$port,tls=>$tls); - } + if (!$port) { + @res = $cnx->Connect(hostname => $host, tls => $tls); + error_exit ("Could not connect to server '$host': $@") unless @res; + } else { + @res = $cnx->Connect(hostname => $host, port => $port, tls => $tls); + error_exit ("Could not connect to '$host' on port $port: $@") unless @res; + } xmpp_check_result("Connect",\@res,$cnx); @@ -271,22 +291,46 @@ sub xmpp_send ($$$) { my ($cnx, $cmdline, $txt) = @_; - unless ($$cmdline{'chatroom'}) { - xmpp_send_message ($cnx, - $$cmdline{'recipient'}, - $$cmdline{'subject'}, - $txt); - } else { - xmpp_send_chatroom_message ($cnx, - $$cmdline{'resource'}, - $$cmdline{'subject'}, - $$cmdline{'recipient'}, - $txt); - } + unless ($$cmdline{'chatroom'}) { + unless ($$cmdline{'raw'}) { + map { + xmpp_send_message ($cnx, + $_, #$$cmdline{'recipient'}, + $$cmdline{'subject'}, + $txt) + } @{$$cmdline{'recipient'}}; + } + else { + xmpp_send_raw_xml ($cnx, $txt); + } + } + else { + map { + xmpp_send_chatroom_message ($cnx, + $$cmdline{'resource'}, + $$cmdline{'subject'}, + $_, # $$cmdline{'recipient'}, + $txt) + } @{$$cmdline{'recipient'}}; + } } +# +# xmpp_send_raw_xml: send a raw XML packet +# input: connection,packet +# +sub xmpp_send_raw_xml ($$) { + + my ($cnx,$packet) = @_; + + # for some reason, Send does not return anything + $cnx->Send($packet); + xmpp_check_result('Send',0,$cnx); +} + + # # xmpp_send_message: send a message to some xmpp user # input: connection,recipient,subject,msg @@ -417,8 +461,8 @@ sub error_exit { sub usage () { print STDERR - "sendxmpp version $VERSION, Copyright (c) 2004,2005 Dirk-Jan C. Binnema\n" . - "usage: sendxmpp [options] \n" . + "sendxmpp version $VERSION, Copyright (c) 2004, 2005 Dirk-Jan C. Binnema\n" . + "usage: sendxmpp [options] [ ...]\n" . "or refer to the the sendxmpp manpage\n"; exit 0; @@ -435,7 +479,9 @@ sendxmpp - send xmpp messages from the commandline. =head1 SYNOPSIS -sendxmpp [options] +sendxmpp [options] [ ...] + +sendxmpp --raw [options] =head1 DESCRIPTION @@ -444,64 +490,97 @@ unlike L. Messages can be sent both to individual recipients and chatro =head1 OPTIONS -B<-f>,B<--file> -use configuration file instead of ~/.sendxmpprc +=over + +=item B<-f>,B<--file> I + +Use I configuration file instead of F<~/.sendxmpprc> + +=item B<-u>,B<--username> I + +Use I instead of the one in the configuration file + +=item B<-p>,B<--password> I + +Use I instead of the one in the configuration file + +=item B<-j>,B<--jserver> I + +Use jabber I instead of the one in the configuration file. + +=item B<-r>,B<--resource> I + +Use resource I for the sender [default: 'sendxmpp']; when sending to a chatroom, this determines the 'alias' -B<-u>,B<--username> -use instead of the one in the configuration file +=item B<-t>,B<--tls> -B<-p>,B<--password> -use instead of the one in the configuration file +Connect securely, using TLS -B<-j>,B<--jserver> -use jabber server instead of the one in the configuration file. Note that you can add : to use a non-default port, ie. B<-j myjabber.org:1234> +=item B<-c>,B<--chatroom> -B<-r>,B<--resource> -use resource for the sender [default: 'sendxmpp']; when sending to a chatroom, this determines the 'alias' +Send the message to a chatroom -B<-t>,B<--tls> -connect securely, using TLS +=item B<-s>,B<--subject> I -B<-c>,B<--chatroom> -send the message to a chatroom +Set the subject for the message to I [default: '']; when sending to a chatroom, this will set the subject for the chatroom -B<-s>,B<--subject> -set the subject for the message to [default: '']; when sending to a chatroom, -this will set the subject for the chatroom +=item B<-m>,B<--message> I -B<-m>,B<--message> -read the message from (a file) instead of stdin +Read the message from I (a file) instead of stdin -B<-i>,B<--interactive> -work in interactive mode, reading lines from stdin and sending the one-at-time +=item B<-i>,B<--interactive> -B<-v>,B<--verbose> -give verbose output about what is happening +Work in interactive mode, reading lines from stdin and sending the one-at-time -B<-h>,B<--help>,B<--usage> -show a 'Usage' message +=item B<-w>,B<--raw> -B<-d>,B<--debug> -show debugging info while running. B: This will include passwords etc. so be careful with the output! +Send raw XML message to jabber server + +=item B<-v>,B<--verbose> + +Give verbose output about what is happening + +=item B<-h>,B<--help>,B<--usage> + +Show a 'Usage' message + +=item B<-d>,B<--debug> + +Show debugging info while running. B: This will include passwords etc. so be careful with the output! + +=back =head1 CONFIGURATION FILE -You may define a '~/.sendxmpprc' file with the necessary data for your +You may define a 'F<~/.sendxmpprc>' file with the necessary data for your xmpp-account, with a line of the format: - @ +=over + +I@I I + +=back e.g.: # my account alice@jabber.org secret -('#' and newlines are allowed like in shellscripts). You can add : to -the if you need an alternative port, ie. +('#' and newlines are allowed like in shellscripts). You can add a I (or IP address) if it is different from the I part of your JID: + + # account with specific connection host + alice@myjabberserver.com;foo.com secret + +You can also add a I if it is not the standard XMPP port: # account with weird port number - alice@myjabberhost.com:1234 secret - + alice@myjabberserver.com:1234 secret + +Of course, you may also mix the two: + + # account with a specific host and port + alice@myjabberserver.com;foo.com:1234 secret + B: for your security, sendxmpp demands that the configuration file is owned by you and has file permissions 600. @@ -523,13 +602,14 @@ file is owned by you and has file permissions 600. Documentation for the L module -The jabber homepage: http://www.jabber.org/ +The jabber homepage: L -The sendxmpp homepage: http://www.djcbsoftware.nl/code/sendxmpp +The sendxmpp homepage: L =head1 AUTHOR sendxmpp has been written by Dirk-Jan C. Binnema , and uses -the L modules written by Ryan Eatmon. +the L modules written by Ryan Eatmon. Current maintainer is +Lubomir Host 'rajo' , L =cut -- 2.20.1