Index: openacs-4/packages/acs-mail/acs-mail.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/acs-mail.info,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-mail/acs-mail.info 30 Aug 2001 05:06:04 -0000 1.6 +++ openacs-4/packages/acs-mail/acs-mail.info 25 Oct 2001 23:49:20 -0000 1.7 @@ -1,5 +1,5 @@ - + ACS Mail @@ -28,6 +28,9 @@ + + + @@ -41,7 +44,10 @@ + + + Index: openacs-4/packages/acs-mail/tcl/acs-mail-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/tcl/acs-mail-init.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-mail/tcl/acs-mail-init.tcl 13 Mar 2001 22:59:26 -0000 1.1 +++ openacs-4/packages/acs-mail/tcl/acs-mail-init.tcl 25 Oct 2001 23:49:20 -0000 1.2 @@ -13,3 +13,32 @@ # Default interval is 15 minutes. ad_schedule_proc -thread t 900 acs_mail_process_queue + +ad_proc -private acs_mail_check_uuencode { } { + Check if ns_uuencode is properly encoding binary files +} { + + # expected result from ns_uuencode + set expected_result "H4sICHH01DsAA2p1bmsAS8zPKU4tKkstAgCaYWMDCQAAAA==" + + set file "[file dirname [info script]]/test-binary-file" + + # open the binary file + set fd [open $file r] + fconfigure $fd -encoding binary + set file_content [read $fd] + close $fd + + # encode it + set encoded_content [ns_uuencode $file_content] + + if { [string equal $encoded_content $expected_result] } { + nsv_set acs_mail ns_uuencode_works_p 1 + ns_log Notice "acs-mail: ns_uuencode works!!" + } else { + nsv_set acs_mail ns_uuencode_works_p 0 + ns_log Notice "acs-mail: ns_uuencode broken - will use the slow tcl version" + } +} + +acs_mail_check_uuencode Index: openacs-4/packages/acs-mail/tcl/acs-mail-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/tcl/acs-mail-procs-postgresql.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-mail/tcl/acs-mail-procs-postgresql.xql 13 Aug 2001 18:01:10 -0000 1.5 +++ openacs-4/packages/acs-mail/tcl/acs-mail-procs-postgresql.xql 25 Oct 2001 23:49:20 -0000 1.6 @@ -8,7 +8,7 @@ begin return content_item__new( - 'acs-mail message $body_id', -- new__name + 'acs-mail message $body_id'::varchar, -- new__name null, -- new__parent_id null, -- new__item_id null, -- new__locale Index: openacs-4/packages/acs-mail/tcl/acs-mail-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/tcl/acs-mail-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-mail/tcl/acs-mail-procs.tcl 2 Sep 2001 12:26:05 -0000 1.5 +++ openacs-4/packages/acs-mail/tcl/acs-mail-procs.tcl 25 Oct 2001 23:49:20 -0000 1.6 @@ -11,42 +11,56 @@ # base64 encode a string proc acs_mail_base64_encode {string} { - set i 0 - foreach char {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \ - a b c d e f g h i j k l m n o p q r s t u v w x y z \ - 0 1 2 3 4 5 6 7 8 9 + /} { - set base64_en($i) $char - incr i - } - - set result {} - set state 0 - set length 0 - foreach {c} [split $string {}] { - if { $length >= 60 } { - append result "\n" - set length 0 + if [nsv_get acs_mail ns_uuencode_works_p] { + # ns_uuencode works - use it + + # split it into chunks of 48 chars and then encode it + set length [string length $string] + for { set i 0 } { [expr $i + 48 ] < $length } { incr i 48 } { + append result "[ns_uuencode [string range $string $i [expr $i+47]]]\n" } - scan $c %c x - switch [incr state] { - 1 { append result $base64_en([expr {($x >>2) & 0x3F}]) } - 2 { append result \ - $base64_en([expr {(($old << 4) & 0x30) | (($x >> 4) & 0xF)}]) } - 3 { append result \ - $base64_en([expr {(($old << 2) & 0x3C) | (($x >> 6) & 0x3)}]) - append result $base64_en([expr {($x & 0x3F)}]) + append result [ns_uuencode [string range $string $i end]] + } else { + # ns_uuencode doesn't work - use the tcl version + + set i 0 + foreach char {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \ + a b c d e f g h i j k l m n o p q r s t u v w x y z \ + 0 1 2 3 4 5 6 7 8 9 + /} { + set base64_en($i) $char + incr i + } + + set result {} + set state 0 + set length 0 + foreach {c} [split $string {}] { + if { $length >= 60 } { + append result "\n" + set length 0 + } + scan $c %c x + switch [incr state] { + 1 { append result $base64_en([expr {($x >>2) & 0x3F}]) } + 2 { append result \ + $base64_en([expr {(($old << 4) & 0x30) | (($x >> 4) & 0xF)}]) } + 3 { append result \ + $base64_en([expr {(($old << 2) & 0x3C) | (($x >> 6) & 0x3)}]) + append result $base64_en([expr {($x & 0x3F)}]) + incr length + set state 0} + } + set old $x incr length - set state 0} } - set old $x - incr length - } - set x 0 - switch $state { - 0 { # OK } - 1 { append result $base64_en([expr {(($old << 4) & 0x30)}])== } - 2 { append result $base64_en([expr {(($old << 2) & 0x3C)}])= } - } + set x 0 + switch $state { + 0 { # OK } + 1 { append result $base64_en([expr {(($old << 4) & 0x30)}])== } + 2 { append result $base64_en([expr {(($old << 2) & 0x3C)}])= } + } + } + return $result } Index: openacs-4/packages/acs-mail/tcl/test-binary-file =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail/tcl/test-binary-file,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-mail/tcl/test-binary-file 25 Oct 2001 23:49:20 -0000 1.1 @@ -0,0 +1 @@ +�q��;junkK��)N-*K-�ac \ No newline at end of file