]> mj.ucw.cz Git - pciids.git/blob - PciIds/Xmpp.pm
Get rid of SF and AnyBrowser logos
[pciids.git] / PciIds / Xmpp.pm
1 #       PciIds web database
2 #       Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
3 #
4 #       This program is free software; you can redistribute it and/or modify
5 #       it under the terms of the GNU General Public License as published by
6 #       he Free Software Foundation; either version 2 of the License, or
7 #       (at your option) any later version.
8 #
9 #       This program is distributed in the hope that it will be useful,
10 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #
13 #       GNU General Public License for more details.
14 #
15 #       You should have received a copy of the GNU General Public License
16 #       along with this program; if not, write to the Free Software
17 #       Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19 package PciIds::Xmpp;
20 use strict;
21 use warnings;
22 use PciIds::Config;
23 use base 'Exporter';
24
25 our @EXPORT = qw(&sendXmpp &flushXmpp);
26
27 my @pending;
28
29 sub sendXmpp( $$$ ) {
30         my( $to, $subject, $body ) = @_;
31         push @pending, [ $to, $subject, $body ];
32 }
33
34 sub flushXmpp() {
35         return unless @pending;
36         open JELNET, "|$config{jelnet} --silent-passwd \"$config{xmpp_name}\" > /dev/null" or die "Could not start XMPP sender\n";
37         print JELNET $config{"xmpp_passwd"}."\n";
38         foreach( @pending ) {
39                 my( $to, $subject, $body ) = @{$_};
40                 $subject =~ s/&/&/g;
41                 $subject =~ s/'/'/g;
42                 $subject =~ s/"/"/g;
43                 $body =~ s/&/&/g;
44                 $body =~ s/</&lt;/g;
45                 $body =~ s/>/&gt;/g;
46                 print JELNET "<message to='$to'><subject>$subject</subject><body>$body</body></message>";
47         }
48         close JELNET;
49 }
50
51 checkConf( [ "xmpp_name", "xmpp_passwd", "jelnet" ] );
52
53 1;