]> mj.ucw.cz Git - pciids.git/blob - PciIds/Xmpp.pm
Integrate account help into menu
[pciids.git] / PciIds / Xmpp.pm
1 package PciIds::Xmpp;
2 use strict;
3 use warnings;
4 use PciIds::Config;
5 use base 'Exporter';
6
7 our @EXPORT = qw(&sendXmpp &flushXmpp);
8
9 my @pending;
10
11 sub sendXmpp( $$$ ) {
12         my( $to, $subject, $body ) = @_;
13         push @pending, [ $to, $subject, $body ];
14 }
15
16 sub flushXmpp() {
17         return unless @pending;
18         open JELNET, "|$config{jelnet} --silent-passwd \"$config{xmpp_name}\" > /dev/null" or die "Could not start XMPP sender\n";
19         print JELNET $config{"xmpp_passwd"}."\n";
20         foreach( @pending ) {
21                 my( $to, $subject, $body ) = @{$_};
22                 $subject =~ s/&/&/g;
23                 $subject =~ s/'/'/g;
24                 $subject =~ s/"/"/g;
25                 $body =~ s/&/&/g;
26                 $body =~ s/</&lt;/g;
27                 $body =~ s/>/&gt;/g;
28                 print JELNET "<message to='$to'><subject>$subject</subject><body>$body</body></message>";
29         }
30         close JELNET;
31 }
32
33 checkConf( [ "xmpp_name", "xmpp_passwd", "jelnet" ] );
34
35 1;