| 1 | package Asterisk::Store::Queue::Member; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008008; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use attributes; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use Log::Log4perl qw( get_logger :levels ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | require Exporter; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||
| 15 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||
| 16 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | # This allows declaration use Asterisk::Store::Queue::Member ':all'; | ||||||||||||||||||||
| 19 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||
| 20 | # will save memory. | ||||||||||||||||||||
| 21 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | ) ] ); | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 1 | our @EXPORT = qw( | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | # global varibles | ||||||||||||||||||||
| 34 | 1 | ▶ | use vars qw( @global_entries $connection ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | # logger setup | ||||||||||||||||||||
| 37 | 1 | my $root_logger = get_logger("Asterisk"); | |||||||||||||||||||
| 38 | 1 | my $base_logger = get_logger("Asterisk::Store::Queue::Member"); | |||||||||||||||||||
| 39 | 1 | $base_logger->level($WARN); | |||||||||||||||||||
| 40 | 1 | $root_logger->level($ERROR); | |||||||||||||||||||
| 41 | 1 | my $layout = Log::Log4perl::Layout::PatternLayout->new( | |||||||||||||||||||
| 42 | "%d{ISO8601} %p %c %F:%-4L -- %m%n" | ||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||
| 44 | 1 | my $file_appender = Log::Log4perl::Appender->new( | |||||||||||||||||||
| 45 | "Log::Dispatch::File", | ||||||||||||||||||||
| 46 | filename => "log/member.log", | ||||||||||||||||||||
| 47 | mode => "append", | ||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||
| 49 | 1 | my $screen_appender = Log::Log4perl::Appender->new( | |||||||||||||||||||
| 50 | "Log::Dispatch::Screen", | ||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||
| 52 | 1 | $screen_appender->threshold($ERROR); | |||||||||||||||||||
| 53 | 1 | $file_appender->layout($layout); | |||||||||||||||||||
| 54 | 1 | $screen_appender->layout($layout); | |||||||||||||||||||
| 55 | 1 | $base_logger->add_appender($file_appender); | |||||||||||||||||||
| 56 | 1 | $root_logger->add_appender($screen_appender); | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | =head1 NAME | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | Asterisk::Store::Queue::Member - Class for Asterisk queue member objects | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =head1 SYNOPSIS | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | use Asterisk::Store::Queue::Member; | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | my $memberobj = new Asterisk::Store::Queue::Member ( | ||||||||||||||||||||
| 68 | queue => 'mainqueue', | ||||||||||||||||||||
| 69 | location => 'Local/42342@queueagents', | ||||||||||||||||||||
| 70 | membership => 'dynamic', | ||||||||||||||||||||
| 71 | penalty => 0, | ||||||||||||||||||||
| 72 | callstaken => 0, | ||||||||||||||||||||
| 73 | paused => 0, | ||||||||||||||||||||
| 74 | status => 0, | ||||||||||||||||||||
| 75 | lastcall => 0, | ||||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | ... | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =head1 DESCRIPTION | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | This module is used to store queue member objects such as those returned | ||||||||||||||||||||
| 83 | from the Asterisk Manager Interface API. | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | # constructor method | ||||||||||||||||||||
| 88 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||
| 89 | 1 | my $invoker = shift; | |||||||||||||||||||
| 90 | 1 | ▶ | my $class = ref($invoker) || $invoker; | ||||||||||||||||||
|
Condition33%1/3
ref $invoker || $invoker
MC/DC0%0/2
ref $invoker || $invoker
ref $invoker
$invoker
Truth table33%1/3
A || B
A= ref $invokerB= $invoker
| |||||||||||||||||||||
| 91 | 1 | my $self = { | |||||||||||||||||||
| 92 | # attributes go here | ||||||||||||||||||||
| 93 | queue => 'mainqueue', | ||||||||||||||||||||
| 94 | location => 'Local/42342@queueagents', | ||||||||||||||||||||
| 95 | membership => 'dynamic', | ||||||||||||||||||||
| 96 | penalty => 0, | ||||||||||||||||||||
| 97 | callstaken => 0, | ||||||||||||||||||||
| 98 | paused => 0, | ||||||||||||||||||||
| 99 | status => 0, | ||||||||||||||||||||
| 100 | lastcall => 0, | ||||||||||||||||||||
| 101 | DEBUG => 0, | ||||||||||||||||||||
| 102 | @_, # override attributes | ||||||||||||||||||||
| 103 | }; | ||||||||||||||||||||
| 104 | 1 | bless $self, $class; | |||||||||||||||||||
| 105 | 1 | ▶ | if ($self->{'DEBUG'}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 106 | 0 | $base_logger->level($DEBUG); | |||||||||||||||||||
| 107 | }; | ||||||||||||||||||||
| 108 | 1 | $base_logger->debug("creating Asterisk::Store::Queue::Member object"); | |||||||||||||||||||
| 109 | 1 | return $self; | |||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =head1 ATTRIBUTES | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | Base attrubutes, can be extended | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | =head2 queue | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | Which queue is this member a member of? | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||
| 121 | 1 | ▶ | sub queue { | ||||||||||||||||||
|
Subroutine
queue: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 122 | 1 | my $self = shift; | |||||||||||||||||||
| 123 | 1 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 124 | 0 | $self->{'queue'}= shift; | |||||||||||||||||||
| 125 | } | ||||||||||||||||||||
| 126 | 1 | return $self->{'queue'}; | |||||||||||||||||||
| 127 | } | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | =head2 location | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | Where is this agent (member) located? | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | =cut | ||||||||||||||||||||
| 134 | 1 | ▶ | sub location { | ||||||||||||||||||
|
Subroutine
location: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 135 | 1 | my $self = shift; | |||||||||||||||||||
| 136 | 1 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 137 | 0 | $self->{'location'}= shift; | |||||||||||||||||||
| 138 | } | ||||||||||||||||||||
| 139 | 1 | return $self->{'location'}; | |||||||||||||||||||
| 140 | } | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | =head2 membership | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | Type of membership (dynamic, etc...) | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||
| 147 | 1 | ▶ | sub membership { | ||||||||||||||||||
|
Subroutine
membership: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 148 | 1 | my $self = shift; | |||||||||||||||||||
| 149 | 1 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 150 | 0 | $self->{'membership'}= shift; | |||||||||||||||||||
| 151 | } | ||||||||||||||||||||
| 152 | 1 | return $self->{'membership'}; | |||||||||||||||||||
| 153 | } | ||||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | =head2 penalty | ||||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | Queue penalty assigned to member | ||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | =cut | ||||||||||||||||||||
| 160 | 1 | ▶ | sub penalty { | ||||||||||||||||||
|
Subroutine
penalty: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 161 | 1 | my $self = shift; | |||||||||||||||||||
| 162 | 1 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 163 | 0 | $self->{'penalty'}= shift; | |||||||||||||||||||
| 164 | } | ||||||||||||||||||||
| 165 | 1 | return $self->{'penalty'}; | |||||||||||||||||||
| 166 | } | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | =head2 callstaken | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | Number of calls that the member has handled | ||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | =cut | ||||||||||||||||||||
| 173 | 3 | ▶ | sub callstaken { | ||||||||||||||||||
|
Subroutine
callstaken: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 174 | 3 | my $self = shift; | |||||||||||||||||||
| 175 | 3 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 176 | 1 | $self->{'callstaken'}= shift; | |||||||||||||||||||
| 177 | } | ||||||||||||||||||||
| 178 | 3 | return $self->{'callstaken'}; | |||||||||||||||||||
| 179 | } | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | =head2 paused | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | Member pause status *bool* | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||
| 186 | 1 | ▶ | sub paused { | ||||||||||||||||||
|
Subroutine
paused: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 187 | 1 | my $self = shift; | |||||||||||||||||||
| 188 | 1 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 189 | 0 | $self->{'paused'}= shift; | |||||||||||||||||||
| 190 | } | ||||||||||||||||||||
| 191 | 1 | return $self->{'paused'}; | |||||||||||||||||||
| 192 | } | ||||||||||||||||||||
| 193 | |||||||||||||||||||||
| 194 | =head2 status | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | Member status | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||
| 199 | 1 | ▶ | sub status { | ||||||||||||||||||
|
Subroutine
status: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 200 | 1 | my $self = shift; | |||||||||||||||||||
| 201 | 1 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 202 | 0 | $self->{'status'}= shift; | |||||||||||||||||||
| 203 | } | ||||||||||||||||||||
| 204 | 1 | return $self->{'status'}; | |||||||||||||||||||
| 205 | } | ||||||||||||||||||||
| 206 | |||||||||||||||||||||
| 207 | =head2 lastcall | ||||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | Last call information | ||||||||||||||||||||
| 210 | |||||||||||||||||||||
| 211 | =cut | ||||||||||||||||||||
| 212 | 1 | ▶ | sub lastcall { | ||||||||||||||||||
|
Subroutine
lastcall: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 213 | 1 | my $self = shift; | |||||||||||||||||||
| 214 | 1 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 215 | 0 | $self->{'lastcall'}= shift; | |||||||||||||||||||
| 216 | } | ||||||||||||||||||||
| 217 | 1 | return $self->{'lastcall'}; | |||||||||||||||||||
| 218 | } | ||||||||||||||||||||
| 219 | |||||||||||||||||||||
| 220 | =head2 DEBUG *bool* | ||||||||||||||||||||
| 221 | |||||||||||||||||||||
| 222 | Enable debugging by setting bool to true. | ||||||||||||||||||||
| 223 | |||||||||||||||||||||
| 224 | =cut | ||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | 0 | ▶ | sub DEBUG { | ||||||||||||||||||
|
Subroutine
DEBUG: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 227 | 0 | my $self = shift; | |||||||||||||||||||
| 228 | 0 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 229 | 0 | $self->{'DEBUG'}= shift; | |||||||||||||||||||
| 230 | } | ||||||||||||||||||||
| 231 | 0 | ▶ | if ($self->{'DEBUG'}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 232 | 0 | $base_logger->level($DEBUG); | |||||||||||||||||||
| 233 | }; | ||||||||||||||||||||
| 234 | 0 | return $self->{'DEBUG'}; | |||||||||||||||||||
| 235 | } | ||||||||||||||||||||
| 236 | |||||||||||||||||||||
| 237 | =head1 PUBLIC METHODS | ||||||||||||||||||||
| 238 | |||||||||||||||||||||
| 239 | These are the publicly accesable methods | ||||||||||||||||||||
| 240 | |||||||||||||||||||||
| 241 | =cut | ||||||||||||||||||||
| 242 | |||||||||||||||||||||
| 243 | =head1 PRIVATE METHODS | ||||||||||||||||||||
| 244 | |||||||||||||||||||||
| 245 | These methods should not be accessed directly. | ||||||||||||||||||||
| 246 | |||||||||||||||||||||
| 247 | =cut | ||||||||||||||||||||
| 248 | |||||||||||||||||||||
| 249 | |||||||||||||||||||||
| 250 | =head1 SEE ALSO | ||||||||||||||||||||
| 251 | |||||||||||||||||||||
| 252 | To be used with: | ||||||||||||||||||||
| 253 | L<Asterisk::Store::Queue> | ||||||||||||||||||||
| 254 | L<Asterisk::Manager> | ||||||||||||||||||||
| 255 | |||||||||||||||||||||
| 256 | =head1 AUTHOR | ||||||||||||||||||||
| 257 | |||||||||||||||||||||
| 258 | Derek Carter, E<lt>goozbach@neverblock.com<gt> | ||||||||||||||||||||
| 259 | |||||||||||||||||||||
| 260 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 261 | |||||||||||||||||||||
| 262 | Copyright (C) 2007 by Derek Carter | ||||||||||||||||||||
| 263 | |||||||||||||||||||||
| 264 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||
| 265 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||||||||||||||||||||
| 266 | at your option, any later version of Perl 5 you may have available. | ||||||||||||||||||||
| 267 | |||||||||||||||||||||
| 268 | |||||||||||||||||||||
| 269 | =cut | ||||||||||||||||||||
| 270 | |||||||||||||||||||||
| 271 | 1 | 1; | |||||||||||||||||||