~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/cues/send-cues.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # send-cues.tcl --
  2 #
  3 #       An object for sending cues in a collaborative meeting.
  4 #
  5 # Copyright (c) 1998-2002 The Regents of the University of California.
  6 # All rights reserved.
  7 #
  8 # Redistribution and use in source and binary forms, with or without
  9 # modification, are permitted provided that the following conditions are met:
 10 #
 11 # A. Redistributions of source code must retain the above copyright notice,
 12 #    this list of conditions and the following disclaimer.
 13 # B. Redistributions in binary form must reproduce the above copyright notice,
 14 #    this list of conditions and the following disclaimer in the documentation
 15 #    and/or other materials provided with the distribution.
 16 # C. Neither the names of the copyright holders nor the names of its
 17 #    contributors may be used to endorse or promote products derived from this
 18 #    software without specific prior written permission.
 19 #
 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 23 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 
 31 #
 32 # An object for sending cues in a collaborative meeting.
 33 # The cues currently available are "raise hand", "speak
 34 # louder", "agree", and "disagree". The idea is for a
 35 # person to express these cues in a non-verbal manner.
 36 #
 37 # This class makes a gui for the cues; there is just
 38 # one format now. It is a list of checkbuttons with the
 39 # cues images next to them.
 40 #
 41 # It also sends the cues messages on the global
 42 # coordination bus. The client of this class needs to
 43 # pass in this bus object.
 44 #
 45 # See also: CuesReceiver
 46 #
 47 # Examples of usage can be found in vic.
 48 #
 49 
 50 import CheckButton
 51 
 52 Class CuesSender
 53 
 54 #
 55 # Initialize the global coordination bus so the client
 56 # can use this class. The client should use CoordBus_
 57 # and the associated CBChannel/Site object. See the
 58 # creation of buses in application-{vic,vat}.tcl for
 59 # an example
 60 #
 61 CuesSender proc set_cb { cb } {
 62         # initialize global coordination bus
 63         CuesSender set glob_chan_ $cb
 64 }
 65 
 66 #
 67 # Create a CuesSender object and the gui
 68 # path: the gui is constructed using this path, the
 69 #       client should pass in the name of a frame
 70 # cname: the cname that represents the user
 71 #
 72 CuesSender instproc init { path cname } {
 73         # initialize some variables
 74         $self instvar cname_ cues_
 75         set cname_ $cname
 76         # FIXME change so client can specify
 77         set cues_ "hand ear yes no"
 78 
 79         # create the cues buttons
 80         $self instvar top_
 81         set top_ $path
 82         foreach c $cues_ {
 83                 $self set ${c}_b_ [$self create_cue $c]
 84                 pack $top_.${c} -side left
 85         }
 86 }
 87 
 88 #
 89 # Create a cue checkbutton
 90 #
 91 CuesSender instproc create_cue { cue } {
 92         $self instvar top_
 93         set cb [new CheckButton $top_.${cue} \
 94                  -bitmap sm_${cue} -command "$self send $cue" \
 95                  -onvalue ${cue}_on -offvalue ${cue}_off \
 96                  -width 20 -height 20 -anchor w ]
 97         $cb set-val ${cue}_off
 98         return $cb
 99 }
100 
101 CuesSender instproc destroy { } {
102         $self next
103 }
104 
105 #
106 # Send cue message whenever the user click on a
107 # cue button. If the checkbutton is clicked down,
108 # send a message that says this particular cue
109 # is one, otherwise, send a message that cancels
110 # this cue.
111 #
112 # (punt): because reliable multicast is probably
113 # too heavyweight for this, we just send the
114 # three times, hoping most participants can
115 # get it.
116 #
117 CuesSender instproc send { cue } {
118         CuesSender instvar glob_chan_
119         $self instvar cname_ ${cue}_b_ ${cue}_after_ ${cue}_ids_
120 
121         # do nothing is global coordination bus does not exist
122         # or there is no cname
123         if { ![info exists glob_chan_] || "$cname_" == "" } {
124                 return
125         }
126 
127         # start sending messages
128         if { "[[$self set ${cue}_b_] get-val]" == "${cue}_on" } {
129                 # send the aware message three times
130                 set ${cue}_after_ 1
131                 for { set i 0; set t 0 } \
132                     { $i < 1 } \
133                     { incr i; incr t 500 } {
134                         set ${cue}_ids_($i) \
135                                 [after $t "$glob_chan_ send AWARE_$cue $cname_" ]
136                 }
137 
138         } else {
139                 # stop sending, if aware messages are queued up
140                 # then cancel them
141                 if [info exists ${cue}_after_] {
142                         unset ${cue}_after_
143                         foreach i [array names ${cue}_ids_] {
144                                 after cancel [set ${cue}_ids_($i)]
145                         }
146                 }
147 
148                 # send the cancel message three times
149                 for { set i 0; set t 0 } \
150                     { $i < 1 } \
151                     { incr i; incr t 500 } {
152                         after $t "$glob_chan_ send UNAWARE_$cue $cname_"
153                 }
154         }
155 }
156 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.