Lines 276-282
foreach my $i (keys(%handlers)) {
Link Here
|
276 |
} |
276 |
} |
277 |
|
277 |
|
278 |
sub new { |
278 |
sub new { |
279 |
my ($class, $msg, $seqno) = @_; |
279 |
my ($class, $msg, $seqno, $server) = @_; |
280 |
my $self = {}; |
280 |
my $self = {}; |
281 |
my $msgtag = substr($msg, 0, 2); |
281 |
my $msgtag = substr($msg, 0, 2); |
282 |
|
282 |
|
Lines 287-300
sub new {
Link Here
|
287 |
# it's using the 2.00 login process, so it must support 2.00. |
287 |
# it's using the 2.00 login process, so it must support 2.00. |
288 |
$protocol_version = 2; |
288 |
$protocol_version = 2; |
289 |
} |
289 |
} |
|
|
290 |
my $id = $server->{account} ? $server->{account}->{id} . ':' : q{}; |
291 |
$server->{logger}->debug( "$server->{server}->{peeraddr}:$id Sip::MsgType::new('$class', '" . substr($msg, 0, 10) |
292 |
. "...', '$msgtag'): seq.no '$seqno', protocol $protocol_version" ); |
290 |
syslog("LOG_DEBUG", "Sip::MsgType::new('%s', '%s...', '%s'): seq.no '%s', protocol %s", |
293 |
syslog("LOG_DEBUG", "Sip::MsgType::new('%s', '%s...', '%s'): seq.no '%s', protocol %s", |
291 |
$class, substr($msg, 0, 10), $msgtag, $seqno, $protocol_version); |
294 |
$class, substr($msg, 0, 10), $msgtag, $seqno, $protocol_version); |
292 |
# warn "SIP PROTOCOL: $protocol_version"; |
|
|
293 |
if (!exists($handlers{$msgtag})) { |
295 |
if (!exists($handlers{$msgtag})) { |
|
|
296 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$id new Sip::MsgType: Skipping message of unknown type '$msgtag' in '$msg'"); |
294 |
syslog("LOG_WARNING", "new Sip::MsgType: Skipping message of unknown type '%s' in '%s'", |
297 |
syslog("LOG_WARNING", "new Sip::MsgType: Skipping message of unknown type '%s' in '%s'", |
295 |
$msgtag, $msg); |
298 |
$msgtag, $msg); |
296 |
return; |
299 |
return; |
297 |
} elsif (!exists($handlers{$msgtag}->{protocol}->{$protocol_version})) { |
300 |
} elsif (!exists($handlers{$msgtag}->{protocol}->{$protocol_version})) { |
|
|
301 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$id new Sip::MsgType: Skipping message '$msgtag' unsupported by protocol rev. '$protocol_version'"); |
298 |
syslog("LOG_WARNING", "new Sip::MsgType: Skipping message '%s' unsupported by protocol rev. '%d'", |
302 |
syslog("LOG_WARNING", "new Sip::MsgType: Skipping message '%s' unsupported by protocol rev. '%d'", |
299 |
$msgtag, $protocol_version); |
303 |
$msgtag, $protocol_version); |
300 |
return; |
304 |
return; |
Lines 302-307
sub new {
Link Here
|
302 |
|
306 |
|
303 |
bless $self, $class; |
307 |
bless $self, $class; |
304 |
|
308 |
|
|
|
309 |
$self->{server} = $server; |
305 |
$self->{seqno} = $seqno; |
310 |
$self->{seqno} = $seqno; |
306 |
$self->_initialize(substr($msg,2), $handlers{$msgtag}); |
311 |
$self->_initialize(substr($msg,2), $handlers{$msgtag}); |
307 |
|
312 |
|
Lines 328-333
sub _initialize {
Link Here
|
328 |
$self->{fields}->{$field} = undef; |
333 |
$self->{fields}->{$field} = undef; |
329 |
} |
334 |
} |
330 |
|
335 |
|
|
|
336 |
my $id = $self->{server}->{account} ? $self->{server}->{account}->{id} . ':' : q{}; |
337 |
$self->{server}->{logger}->debug("$self->{server}->{server}->{peeraddr}:$id Sip::MsgType::_initialize('$self->{name}', '$msg', '$proto->{template}', '$proto->{template_len}', ...)"); |
331 |
syslog("LOG_DEBUG", "Sip::MsgType::_initialize('%s', '%s', '%s', '%s', ...)", |
338 |
syslog("LOG_DEBUG", "Sip::MsgType::_initialize('%s', '%s', '%s', '%s', ...)", |
332 |
$self->{name}, $msg, $proto->{template}, $proto->{template_len}); |
339 |
$self->{name}, $msg, $proto->{template}, $proto->{template_len}); |
333 |
|
340 |
|
Lines 339-347
sub _initialize {
Link Here
|
339 |
$fn = substr($field, 0, 2); |
346 |
$fn = substr($field, 0, 2); |
340 |
|
347 |
|
341 |
if (!exists($self->{fields}->{$fn})) { |
348 |
if (!exists($self->{fields}->{$fn})) { |
|
|
349 |
$self->{server}->{logger}->warn("$self->{server}->{server}->{peeraddr}:$id: Unsupported field '$fn' in $self->{name}, message '$msg'"); |
342 |
syslog("LOG_WARNING", "Unsupported field '%s' in %s message '%s'", |
350 |
syslog("LOG_WARNING", "Unsupported field '%s' in %s message '%s'", |
343 |
$fn, $self->{name}, $msg); |
351 |
$fn, $self->{name}, $msg); |
344 |
} elsif (defined($self->{fields}->{$fn})) { |
352 |
} elsif (defined($self->{fields}->{$fn})) { |
|
|
353 |
$self->{server}->{logger}->warn("$self->{server}->{server}->{peeraddr}:$id: Duplicate field '$fn' (previous value '$self->{fields}->{$fn}') in $self->{name} message '$msg'"); |
345 |
syslog("LOG_WARNING", "Duplicate field '%s' (previous value '%s') in %s message '%s'", |
354 |
syslog("LOG_WARNING", "Duplicate field '%s' (previous value '%s') in %s message '%s'", |
346 |
$fn, $self->{fields}->{$fn}, $self->{name}, $msg); |
355 |
$fn, $self->{fields}->{$fn}, $self->{name}, $msg); |
347 |
} else { |
356 |
} else { |
Lines 373-383
sub handle {
Link Here
|
373 |
if ($msg eq REQUEST_ACS_RESEND_CKSUM) { |
382 |
if ($msg eq REQUEST_ACS_RESEND_CKSUM) { |
374 |
# Special case |
383 |
# Special case |
375 |
$error_detection = 1; |
384 |
$error_detection = 1; |
376 |
$self = C4::SIP::Sip::MsgType->new((REQUEST_ACS_RESEND), 0); |
385 |
$self = C4::SIP::Sip::MsgType->new( (REQUEST_ACS_RESEND), 0, $server ); |
377 |
} elsif((length($msg) > 11) && (substr($msg, -9, 2) eq "AY")) { |
386 |
} elsif((length($msg) > 11) && (substr($msg, -9, 2) eq "AY")) { |
378 |
$error_detection = 1; |
387 |
$error_detection = 1; |
379 |
|
388 |
|
380 |
if (!verify_cksum($msg)) { |
389 |
if (!verify_cksum($msg)) { |
|
|
390 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: Checksum failed on message '$msg'"); |
381 |
syslog("LOG_WARNING", "Checksum failed on message '%s'", $msg); |
391 |
syslog("LOG_WARNING", "Checksum failed on message '%s'", $msg); |
382 |
# REQUEST_SC_RESEND with error detection |
392 |
# REQUEST_SC_RESEND with error detection |
383 |
$last_response = REQUEST_SC_RESEND_CKSUM; |
393 |
$last_response = REQUEST_SC_RESEND_CKSUM; |
Lines 386-402
sub handle {
Link Here
|
386 |
} else { |
396 |
} else { |
387 |
# Save the sequence number, then strip off the |
397 |
# Save the sequence number, then strip off the |
388 |
# error detection data to process the message |
398 |
# error detection data to process the message |
389 |
$self = C4::SIP::Sip::MsgType->new(substr($msg, 0, -9), substr($msg, -7, 1)); |
399 |
$self = C4::SIP::Sip::MsgType->new( substr( $msg, 0, -9 ), substr( $msg, -7, 1 ), $server ); |
390 |
} |
400 |
} |
391 |
} elsif ($error_detection) { |
401 |
} elsif ($error_detection) { |
392 |
# We received a non-ED message when ED is supposed to be active. |
402 |
# We received a non-ED message when ED is supposed to be active. |
393 |
# Warn about this problem, then process the message anyway. |
403 |
# Warn about this problem, then process the message anyway. |
|
|
404 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: Received message without error detection: '$msg'"); |
394 |
syslog("LOG_WARNING", |
405 |
syslog("LOG_WARNING", |
395 |
"Received message without error detection: '%s'", $msg); |
406 |
"Received message without error detection: '%s'", $msg); |
396 |
$error_detection = 0; |
407 |
$error_detection = 0; |
397 |
$self = C4::SIP::Sip::MsgType->new($msg, 0); |
408 |
$self = C4::SIP::Sip::MsgType->new( $msg, 0, $server ); |
398 |
} else { |
409 |
} else { |
399 |
$self = C4::SIP::Sip::MsgType->new($msg, 0); |
410 |
$self = C4::SIP::Sip::MsgType->new( $msg, 0, $server ); |
400 |
} |
411 |
} |
401 |
|
412 |
|
402 |
if ((substr($msg, 0, 2) ne REQUEST_ACS_RESEND) && |
413 |
if ((substr($msg, 0, 2) ne REQUEST_ACS_RESEND) && |
Lines 404-409
sub handle {
Link Here
|
404 |
return substr($msg, 0, 2); |
415 |
return substr($msg, 0, 2); |
405 |
} |
416 |
} |
406 |
unless ($self->{handler}) { |
417 |
unless ($self->{handler}) { |
|
|
418 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: No handler defined for '$msg'"); |
407 |
syslog("LOG_WARNING", "No handler defined for '%s'", $msg); |
419 |
syslog("LOG_WARNING", "No handler defined for '%s'", $msg); |
408 |
$last_response = REQUEST_SC_RESEND; |
420 |
$last_response = REQUEST_SC_RESEND; |
409 |
print("$last_response\r"); |
421 |
print("$last_response\r"); |
Lines 437-443
sub build_patron_status {
Link Here
|
437 |
my $resp = (PATRON_STATUS_RESP); |
449 |
my $resp = (PATRON_STATUS_RESP); |
438 |
|
450 |
|
439 |
if ($patron) { |
451 |
if ($patron) { |
440 |
$resp .= patron_status_string($patron); |
452 |
$resp .= patron_status_string( $patron, $server ); |
441 |
$resp .= $lang . timestamp(); |
453 |
$resp .= $lang . timestamp(); |
442 |
$resp .= add_field(FID_PERSONAL_NAME, $patron->name); |
454 |
$resp .= add_field(FID_PERSONAL_NAME, $patron->name); |
443 |
|
455 |
|
Lines 518-523
sub handle_checkout {
Link Here
|
518 |
|
530 |
|
519 |
# Off-line transactions need to be recorded, but there's |
531 |
# Off-line transactions need to be recorded, but there's |
520 |
# not a lot we can do about it |
532 |
# not a lot we can do about it |
|
|
533 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: received no-block checkout from terminal '$account->{id}'"); |
521 |
syslog( "LOG_WARNING", "received no-block checkout from terminal '%s'", $account->{id} ); |
534 |
syslog( "LOG_WARNING", "received no-block checkout from terminal '%s'", $account->{id} ); |
522 |
|
535 |
|
523 |
$status = $ils->checkout_no_block( $patron_id, $item_id, $sc_renewal_policy, $trans_date, $nb_due_date ); |
536 |
$status = $ils->checkout_no_block( $patron_id, $item_id, $sc_renewal_policy, $trans_date, $nb_due_date ); |
Lines 640-645
sub handle_checkin {
Link Here
|
640 |
|
653 |
|
641 |
if ($no_block eq 'Y') { |
654 |
if ($no_block eq 'Y') { |
642 |
# Off-line transactions, ick. |
655 |
# Off-line transactions, ick. |
|
|
656 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: received no-block checkin from terminal '$account->{id}'"); |
643 |
syslog("LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id}); |
657 |
syslog("LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id}); |
644 |
$status = $ils->checkin_no_block($item_id, $trans_date, $return_date, $item_props, $cancel); |
658 |
$status = $ils->checkin_no_block($item_id, $trans_date, $return_date, $item_props, $cancel); |
645 |
} else { |
659 |
} else { |
Lines 759-779
sub handle_sc_status {
Link Here
|
759 |
} elsif ($sc_protocol_version =~ /^2\./) { |
773 |
} elsif ($sc_protocol_version =~ /^2\./) { |
760 |
$new_proto = 2; |
774 |
$new_proto = 2; |
761 |
} else { |
775 |
} else { |
|
|
776 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: Unrecognized protocol revision '$sc_protocol_version', falling back to '1'"); |
762 |
syslog("LOG_WARNING", "Unrecognized protocol revision '%s', falling back to '1'", $sc_protocol_version); |
777 |
syslog("LOG_WARNING", "Unrecognized protocol revision '%s', falling back to '1'", $sc_protocol_version); |
763 |
$new_proto = 1; |
778 |
$new_proto = 1; |
764 |
} |
779 |
} |
765 |
|
780 |
|
766 |
if ($new_proto != $protocol_version) { |
781 |
if ($new_proto != $protocol_version) { |
|
|
782 |
$server->{logger}->info("$server->{server}->{peeraddr}:$server->{account}->{id}: Setting protocol level to $new_proto"); |
767 |
syslog("LOG_INFO", "Setting protocol level to $new_proto"); |
783 |
syslog("LOG_INFO", "Setting protocol level to $new_proto"); |
768 |
$protocol_version = $new_proto; |
784 |
$protocol_version = $new_proto; |
769 |
} |
785 |
} |
770 |
|
786 |
|
771 |
if ($status == SC_STATUS_PAPER) { |
787 |
if ($status == SC_STATUS_PAPER) { |
772 |
syslog("LOG_WARNING", "Self-Check unit '%s@%s' out of paper", |
788 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' out of paper"); |
773 |
$self->{account}->{id}, $self->{account}->{institution}); |
789 |
syslog("LOG_WARNING", "Self-Check unit '%s@%s' out of paper", |
|
|
790 |
$self->{account}->{id}, $self->{account}->{institution}); |
774 |
} elsif ($status == SC_STATUS_SHUTDOWN) { |
791 |
} elsif ($status == SC_STATUS_SHUTDOWN) { |
775 |
syslog("LOG_WARNING", "Self-Check unit '%s@%s' shutting down", |
792 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: Self-Check unit '$self->{account}->{id}@$self->{account}->{institution}' shutting down"); |
776 |
$self->{account}->{id}, $self->{account}->{institution}); |
793 |
syslog("LOG_WARNING", "Self-Check unit '%s@%s' shutting down", |
|
|
794 |
$self->{account}->{id}, $self->{account}->{institution}); |
777 |
} |
795 |
} |
778 |
|
796 |
|
779 |
$self->{account}->{print_width} = $print_width; |
797 |
$self->{account}->{print_width} = $print_width; |
Lines 810-818
sub login_core {
Link Here
|
810 |
my $pwd = shift; |
828 |
my $pwd = shift; |
811 |
my $status = 1; # Assume it all works |
829 |
my $status = 1; # Assume it all works |
812 |
if (!exists($server->{config}->{accounts}->{$uid})) { |
830 |
if (!exists($server->{config}->{accounts}->{$uid})) { |
|
|
831 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: MsgType::login_core: Unknown login '$uid'"); |
813 |
syslog("LOG_WARNING", "MsgType::login_core: Unknown login '$uid'"); |
832 |
syslog("LOG_WARNING", "MsgType::login_core: Unknown login '$uid'"); |
814 |
$status = 0; |
833 |
$status = 0; |
815 |
} elsif ($server->{config}->{accounts}->{$uid}->{password} ne $pwd) { |
834 |
} elsif ($server->{config}->{accounts}->{$uid}->{password} ne $pwd) { |
|
|
835 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: MsgType::login_core: Invalid password for login '$uid'"); |
816 |
syslog("LOG_WARNING", "MsgType::login_core: Invalid password for login '$uid'"); |
836 |
syslog("LOG_WARNING", "MsgType::login_core: Invalid password for login '$uid'"); |
817 |
$status = 0; |
837 |
$status = 0; |
818 |
} else { |
838 |
} else { |
Lines 826-840
sub login_core {
Link Here
|
826 |
|
846 |
|
827 |
my $auth_status = api_auth($uid,$pwd,$inst); |
847 |
my $auth_status = api_auth($uid,$pwd,$inst); |
828 |
if (!$auth_status or $auth_status !~ /^ok$/i) { |
848 |
if (!$auth_status or $auth_status !~ /^ok$/i) { |
|
|
849 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: api_auth failed for SIP terminal '$uid' of '$inst': " . ($auth_status||'unknown') ); |
829 |
syslog("LOG_WARNING", "api_auth failed for SIP terminal '%s' of '%s': %s", |
850 |
syslog("LOG_WARNING", "api_auth failed for SIP terminal '%s' of '%s': %s", |
830 |
$uid, $inst, ($auth_status||'unknown')); |
851 |
$uid, $inst, ($auth_status||'unknown')); |
831 |
$status = 0; |
852 |
$status = 0; |
832 |
} else { |
853 |
} else { |
|
|
854 |
$server->{logger}->info("$server->{server}->{peeraddr}:$server->{account}->{id}: Successful login/auth for '$server->{account}->{id}' of '$inst'"); |
833 |
syslog("LOG_INFO", "Successful login/auth for '%s' of '%s'", $server->{account}->{id}, $inst); |
855 |
syslog("LOG_INFO", "Successful login/auth for '%s' of '%s'", $server->{account}->{id}, $inst); |
834 |
# |
856 |
# |
835 |
# initialize connection to ILS |
857 |
# initialize connection to ILS |
836 |
# |
858 |
# |
837 |
my $module = $server->{config}->{institutions}->{$inst}->{implementation}; |
859 |
my $module = $server->{config}->{institutions}->{$inst}->{implementation}; |
|
|
860 |
$server->{logger}->debug("$server->{server}->{peeraddr}:$server->{account}->{id}: login_core: " . Dumper($module) ); |
838 |
syslog("LOG_DEBUG", 'login_core: ' . Dumper($module)); |
861 |
syslog("LOG_DEBUG", 'login_core: ' . Dumper($module)); |
839 |
# Suspect this is always ILS but so we don't break any eccentic install (for now) |
862 |
# Suspect this is always ILS but so we don't break any eccentic install (for now) |
840 |
if ($module eq 'ILS') { |
863 |
if ($module eq 'ILS') { |
Lines 842-855
sub login_core {
Link Here
|
842 |
} |
865 |
} |
843 |
$module->use; |
866 |
$module->use; |
844 |
if ($@) { |
867 |
if ($@) { |
|
|
868 |
$server->{logger}->error("$server->{server}->{peeraddr}:$server->{service}: Loading ILS implementation '$module' for institution '$inst' failed"); |
845 |
syslog("LOG_ERR", "%s: Loading ILS implementation '%s' for institution '%s' failed", |
869 |
syslog("LOG_ERR", "%s: Loading ILS implementation '%s' for institution '%s' failed", |
846 |
$server->{service}, $module, $inst); |
870 |
$server->{service}, $module, $inst); |
847 |
die("Failed to load ILS implementation '$module' for $inst"); |
871 |
die("Failed to load ILS implementation '$module' for $inst"); |
848 |
} |
872 |
} |
849 |
|
873 |
|
850 |
# like ILS->new(), I think. |
874 |
# like ILS->new(), I think. |
851 |
$server->{ils} = $module->new($server->{institution}, $server->{account}); |
875 |
|
|
|
876 |
$server->{ils} = $module->new( $server->{institution}, $server->{account}, $server ); |
852 |
if (!$server->{ils}) { |
877 |
if (!$server->{ils}) { |
|
|
878 |
$server->{logger}->error("$server->{server}->{peeraddr}:$server->{account}->{id}: $server->{service}: ILS connection to '$inst' failed"); |
853 |
syslog("LOG_ERR", "%s: ILS connection to '%s' failed", $server->{service}, $inst); |
879 |
syslog("LOG_ERR", "%s: ILS connection to '%s' failed", $server->{service}, $inst); |
854 |
die("Unable to connect to ILS '$inst'"); |
880 |
die("Unable to connect to ILS '$inst'"); |
855 |
} |
881 |
} |
Lines 873-878
sub handle_login {
Link Here
|
873 |
$pwd = $fields->{(FID_LOGIN_PWD)}; # Terminal PWD, not patron PWD. |
899 |
$pwd = $fields->{(FID_LOGIN_PWD)}; # Terminal PWD, not patron PWD. |
874 |
|
900 |
|
875 |
if ($uid_algorithm || $pwd_algorithm) { |
901 |
if ($uid_algorithm || $pwd_algorithm) { |
|
|
902 |
$server->{logger}->error("$server->{server}->{peeraddr}:$server->{account}->{id}: LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm"); |
876 |
syslog("LOG_ERR", "LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm"); |
903 |
syslog("LOG_ERR", "LOGIN: Unsupported non-zero encryption method(s): uid = $uid_algorithm, pwd = $pwd_algorithm"); |
877 |
$status = 0; |
904 |
$status = 0; |
878 |
} |
905 |
} |
Lines 890-896
sub handle_login {
Link Here
|
890 |
# and we're going to believe it. |
917 |
# and we're going to believe it. |
891 |
# |
918 |
# |
892 |
sub summary_info { |
919 |
sub summary_info { |
893 |
my ($ils, $patron, $summary, $start, $end) = @_; |
920 |
my ($server, $ils, $patron, $summary, $start, $end) = @_; |
894 |
my $resp = ''; |
921 |
my $resp = ''; |
895 |
my $summary_type; |
922 |
my $summary_type; |
896 |
# |
923 |
# |
Lines 910-915
sub summary_info {
Link Here
|
910 |
return ''; # No detailed information required |
937 |
return ''; # No detailed information required |
911 |
} |
938 |
} |
912 |
|
939 |
|
|
|
940 |
$server->{logger}->debug("$server->{server}->{peeraddr}:$server->{account}->{id}: Summary_info: index == '$summary_type', field '$summary_map[$summary_type]->{fid}'"); |
913 |
syslog("LOG_DEBUG", "Summary_info: index == '%d', field '%s'", |
941 |
syslog("LOG_DEBUG", "Summary_info: index == '%d', field '%s'", |
914 |
$summary_type, $summary_map[$summary_type]->{fid}); |
942 |
$summary_type, $summary_map[$summary_type]->{fid}); |
915 |
|
943 |
|
Lines 917-922
sub summary_info {
Link Here
|
917 |
my $fid = $summary_map[$summary_type]->{fid}; |
945 |
my $fid = $summary_map[$summary_type]->{fid}; |
918 |
my $itemlist = &$func($patron, $start, $end); |
946 |
my $itemlist = &$func($patron, $start, $end); |
919 |
|
947 |
|
|
|
948 |
$server->{logger}->debug("$server->{server}->{peeraddr}:$server->{account}->{id}: summary_info: list = (" . join(", ", @{$itemlist}) . ")"); |
920 |
syslog("LOG_DEBUG", "summary_info: list = (%s)", join(", ", @{$itemlist})); |
949 |
syslog("LOG_DEBUG", "summary_info: list = (%s)", join(", ", @{$itemlist})); |
921 |
foreach my $i (@{$itemlist}) { |
950 |
foreach my $i (@{$itemlist}) { |
922 |
$resp .= add_field($fid, $i->{barcode}); |
951 |
$resp .= add_field($fid, $i->{barcode}); |
Lines 944-950
sub handle_patron_info {
Link Here
|
944 |
|
973 |
|
945 |
$resp = (PATRON_INFO_RESP); |
974 |
$resp = (PATRON_INFO_RESP); |
946 |
if ($patron) { |
975 |
if ($patron) { |
947 |
$resp .= patron_status_string($patron); |
976 |
$resp .= patron_status_string($patron, $server); |
948 |
$resp .= (defined($lang) and length($lang) ==3) ? $lang : $patron->language; |
977 |
$resp .= (defined($lang) and length($lang) ==3) ? $lang : $patron->language; |
949 |
$resp .= timestamp(); |
978 |
$resp .= timestamp(); |
950 |
|
979 |
|
Lines 991-997
sub handle_patron_info {
Link Here
|
991 |
# fine_items |
1020 |
# fine_items |
992 |
# recall_items |
1021 |
# recall_items |
993 |
|
1022 |
|
994 |
$resp .= summary_info($ils, $patron, $summary, $start, $end); |
1023 |
$resp .= summary_info($server, $ils, $patron, $summary, $start, $end); |
995 |
|
1024 |
|
996 |
$resp .= maybe_add(FID_HOME_ADDR, $patron->address); |
1025 |
$resp .= maybe_add(FID_HOME_ADDR, $patron->address); |
997 |
$resp .= maybe_add(FID_EMAIL, $patron->email_addr); |
1026 |
$resp .= maybe_add(FID_EMAIL, $patron->email_addr); |
Lines 1177-1182
sub handle_item_status_update {
Link Here
|
1177 |
$item_props = $fields->{(FID_ITEM_PROPS)}; |
1206 |
$item_props = $fields->{(FID_ITEM_PROPS)}; |
1178 |
|
1207 |
|
1179 |
if (!defined($item_id)) { |
1208 |
if (!defined($item_id)) { |
|
|
1209 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: handle_item_status: received message without Item ID field"); |
1180 |
syslog("LOG_WARNING", |
1210 |
syslog("LOG_WARNING", |
1181 |
"handle_item_status: received message without Item ID field"); |
1211 |
"handle_item_status: received message without Item ID field"); |
1182 |
} else { |
1212 |
} else { |
Lines 1221-1226
sub handle_patron_enable {
Link Here
|
1221 |
$patron_id = $fields->{(FID_PATRON_ID)}; |
1251 |
$patron_id = $fields->{(FID_PATRON_ID)}; |
1222 |
$patron_pwd = $fields->{(FID_PATRON_PWD)}; |
1252 |
$patron_pwd = $fields->{(FID_PATRON_PWD)}; |
1223 |
|
1253 |
|
|
|
1254 |
$server->{logger}->debug("$server->{server}->{peeraddr}:$server->{account}->{id}: handle_patron_enable: patron_id: '$patron_id', patron_pwd: '$patron_pwd'"); |
1224 |
syslog("LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", |
1255 |
syslog("LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", |
1225 |
$patron_id, $patron_pwd); |
1256 |
$patron_id, $patron_pwd); |
1226 |
|
1257 |
|
Lines 1239-1245
sub handle_patron_enable {
Link Here
|
1239 |
# Don't enable the patron if there was an invalid password |
1270 |
# Don't enable the patron if there was an invalid password |
1240 |
$status = $patron->enable; |
1271 |
$status = $patron->enable; |
1241 |
} |
1272 |
} |
1242 |
$resp .= patron_status_string($patron); |
1273 |
$resp .= patron_status_string( $patron, $server ); |
1243 |
$resp .= $patron->language . timestamp(); |
1274 |
$resp .= $patron->language . timestamp(); |
1244 |
|
1275 |
|
1245 |
$resp .= add_field(FID_PATRON_ID, $patron->id); |
1276 |
$resp .= add_field(FID_PATRON_ID, $patron->id); |
Lines 1292-1301
sub handle_hold {
Link Here
|
1292 |
$status = $ils->alter_hold($patron_id, $patron_pwd, $item_id, $title_id, |
1323 |
$status = $ils->alter_hold($patron_id, $patron_pwd, $item_id, $title_id, |
1293 |
$expiry_date, $pickup_locn, $hold_type, $fee_ack); |
1324 |
$expiry_date, $pickup_locn, $hold_type, $fee_ack); |
1294 |
} else { |
1325 |
} else { |
1295 |
syslog("LOG_WARNING", "handle_hold: Unrecognized hold mode '%s' from terminal '%s'", |
1326 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: handle_hold: Unrecognized hold mode '$hold_mode' from terminal '$server->{account}->{id}'"); |
1296 |
$hold_mode, $server->{account}->{id}); |
1327 |
syslog("LOG_WARNING", "handle_hold: Unrecognized hold mode '%s' from terminal '%s'", |
1297 |
$status = $ils->Transaction::Hold; # new? |
1328 |
$hold_mode, $server->{account}->{id}); |
1298 |
$status->screen_msg("System error. Please contact library staff."); |
1329 |
$status = $ils->Transaction::Hold; # new? |
|
|
1330 |
$status->screen_msg("System error. Please contact library staff."); |
1299 |
} |
1331 |
} |
1300 |
|
1332 |
|
1301 |
$resp .= $status->ok; |
1333 |
$resp .= $status->ok; |
Lines 1342-1350
sub handle_renew {
Link Here
|
1342 |
$ils->check_inst_id($fields->{(FID_INST_ID)}, "handle_renew"); |
1374 |
$ils->check_inst_id($fields->{(FID_INST_ID)}, "handle_renew"); |
1343 |
|
1375 |
|
1344 |
if ($no_block eq 'Y') { |
1376 |
if ($no_block eq 'Y') { |
1345 |
syslog("LOG_WARNING", |
1377 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: handle_renew: received 'no block' renewal from terminal '$server->{account}->{id}'"); |
1346 |
"handle_renew: received 'no block' renewal from terminal '%s'", |
1378 |
syslog("LOG_WARNING", |
1347 |
$server->{account}->{id}); |
1379 |
"handle_renew: received 'no block' renewal from terminal '%s'", |
|
|
1380 |
$server->{account}->{id}); |
1348 |
} |
1381 |
} |
1349 |
|
1382 |
|
1350 |
$patron_id = $fields->{(FID_PATRON_ID)}; |
1383 |
$patron_id = $fields->{(FID_PATRON_ID)}; |
Lines 1511-1525
sub send_acs_status {
Link Here
|
1511 |
$retries = sprintf("%03d", $policy->{retries}); |
1544 |
$retries = sprintf("%03d", $policy->{retries}); |
1512 |
|
1545 |
|
1513 |
if (length($timeout) != 3) { |
1546 |
if (length($timeout) != 3) { |
1514 |
syslog("LOG_ERR", "handle_acs_status: timeout field wrong size: '%s'", |
1547 |
$server->{logger}->error("$server->{server}->{peeraddr}:$server->{account}->{id}: handle_acs_status: timeout field wrong size: '$timeout'"); |
1515 |
$timeout); |
1548 |
syslog("LOG_ERR", "handle_acs_status: timeout field wrong size: '%s'", |
1516 |
$timeout = '000'; |
1549 |
$timeout); |
|
|
1550 |
$timeout = '000'; |
1517 |
} |
1551 |
} |
1518 |
|
1552 |
|
1519 |
if (length($retries) != 3) { |
1553 |
if (length($retries) != 3) { |
1520 |
syslog("LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", |
1554 |
$server->{logger}->error("$server->{server}->{peeraddr}:$server->{account}->{id}: handle_acs_status: retries field wrong size: '$retries'"); |
1521 |
$retries); |
1555 |
syslog("LOG_ERR", "handle_acs_status: retries field wrong size: '%s'", |
1522 |
$retries = '000'; |
1556 |
$retries); |
|
|
1557 |
$retries = '000'; |
1523 |
} |
1558 |
} |
1524 |
|
1559 |
|
1525 |
$msg .= "$online_status$checkin_ok$checkout_ok$ACS_renewal_policy"; |
1560 |
$msg .= "$online_status$checkin_ok$checkout_ok$ACS_renewal_policy"; |
Lines 1531-1540
sub send_acs_status {
Link Here
|
1531 |
} elsif ($protocol_version == 2) { |
1566 |
} elsif ($protocol_version == 2) { |
1532 |
$msg .= '2.00'; |
1567 |
$msg .= '2.00'; |
1533 |
} else { |
1568 |
} else { |
1534 |
syslog("LOG_ERR", |
1569 |
$server->{logger}->error("$server->{server}->{peeraddr}:$server->{account}->{id}: Bad setting for \$protocol_version, '$protocol_version' in send_acs_status"); |
1535 |
'Bad setting for $protocol_version, "%s" in send_acs_status', |
1570 |
syslog("LOG_ERR", |
1536 |
$protocol_version); |
1571 |
'Bad setting for $protocol_version, "%s" in send_acs_status', |
1537 |
$msg .= '1.00'; |
1572 |
$protocol_version); |
|
|
1573 |
$msg .= '1.00'; |
1538 |
} |
1574 |
} |
1539 |
|
1575 |
|
1540 |
# Institution ID |
1576 |
# Institution ID |
Lines 1552-1557
sub send_acs_status {
Link Here
|
1552 |
} |
1588 |
} |
1553 |
} |
1589 |
} |
1554 |
if (length($supported_msgs) < 16) { |
1590 |
if (length($supported_msgs) < 16) { |
|
|
1591 |
$server->{logger}->error("$server->{server}->{peeraddr}:$server->{account}->{id}: send_acs_status: supported messages '$supported_msgs' too short"); |
1555 |
syslog("LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs); |
1592 |
syslog("LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs); |
1556 |
} |
1593 |
} |
1557 |
$msg .= add_field(FID_SUPPORTED_MSGS, $supported_msgs); |
1594 |
$msg .= add_field(FID_SUPPORTED_MSGS, $supported_msgs); |
Lines 1561-1569
sub send_acs_status {
Link Here
|
1561 |
|
1598 |
|
1562 |
if (defined($account->{print_width}) && defined($print_line) |
1599 |
if (defined($account->{print_width}) && defined($print_line) |
1563 |
&& $account->{print_width} < length($print_line)) { |
1600 |
&& $account->{print_width} < length($print_line)) { |
1564 |
syslog("LOG_WARNING", "send_acs_status: print line '%s' too long. Truncating", |
1601 |
$server->{logger}->warn("$server->{server}->{peeraddr}:$server->{account}->{id}: send_acs_status: print line '$print_line' too long. Truncating"); |
1565 |
$print_line); |
1602 |
syslog("LOG_WARNING", "send_acs_status: print line '%s' too long. Truncating", |
1566 |
$print_line = substr($print_line, 0, $account->{print_width}); |
1603 |
$print_line); |
|
|
1604 |
$print_line = substr($print_line, 0, $account->{print_width}); |
1567 |
} |
1605 |
} |
1568 |
|
1606 |
|
1569 |
$msg .= maybe_add(FID_PRINT_LINE, $print_line); |
1607 |
$msg .= maybe_add(FID_PRINT_LINE, $print_line); |
Lines 1580-1587
sub send_acs_status {
Link Here
|
1580 |
# |
1618 |
# |
1581 |
sub patron_status_string { |
1619 |
sub patron_status_string { |
1582 |
my $patron = shift; |
1620 |
my $patron = shift; |
|
|
1621 |
my $server = shift; |
1583 |
my $patron_status; |
1622 |
my $patron_status; |
1584 |
|
1623 |
|
|
|
1624 |
$server->{logger}->debug("$server->{server}->{peeraddr}:$server->{account}->{id}: patron_status_string: $patron->id charge_ok: $patron->charge_ok"); |
1585 |
syslog("LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok); |
1625 |
syslog("LOG_DEBUG", "patron_status_string: %s charge_ok: %s", $patron->id, $patron->charge_ok); |
1586 |
$patron_status = sprintf( |
1626 |
$patron_status = sprintf( |
1587 |
'%s%s%s%s%s%s%s%s%s%s%s%s%s%s', |
1627 |
'%s%s%s%s%s%s%s%s%s%s%s%s%s%s', |