Index: openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl,v diff -u -r1.49.2.3 -r1.49.2.4 --- openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl 30 Dec 2015 18:09:14 -0000 1.49.2.3 +++ openacs-4/packages/xotcl-core/tcl/bgdelivery-procs.tcl 1 Nov 2016 18:54:06 -0000 1.49.2.4 @@ -323,9 +323,12 @@ } Subscriber instproc send {msg} { + #ns_log notice "SEND <$msg> [my mode]" my log "" if {[my mode] eq "scripted"} { - set smsg "\n" set smsg [format %x [string length $smsg]]\r\n$smsg\r\n } else { @@ -376,17 +379,17 @@ fconfigure [my channel] -translation binary if {[my mode] eq "scripted"} { - set content_type text/html + set content_type "text/html;chartype=utf-8" set encoding "Cache-Control: no-cache\r\nTransfer-Encoding: chunked\r\n" set body "
[string repeat { } 1024]\r\n" set body [format %x [string length $body]]\r\n$body\r\n } else { - #set content_type text/plain # Chrome refuses to expose partial response to ajax unless we - # set content_type to octet stream. Drawback is we now need to - # treat special characters on the client side. + # set content_type to octet stream. Drawback is we have to + # force the translation on the channel. set content_type "application/octet-stream" set encoding "" + fconfigure [my channel] -encoding utf-8 set body "" } Index: openacs-4/packages/xotcl-core/tcl/chat-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/Attic/chat-procs.tcl,v diff -u -r1.23.2.3 -r1.23.2.4 --- openacs-4/packages/xotcl-core/tcl/chat-procs.tcl 28 Oct 2016 18:57:36 -0000 1.23.2.3 +++ openacs-4/packages/xotcl-core/tcl/chat-procs.tcl 1 Nov 2016 18:54:06 -0000 1.23.2.4 @@ -14,7 +14,7 @@ user_id session_id {mode default} - {encoder urlencode} + {encoder noencode} {timewindow 600} {sweepinterval 599} {login_messages_p t} @@ -70,13 +70,6 @@ my instvar array now set user_id [expr {[info exists uid] ? $uid : [my set user_id]}] set color [my user_color $user_id] - # apisano: the vanilla chat you can include in a xowiki::Object - # page is not able to deliver messages like '%'. Usage by the chat - # package is fine, but probably something should be done to have a - # consistent quoting of special chars. This commented line is not - # ok, because would corrupt some chars in the chat package, which - # is our main usage. - # set msg [my encode $msg] set msg [ns_quotehtml $msg] # my log "-- msg=$msg" @@ -127,6 +120,9 @@ foreach {key value} [nsv_array get $array] { lassign $value timestamp secs user msg color if {$timestamp > $last} { + # + # add the message to the ordered composite. + # my add [Message new -time $secs -user_id $user -msg $msg -color $color] } else { my check_age $key [expr {($now - $timestamp) / 1000}] @@ -264,7 +260,7 @@ Chat instproc noencode {string} {set string} Chat instproc encode {string} {my [my encoder] $string} Chat instproc json_encode {string} { - string map [list \n \\n {"} {\"} ' {\'}] $string" + string map [list \n \\n \" \\\" ' {\'}] $string } Chat instproc json_encode_msg {msg} { @@ -278,91 +274,91 @@ return [subst -nocommands {{'messages': [ {'user':'$userlink', 'time': '$timeshort', 'msg':'$text'} ]\n} - }] - } + }] + } - Chat instproc js_encode_msg {msg} { - set json [my json_encode_msg $msg] - return "\n" - } + } - Chat instproc broadcast_msg {msg} { - my log "--chat broadcast_msg $msg" - ::xo::clusterwide \ - bgdelivery send_to_subscriber chat-[my chat_id] [my json_encode_msg $msg] - } + Chat instproc broadcast_msg {msg} { + my log "--chat broadcast_msg" + ::xo::clusterwide \ + bgdelivery send_to_subscriber chat-[my chat_id] [my json_encode_msg $msg] + } - Chat instproc subscribe {-uid} { - set user_id [expr {[info exists uid] ? $uid : [my set user_id]}] - set color [my user_color $user_id] - bgdelivery subscribe chat-[my chat_id] "" [my mode] - if {[my set login_messages_p] && ![my user_active $user_id]} { - # my broadcast_msg [Message new -volatile -time [clock seconds] \ - # -user_id $user_id -color $color \ - # -msg [_ xotcl-core.has_entered_the_room] ] - } - #my get_all - } + Chat instproc subscribe {-uid} { + set user_id [expr {[info exists uid] ? $uid : [my set user_id]}] + set color [my user_color $user_id] + bgdelivery subscribe chat-[my chat_id] "" [my mode] + if {[my set login_messages_p] && ![my user_active $user_id]} { + my broadcast_msg [Message new -volatile -time [clock seconds] \ + -user_id $user_id -color $color \ + -msg [_ xotcl-core.has_entered_the_room] ] + } + #my get_all + } - Chat instproc render {} { - my orderby time - set result " " + return $result + } - ############################################################################ - # Chat meta class, since we need to define general class-specific methods - ############################################################################ - Class create ChatClass -superclass ::xotcl::Class - ChatClass method sweep_all_chats {} { - my log "-- starting" - foreach nsv [nsv_names "[self]-*-seen"] { - if { [regexp "[self]-(\[0-9\]+)-seen" $nsv _ chat_id] } { - my log "--Chat_id $chat_id" - my new -volatile -chat_id $chat_id -user_id 0 -session_id 0 -init -sweeper - } - } - my log "-- ending" - } + ############################################################################ + # Chat meta class, since we need to define general class-specific methods + ############################################################################ + Class create ChatClass -superclass ::xotcl::Class + ChatClass method sweep_all_chats {} { + my log "-- starting" + foreach nsv [nsv_names "[self]-*-seen"] { + if { [regexp "[self]-(\[0-9\]+)-seen" $nsv _ chat_id] } { + my log "--Chat_id $chat_id" + my new -volatile -chat_id $chat_id -user_id 0 -session_id 0 -init -sweeper + } + } + my log "-- ending" + } - ChatClass method initialize_nsvs {} { - # read the last_activity information at server start into a nsv array - ::xo::dc foreach get_rooms { - select room_id, to_char(max(creation_date),'HH24:MI:SS YYYY-MM-DD') as last_activity - from chat_msgs group by room_id - } { - ::xo::clusterwide nsv_set [self]-$room_id-seen last [clock scan $last_activity] - } - } + ChatClass method initialize_nsvs {} { + # read the last_activity information at server start into a nsv array + ::xo::dc foreach get_rooms { + select room_id, to_char(max(creation_date),'HH24:MI:SS YYYY-MM-DD') as last_activity + from chat_msgs group by room_id + } { + ::xo::clusterwide nsv_set [self]-$room_id-seen last [clock scan $last_activity] + } + } - ChatClass method flush_messages {-chat_id:required} { - set array "[self]-$chat_id" - ::xo::clusterwide nsv_unset -nocomplain $array - ::xo::clusterwide nsv_unset -nocomplain $array-seen - ::xo::clusterwide nsv_unset -nocomplain $array-last-activity - } + ChatClass method flush_messages {-chat_id:required} { + set array "[self]-$chat_id" + ::xo::clusterwide nsv_unset -nocomplain $array + ::xo::clusterwide nsv_unset -nocomplain $array-seen + ::xo::clusterwide nsv_unset -nocomplain $array-last-activity + } - ChatClass method init {} { - # default setting is set19 from http://www.graphviz.org/doc/info/colors.html - # per parameter settings in the chat package are available (param UserColors) - my set colors [list #1b9e77 #d95f02 #7570b3 #e7298a #66a61e #e6ab02 #a6761d #666666] - } + ChatClass method init {} { + # default setting is set19 from http://www.graphviz.org/doc/info/colors.html + # per parameter settings in the chat package are available (param UserColors) + my set colors [list #1b9e77 #d95f02 #7570b3 #e7298a #66a61e #e6ab02 #a6761d #666666] + } } # Index: openacs-4/packages/xowiki/tcl/chat-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/chat-procs.tcl,v diff -u -r1.19 -r1.19.2.1 --- openacs-4/packages/xowiki/tcl/chat-procs.tcl 16 Jun 2015 19:49:20 -0000 1.19 +++ openacs-4/packages/xowiki/tcl/chat-procs.tcl 1 Nov 2016 18:54:06 -0000 1.19.2.1 @@ -119,7 +119,7 @@ error "mode $mode unknown, valid are: polling, streaming and scripted-streaming" } } - set send_url ${path}ajax/chat?m=add_msg&$context&msg= + set send_url ${path}ajax/chat?m=add_msg&$context&msg= if { ![file exists [acs_root_dir]/$jspath] } { return -code error "File [acs_root_dir]/$jspath does not exist" @@ -140,6 +140,8 @@ overflow:auto; } + template::add_body_script -script [subst {document.getElementById('chatMsg').focus();}] + switch $mode { polling {return "\ -