print notice that member returned all books
[koha_fer] / C4 / SIP / Sip.pm
index 8807df6..b6f1916 100644 (file)
@@ -6,10 +6,8 @@ package Sip;
 
 use strict;
 use warnings;
-use English;
 use Exporter;
-use Readonly;
-
+use Encode;
 use Sys::Syslog qw(syslog);
 use POSIX qw(strftime);
 use Socket qw(:crlf);
@@ -40,15 +38,6 @@ BEGIN {
 our $error_detection = 0;
 our $protocol_version = 1;
 our $field_delimiter = '|'; # Protocol Default
-# The message terminator for a SIP message is '\r' in the standard doc
-# However most sip devices in the wild send a CR LF pair
-# This is required by Telnet if that is your carrier mechanism
-# On raw connections it may also be required because the buffer is
-# only flushed on linefeed and its absence causes enough delay for
-# client machines to go into an error state
-# The below works for almost all machines if however you have one
-# which does not like the additional linefeed change value to $CR
-Readonly my $msg_terminator => $CRLF;
 
 # We need to keep a copy of the last message we sent to the SC,
 # in case there's a transmission error and the SC sends us a
@@ -220,7 +209,13 @@ sub read_SIP_packet {
 #
 
 sub write_msg {
-    my ($self, $msg, $file) = @_;
+    my ($self, $msg, $file, $terminator, $encoding) = @_;
+
+    $terminator ||= q{};
+    $terminator = ( $terminator eq 'CR' ) ? $CR : $CRLF;
+
+    $msg = encode($encoding, $msg) if ( $encoding );
+
     my $cksum;
 
     # $msg = encode_utf8($msg);
@@ -236,10 +231,10 @@ sub write_msg {
 
     if ($file) {
         $file->autoflush(1);
-        print $file $msg, $msg_terminator;
+        print $file $msg, $terminator;
     } else {
         STDOUT->autoflush(1);
-        print $msg, $msg_terminator;
+        print $msg, $terminator;
         syslog("LOG_INFO", "OUTPUT MSG: '$msg'");
     }