| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::MonM::Notifier::Const; # $Id: Const.pm 59 2019-07-14 09:14:38Z abalama $ | 
| 2 | 2 |  |  | 2 |  | 13 | use strict; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 48 |  | 
| 3 | 2 |  |  | 2 |  | 9 | use utf8; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 10 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =encoding utf-8 | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =head1 NAME | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | App::MonM::Notifier::Const - Interface for constants | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | =head1 VERSION | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | Version 1.01 | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | use App::MonM::Notifier::Const qw/ :bits :functions :jobs /; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | This module provide interface for constants | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =head1 VARIABLES | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =head2 EXPIRES | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | The default "expires" value (30 days) | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =head2 JOB_DONE | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | The "DONE" status | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =head2 JOB_ERROR | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | The "ERROR" status | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =head2 JOB_EXPIRED | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | The "EXPIRED" status | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | =head2 JOB_NEW | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | The "NEW" status | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =head2 JOB_PROGRESS | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | The "PROGRESS" status | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head2 JOB_SENT | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | The "SENT" status | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | =head2 JOB_SKIP | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | The "SKIP" status | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | =head2 TIMEOUT | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | The default timeout value (300 secs) | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =head1 FUNCTIONS | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =head2 getErr | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | my $errmsg = getErr(101); | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | Returns error mask for (s)printf by errorcode | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head1 HISTORY | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | See C file | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =head1 TO DO | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | See C file | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =head1 BUGS | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | * none noted | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | L | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =head1 AUTHOR | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | Serż Minus (Sergey Lepenkov) L Eabalama@cpan.orgE | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =head1 LICENSE | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or | 
| 96 |  |  |  |  |  |  | modify it under the same terms as Perl itself. | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | See C file and L | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | =cut | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | use constant { | 
| 103 |  |  |  |  |  |  | # General | 
| 104 | 2 |  |  |  |  | 252 | EXPIRES         => 30*24*60*60, # 30 days max (Time waiting for hold requests) | 
| 105 |  |  |  |  |  |  | TIMEOUT         => 300, | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | # Job Statuses (JOB_*) | 
| 108 |  |  |  |  |  |  | JOB_NEW         => "NEW",       # New job | 
| 109 |  |  |  |  |  |  | JOB_PROGRESS    => "PROGRESS",  # In progress... | 
| 110 |  |  |  |  |  |  | JOB_EXPIRED     => "EXPIRED",   # Expired job. Closed status | 
| 111 |  |  |  |  |  |  | JOB_SKIP        => "SKIP",      # Temporary error status. Closed status | 
| 112 |  |  |  |  |  |  | JOB_SENT        => "SENT",      # Ok status. Message is sent | 
| 113 |  |  |  |  |  |  | JOB_DONE        => "DONE",      # Ok status. Job is closed | 
| 114 |  |  |  |  |  |  | JOB_ERROR       => "ERROR",     # Error status. Closed status | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | # ERRORS | 
| 117 |  |  |  |  |  |  | ERRCODES    => { | 
| 118 |  |  |  |  |  |  | 0   => "Ok", | 
| 119 |  |  |  |  |  |  | 1   => "Unknown error", | 
| 120 |  |  |  |  |  |  | 101 => "Can't calculate the period. Please check configuration section for user %s", | 
| 121 |  |  |  |  |  |  | 102 => "Can't send message: %s", | 
| 122 |  |  |  |  |  |  | }, | 
| 123 | 2 |  |  | 2 |  | 133 | }; | 
|  | 2 |  |  |  |  | 4 |  | 
| 124 |  |  |  |  |  |  |  | 
| 125 | 2 |  |  | 2 |  | 12 | use base qw/Exporter/; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 178 |  | 
| 126 |  |  |  |  |  |  |  | 
| 127 | 2 |  |  | 2 |  | 13 | use CTK::ConfGenUtil; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 133 |  | 
| 128 | 2 |  |  | 2 |  | 14 | use CTK::TFVals qw/ :ALL /; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 383 |  | 
| 129 | 2 |  |  | 2 |  | 12 | use List::Util qw/ max /; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 156 |  | 
| 130 | 2 |  |  | 2 |  | 22 | use Carp; # carp - warn; croak - die; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 94 |  | 
| 131 |  |  |  |  |  |  |  | 
| 132 | 2 |  |  | 2 |  | 10 | use vars qw/$VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS/; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 389 |  | 
| 133 |  |  |  |  |  |  | $VERSION = '1.01'; | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | # Named groups of exports | 
| 136 |  |  |  |  |  |  | %EXPORT_TAGS = ( | 
| 137 |  |  |  |  |  |  | 'jobs'  => [qw/ | 
| 138 |  |  |  |  |  |  | JOB_NEW | 
| 139 |  |  |  |  |  |  | JOB_PROGRESS | 
| 140 |  |  |  |  |  |  | JOB_EXPIRED | 
| 141 |  |  |  |  |  |  | JOB_SKIP | 
| 142 |  |  |  |  |  |  | JOB_SENT | 
| 143 |  |  |  |  |  |  | JOB_DONE | 
| 144 |  |  |  |  |  |  | JOB_ERROR | 
| 145 |  |  |  |  |  |  | /], | 
| 146 |  |  |  |  |  |  | 'functions' => [qw/ | 
| 147 |  |  |  |  |  |  | getErr | 
| 148 |  |  |  |  |  |  | /], | 
| 149 |  |  |  |  |  |  | ); | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | # Items to export into callers namespace by default | 
| 152 |  |  |  |  |  |  | # (move infrequently used names to @EXPORT_OK below) | 
| 153 |  |  |  |  |  |  | @EXPORT = (qw/ | 
| 154 |  |  |  |  |  |  | EXPIRES | 
| 155 |  |  |  |  |  |  | TIMEOUT | 
| 156 |  |  |  |  |  |  | /, @{$EXPORT_TAGS{functions}}, @{$EXPORT_TAGS{jobs}}); | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  | # Other items we are prepared to export if requested | 
| 159 |  |  |  |  |  |  | @EXPORT_OK = (qw/ | 
| 160 |  |  |  |  |  |  | EXPIRES | 
| 161 |  |  |  |  |  |  | TIMEOUT | 
| 162 |  |  |  |  |  |  | /, map {@{$_}} values %EXPORT_TAGS); | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | sub getErr { | 
| 165 | 0 |  |  | 0 | 1 |  | my $code = shift; | 
| 166 | 0 |  |  |  |  |  | my %es = %{(ERRCODES)}; | 
|  | 0 |  |  |  |  |  |  | 
| 167 | 0 | 0 | 0 |  |  |  | do {carp("Incorrect error code"); return} unless defined($code) && exists($es{$code}); | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 168 | 0 |  |  |  |  |  | return $es{$code}; | 
| 169 |  |  |  |  |  |  | } | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  | 1; |