View | Details | Raw Unified | Return to bug 9865
Collapse All | Expand All

(-)a/C4/SIP/Sip.pm (-2 / +8 lines)
Lines 7-12 package Sip; Link Here
7
use strict;
7
use strict;
8
use warnings;
8
use warnings;
9
use Exporter;
9
use Exporter;
10
use Encode;
10
11
11
use Sys::Syslog qw(syslog);
12
use Sys::Syslog qw(syslog);
12
use POSIX qw(strftime);
13
use POSIX qw(strftime);
Lines 209-222 sub read_SIP_packet { Link Here
209
#
210
#
210
211
211
sub write_msg {
212
sub write_msg {
212
    my ($self, $msg, $file, $terminator) = @_;
213
    my ($self, $msg, $file, $terminator, $encoding) = @_;
213
    
214
    
214
    $terminator ||= q{};    
215
    $terminator ||= q{};    
215
    $terminator = ( $terminator eq 'CR' ) ? $CR : $CRLF;
216
    $terminator = ( $terminator eq 'CR' ) ? $CR : $CRLF;
216
217
218
    $encoding ||= q{};
219
217
    my $cksum;
220
    my $cksum;
218
221
219
    # $msg = encode_utf8($msg);
222
    if ($encoding ne '') {
223
        $msg = encode($encoding, $msg);
224
    }
225
220
    if ($error_detection) {
226
    if ($error_detection) {
221
        if (defined($self->{seqno})) {
227
        if (defined($self->{seqno})) {
222
            $msg .= 'AY' . $self->{seqno};
228
            $msg .= 'AY' . $self->{seqno};
(-)a/C4/SIP/Sip/MsgType.pm (-17 / +17 lines)
Lines 486-492 sub handle_patron_status { Link Here
486
    $ils->check_inst_id($fields->{(FID_INST_ID)}, "handle_patron_status");
486
    $ils->check_inst_id($fields->{(FID_INST_ID)}, "handle_patron_status");
487
    $patron = $ils->find_patron($fields->{(FID_PATRON_ID)});
487
    $patron = $ils->find_patron($fields->{(FID_PATRON_ID)});
488
    $resp = build_patron_status($patron, $lang, $fields);
488
    $resp = build_patron_status($patron, $lang, $fields);
489
    $self->write_msg($resp,undef,$server->{account}->{terminator});
489
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
490
    return (PATRON_STATUS_REQ);
490
    return (PATRON_STATUS_REQ);
491
}
491
}
492
492
Lines 604-610 sub handle_checkout { Link Here
604
	}
604
	}
605
    }
605
    }
606
606
607
    $self->write_msg($resp,undef,$server->{account}->{terminator});
607
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
608
    return(CHECKOUT);
608
    return(CHECKOUT);
609
}
609
}
610
610
Lines 692-698 sub handle_checkin { Link Here
692
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
692
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
693
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
693
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
694
694
695
    $self->write_msg($resp,undef,$server->{account}->{terminator});
695
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
696
696
697
    return(CHECKIN);
697
    return(CHECKIN);
698
}
698
}
Lines 736-742 sub handle_block_patron { Link Here
736
	}
736
	}
737
737
738
    $resp = build_patron_status($patron, $patron->language, $fields);
738
    $resp = build_patron_status($patron, $patron->language, $fields);
739
    $self->write_msg($resp,undef,$server->{account}->{terminator});
739
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
740
    return(BLOCK_PATRON);
740
    return(BLOCK_PATRON);
741
}
741
}
742
742
Lines 778-784 sub handle_request_acs_resend { Link Here
778
    if (!$last_response) {
778
    if (!$last_response) {
779
	# We haven't sent anything yet, so respond with a
779
	# We haven't sent anything yet, so respond with a
780
	# REQUEST_SC_RESEND msg (p. 16)
780
	# REQUEST_SC_RESEND msg (p. 16)
781
	$self->write_msg(REQUEST_SC_RESEND,undef,$server->{account}->{terminator});
781
	$self->write_msg(REQUEST_SC_RESEND,undef,$server->{account}->{terminator},$server->{account}->{encoding});
782
    } elsif ((length($last_response) < 9)
782
    } elsif ((length($last_response) < 9)
783
	     || substr($last_response, -9, 2) ne 'AY') {
783
	     || substr($last_response, -9, 2) ne 'AY') {
784
	# When resending a message, we aren't supposed to include
784
	# When resending a message, we aren't supposed to include
Lines 790-796 sub handle_request_acs_resend { Link Here
790
	# Cut out the sequence number and checksum, since the old
790
	# Cut out the sequence number and checksum, since the old
791
	# checksum is wrong for the resent message.
791
	# checksum is wrong for the resent message.
792
	my $rebuilt = substr($last_response, 0, -9);
792
	my $rebuilt = substr($last_response, 0, -9);
793
	$self->write_msg($rebuilt,undef,$server->{account}->{terminator});
793
	$self->write_msg($rebuilt,undef,$server->{account}->{terminator},$server->{account}->{encoding});
794
    }
794
    }
795
795
796
    return REQUEST_ACS_RESEND;
796
    return REQUEST_ACS_RESEND;
Lines 866-872 sub handle_login { Link Here
866
    }
866
    }
867
	else { $status = login_core($server,$uid,$pwd); }
867
	else { $status = login_core($server,$uid,$pwd); }
868
868
869
	$self->write_msg(LOGIN_RESP . $status,undef,$server->{account}->{terminator});
869
	$self->write_msg(LOGIN_RESP . $status,undef,$server->{account}->{terminator},$server->{account}->{encoding});
870
    return $status ? LOGIN : '';
870
    return $status ? LOGIN : '';
871
}
871
}
872
872
Lines 1012-1018 sub handle_patron_info { Link Here
1012
        }
1012
        }
1013
    }
1013
    }
1014
1014
1015
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1015
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1016
    return(PATRON_INFO);
1016
    return(PATRON_INFO);
1017
}
1017
}
1018
1018
Lines 1039-1045 sub handle_end_patron_session { Link Here
1039
    $resp .= maybe_add(FID_SCREEN_MSG, $screen_msg);
1039
    $resp .= maybe_add(FID_SCREEN_MSG, $screen_msg);
1040
    $resp .= maybe_add(FID_PRINT_LINE, $print_line);
1040
    $resp .= maybe_add(FID_PRINT_LINE, $print_line);
1041
1041
1042
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1042
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1043
1043
1044
    return(END_PATRON_SESSION);
1044
    return(END_PATRON_SESSION);
1045
}
1045
}
Lines 1073-1079 sub handle_fee_paid { Link Here
1073
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1073
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1074
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1074
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1075
1075
1076
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1076
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1077
1077
1078
    return(FEE_PAID);
1078
    return(FEE_PAID);
1079
}
1079
}
Lines 1140-1146 sub handle_item_information { Link Here
1140
	$resp .= maybe_add(FID_PRINT_LINE, $item->print_line);
1140
	$resp .= maybe_add(FID_PRINT_LINE, $item->print_line);
1141
    }
1141
    }
1142
1142
1143
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1143
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1144
1144
1145
    return(ITEM_INFORMATION);
1145
    return(ITEM_INFORMATION);
1146
}
1146
}
Lines 1189-1195 sub handle_item_status_update { Link Here
1189
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1189
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1190
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1190
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1191
1191
1192
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1192
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1193
1193
1194
    return(ITEM_STATUS_UPDATE);
1194
    return(ITEM_STATUS_UPDATE);
1195
}
1195
}
Lines 1240-1246 sub handle_patron_enable { Link Here
1240
1240
1241
    $resp .= add_field(FID_INST_ID, $ils->institution);
1241
    $resp .= add_field(FID_INST_ID, $ils->institution);
1242
1242
1243
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1243
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1244
1244
1245
    return(PATRON_ENABLE);
1245
    return(PATRON_ENABLE);
1246
}
1246
}
Lines 1306-1312 sub handle_hold { Link Here
1306
    $resp .= maybe_add(FID_SCREEN_MSG,  $status->screen_msg);
1306
    $resp .= maybe_add(FID_SCREEN_MSG,  $status->screen_msg);
1307
    $resp .= maybe_add(FID_PRINT_LINE,  $status->print_line);
1307
    $resp .= maybe_add(FID_PRINT_LINE,  $status->print_line);
1308
1308
1309
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1309
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1310
1310
1311
    return(HOLD);
1311
    return(HOLD);
1312
}
1312
}
Lines 1395-1401 sub handle_renew { Link Here
1395
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1395
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1396
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1396
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1397
1397
1398
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1398
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1399
1399
1400
    return(RENEW);
1400
    return(RENEW);
1401
}
1401
}
Lines 1445-1451 sub handle_renew_all { Link Here
1445
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1445
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg);
1446
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1446
    $resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
1447
1447
1448
    $self->write_msg($resp,undef,$server->{account}->{terminator});
1448
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1449
1449
1450
    return(RENEW_ALL);
1450
    return(RENEW_ALL);
1451
}
1451
}
Lines 1555-1561 sub send_acs_status { Link Here
1555
1555
1556
    # Do we want to tell the terminal its location?
1556
    # Do we want to tell the terminal its location?
1557
1557
1558
    $self->write_msg($msg,undef,$server->{account}->{terminator});
1558
    $self->write_msg($msg,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1559
    return 1;
1559
    return 1;
1560
}
1560
}
1561
1561
(-)a/etc/SIPconfig.xml (-3 / +2 lines)
Lines 36-43 Link Here
36
  </listeners>
36
  </listeners>
37
37
38
  <accounts>
38
  <accounts>
39
      <login id="term1"  password="term1" delimiter="|" error-detect="enabled" institution="CPL" />
39
      <login id="term1"  password="term1" delimiter="|" error-detect="enabled" institution="CPL" encoding="" />
40
      <login id="koha"   password="koha"  delimiter="|" error-detect="enabled" institution="kohalibrary" />
40
      <login id="koha"   password="koha"  delimiter="|" error-detect="enabled" institution="kohalibrary" encoding="" />
41
      <login id="koha2"  password="koha" institution="kohalibrary2" terminator="CR" />
41
      <login id="koha2"  password="koha" institution="kohalibrary2" terminator="CR" />
42
      <login id="lpl-sc" password="1234" institution="LPL" />
42
      <login id="lpl-sc" password="1234" institution="LPL" />
43
      <login id="lpl-sc-beacock" password="xyzzy"
43
      <login id="lpl-sc-beacock" password="xyzzy"
44
- 

Return to bug 9865