File Coverage

blib/lib/Kolab/LDAP/Backend/dirservd.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Kolab::LDAP::Backend::dirservd;
2              
3             ##
4             ## Copyright (c) 2003 Code Fusion cc
5             ##
6             ## Writen by Stuart Bingė
7             ##
8             ## This program is free software; you can redistribute it and/or
9             ## modify it under the terms of the GNU General Public License as
10             ## published by the Free Software Foundation; either version 2, or
11             ## (at your option) any later version.
12             ##
13             ## This program is distributed in the hope that it will be useful,
14             ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15             ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16             ## General Public License for more details.
17             ##
18             ## You can view the GNU General Public License, online, at the GNU
19             ## Project's homepage; see .
20             ##
21              
22 1     1   20435 use 5.008;
  1         4  
  1         35  
23 1     1   5 use strict;
  1         2  
  1         34  
24 1     1   4 use warnings;
  1         6  
  1         39  
25 1     1   445 use Kolab;
  0            
  0            
26             use Kolab::Util;
27             use Kolab::LDAP;
28             use Net::LDAP;
29             use Net::LDAP::Control;
30             use vars qw($ldap $cyrus);
31              
32             require Exporter;
33              
34             our @ISA = qw(Exporter);
35              
36             our %EXPORT_TAGS = (
37             'all' => [ qw(
38             &startup
39             &run
40             ) ]
41             );
42              
43             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
44              
45             our @EXPORT = qw(
46              
47             );
48              
49             our $VERSION = sprintf('%d.%02d', q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/);
50              
51             sub startup { 1; }
52              
53             sub shutdown
54             {
55             Kolab::log('DSd', 'Shutting down');
56             exit(0);
57             }
58              
59             sub abort
60             {
61             Kolab::log('DSd', 'Aborting');
62             exit(1);
63             }
64              
65             sub run
66             {
67             # This should be called from a separate thread, as we set our
68             # own interrupt handlers here
69              
70             $SIG{'INT'} = \&shutdown;
71             $SIG{'TERM'} = \&shutdown;
72              
73             END {
74             alarm 0;
75             }
76              
77             my $mesg;
78              
79             Kolab::log('DSd', 'Listener starting up, refresh is: '.$Kolab::config{'dirserv_poll_period'}." seconds");
80              
81             #while ($Kolab::config{'dirserv_mailbox_server'} ne '') {
82             while (1) {
83              
84             if ($Kolab::config{'dirserv_mailbox_user'} ne "") {
85             Kolab::log('DSd', 'Polling for DirServ updates', KOLAB_DEBUG);
86             Kolab::DirServ::handleNotifications(
87             $Kolab::config{'dirserv_mailbox_server'},
88             $Kolab::config{'dirserv_mailbox_user'},
89             $Kolab::config{'dirserv_mailbox_password'},
90             );
91             }
92              
93             sleep($Kolab::config{'dirserv_poll_period'});
94              
95              
96             };
97              
98              
99              
100             1;
101             }
102              
103             1;
104             __END__