15 | 15 |
#
|
16 | 16 |
# Released under the terms of the GNU General Public License v2
|
17 | 17 |
#
|
18 | |
# $Platon: sendxmpp/sendxmpp,v 1.18 2009-01-10 11:40:14 rajo Exp $
|
|
18 |
# $Platon: sendxmpp/sendxmpp,v 1.20 2010-01-18 00:54:16 rajo Exp $
|
19 | 19 |
# $Id: $
|
20 | 20 |
|
21 | 21 |
use Authen::SASL qw(Perl); # authentication broken if Authen::SASL::Cyrus module installed
|
|
27 | 27 |
use open ':std';
|
28 | 28 |
|
29 | 29 |
# subroutines decls
|
30 | |
sub xmpp_login($$$$$$$$);
|
|
30 |
sub xmpp_login($$$$$$$$$);
|
31 | 31 |
sub xmpp_send ($$$$);
|
32 | 32 |
sub xmpp_send_raw_xml($$);
|
33 | 33 |
sub xmpp_send_message($$$$$$);
|
|
43 | 43 |
sub main();
|
44 | 44 |
|
45 | 45 |
my # MakeMaker
|
46 | |
$VERSION = [ q$Revision: 1.18 $ =~ m/(\S+)\s*$/g ]->[0];
|
|
46 |
$VERSION = [ q$Revision: 1.20 $ =~ m/(\S+)\s*$/g ]->[0];
|
47 | 47 |
my $RESOURCE = 'sendxmpp';
|
48 | 48 |
my $VERBOSE = 0;
|
49 | 49 |
my $DEBUG = 0;
|
|
71 | 71 |
|
72 | 72 |
# login to xmpp
|
73 | 73 |
my $cnx = xmpp_login ($$cmdline{'jserver'} || $$config{'jserver'},
|
74 | |
$$cmdline{'port'} || $$config{'port'},
|
|
74 |
$$cmdline{'port'} || $$config{'port'} || ($$cmdline{'ssl'} ? 5223 : 5222),
|
75 | 75 |
$$cmdline{'username'} || $$config{'username'},
|
76 | 76 |
$$cmdline{'password'} || $$config{'password'},
|
77 | 77 |
$$cmdline{'component'}|| $$config{'component'},
|
78 | 78 |
$$cmdline{'resource'},
|
79 | 79 |
$$cmdline{'tls'},
|
|
80 |
$$cmdline{'ssl'},
|
80 | 81 |
$$cmdline{'debug'})
|
81 | 82 |
or error_exit("cannot login: $!");
|
82 | 83 |
|
|
205 | 206 |
usage() unless (scalar(@ARGV));
|
206 | 207 |
|
207 | 208 |
my ($subject,$file,$resource,$jserver,$port,$username,$password,$component,
|
208 | |
$message, $chatroom, $headline, $debug, $tls, $interactive, $help, $raw, $verbose);
|
|
209 |
$message, $chatroom, $headline, $debug, $tls, $ssl, $interactive, $help, $raw, $verbose);
|
209 | 210 |
my $res = GetOptions ('subject|s=s' => \$subject,
|
210 | 211 |
'file|f=s' => \$file,
|
211 | 212 |
'resource|r=s' => \$resource,
|
|
218 | 219 |
'message-type=s' => \$message_type,
|
219 | 220 |
'chatroom|c' => \$chatroom,
|
220 | 221 |
'tls|t' => \$tls,
|
|
222 |
'ssl|e' => \$ssl,
|
221 | 223 |
'interactive|i' => \$interactive,
|
222 | 224 |
'help|usage|h' => \$help,
|
223 | 225 |
'debug|d' => \$debug,
|
|
243 | 245 |
|
244 | 246 |
if (scalar(grep { $message_type eq $_ } @suppported_message_types) == 0) {
|
245 | 247 |
error_exit("Unsupported message type '$message_type'");
|
|
248 |
}
|
|
249 |
|
|
250 |
if ($ssl && $tls) {
|
|
251 |
error_exit("Connect securely wether using -e (--ssl) or -t (--tls)");
|
246 | 252 |
}
|
247 | 253 |
|
248 | 254 |
if ($headline) {
|
|
272 | 278 |
'message-type' => $message_type,
|
273 | 279 |
'interactive' => ($interactive or 0),
|
274 | 280 |
'tls' => ($tls or 0),
|
|
281 |
'ssl' => ($ssl or 0),
|
275 | 282 |
'debug' => ($debug or 0),
|
276 | 283 |
'verbose' => ($verbose or 0),
|
277 | 284 |
'raw' => ($raw or 0),
|
|
290 | 297 |
|
291 | 298 |
#
|
292 | 299 |
# xmpp_login: login to the xmpp (jabber) server
|
293 | |
# input: hostname,port,username,password,resource,tls,debug
|
|
300 |
# input: hostname,port,username,password,resource,tls,ssl,debug
|
294 | 301 |
# output: an XMPP connection object
|
295 | 302 |
#
|
296 | |
sub xmpp_login ($$$$$$$$) {
|
297 | |
|
298 | |
my ($host, $port, $user, $pw, $comp, $res, $tls, $debug) = @_;
|
|
303 |
sub xmpp_login ($$$$$$$$$) {
|
|
304 |
|
|
305 |
my ($host, $port, $user, $pw, $comp, $res, $tls, $ssl, $debug) = @_;
|
299 | 306 |
my $cnx = new Net::XMPP::Client(debuglevel=>($debug?2:0));
|
300 | 307 |
error_exit "could not create XMPP client object: $!"
|
301 | 308 |
unless ($cnx);
|
|
303 | 310 |
my @res;
|
304 | 311 |
my $arghash = {
|
305 | 312 |
hostname => $host,
|
|
313 |
port => $port,
|
306 | 314 |
tls => $tls,
|
|
315 |
ssl => $ssl,
|
307 | 316 |
connectiontype => 'tcpip',
|
308 | 317 |
componentname => $comp
|
309 | 318 |
};
|
|
580 | 589 |
|
581 | 590 |
Connect securely, using TLS
|
582 | 591 |
|
|
592 |
=item B<-e>,B<--ssl>
|
|
593 |
|
|
594 |
Connect securely, using SSL
|
|
595 |
|
583 | 596 |
=item B<-l>,B<--headline>
|
584 | 597 |
|
585 | 598 |
Backward compatibility option. You should use B<--message-type=headline> instead. Send a headline type message (not stored in offline messages)
|