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

Open Mash Cross Reference
mash/tcl/applications/collaborator/ui-ctrlmenu.tcl

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

  1 # ui-ctrlmenu.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  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 #  @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/applications/collaborator/ui-ctrlmenu.tcl,v 1.10 2002/02/03 04:21:46 lim Exp $
 32 
 33 
 34 import ControlMenu AudioControlMenu UIBook TopLevelWindow
 35 
 36 
 37 Class ControlMenu/Video -superclass ControlMenu
 38 Class ControlMenu/Audio -superclass AudioControlMenu
 39 Class ControlMenu/Mb
 40 Class ControlMenu/Mbv2
 41 Class MultiControlMenu -superclass TopLevelWindow
 42 
 43 
 44 ControlMenu/Video public init {mcm agent vpipe vframe observer} {
 45         $self set mcm_ $mcm
 46         $self next $observer $agent $vpipe $vframe $observer ""
 47 }
 48 
 49 
 50 ControlMenu/Video public build { w } {
 51         $self instvar path_
 52         set path_ $w
 53         frame $w -class VideoControlMenu
 54 
 55         frame $w.cb
 56         $self build.xmit $w.cb
 57         if { [$self yesno useScuba] && \
 58                         [$self get_option megaVideoSession] != ""} {
 59                 frame $w.scuba
 60                 $self build.scuba $w.scuba
 61         }
 62         frame $w.encoder
 63         $self build.encoder $w.encoder
 64         frame $w.decoder
 65         $self build.decoder $w.decoder
 66 
 67         pack $w.cb -padx 6 -fill x -expand 1
 68         if { [$self yesno useScuba] && \
 69                         [$self get_option megaVideoSession] != "" } {
 70                 pack $w.scuba -padx 6 -fill x -expand 1
 71         }
 72         pack $w.encoder $w.decoder -padx 6 -fill x -expand 1
 73 
 74         if [$self have_transmit_permission] {
 75                 $self selectInitialDevice
 76         }
 77 }
 78 
 79 
 80 ControlMenu/Video private build.tile w {
 81 }
 82 
 83 
 84 ControlMenu/Video public new_hostspec {} {
 85         $self instvar videoAgent_ namespec_ mcm_
 86         $mcm_ update_session_info video [$mcm_ get_rtp_info $videoAgent_]
 87 
 88         # use this to enable the transmit button if there is a device
 89         # to select
 90         if [$self have_transmit_permission] {
 91                 $self selectInitialDevice
 92         }
 93 }
 94 
 95 
 96 ControlMenu/Audio instproc init { mcm agent ui panel } {
 97         $self set mcm_ $mcm
 98         $self next $agent $ui $panel
 99 }
100 
101 
102 ControlMenu/Audio instproc build w {
103         frame $w -class AudioControlMenu
104 
105         bind $w <Enter> "focus $w"
106         frame $w.tp
107         frame $w.tp.tests
108         frame $w.tp.pri
109         frame $w.omode
110         #FIXMEframe $w.agc
111         frame $w.net
112 
113         $self mk.tests $w.tp.tests
114         $self mk.pri $w.tp.pri
115         $self mk.omode $w.omode
116         #FIXME NOT YET mk.agc $w.agc
117         $self mk.net $w.net
118         frame $w.pad -borderwidth 0 -height 6
119 
120         pack $w.tp.tests -side left -expand 1 -fill both -padx 2
121         pack $w.tp.pri -side left -expand 1 -fill x -padx 2
122         #FIXME pack $w.tp $w.omode $w.agc $w.net -expand 1 -fill x
123         pack $w.tp $w.omode $w.net -expand 1 -fill x
124         pack $w.tp -padx 4
125         pack $w.omode -padx 6
126 }
127 
128 
129 
130 #
131 ControlMenu/Audio private mk.net { w } {
132         label $w.label -text "Network" -font [$self get_option ctrlTitleFont]
133         frame $w.frame -borderwidth 0
134         $self mk.me $w.frame
135 
136         pack $w.label $w.frame -expand 1 -fill x
137         pack $w.frame -padx 6
138 }
139 
140 
141 ControlMenu/Audio public new_hostspec {} {
142         $self instvar agent_ mcm_
143         $mcm_ update_session_info audio [$mcm_ get_rtp_info $agent_]
144 }
145 
146 
147 ControlMenu/Mb public init {mcm ui} {
148         $self set mcm_ $mcm
149         $self set ui_  $ui
150         $self next
151 }
152 
153 
154 ControlMenu/Mb public new_hostspec { } {
155         $self instvar ui_ mcm_
156 
157         set agent [$ui_ get_local_option mbAgent]
158         if { $agent == {} } {
159                 set dst none
160                 set port none
161                 set ttl none
162                 set srcid none
163         } else {
164                 #set dst [[$session data-net] addr]
165                 #set port [[$session data-net] sport]
166                 #set ttl [[$session data-net] ttl]
167                 set dst  [$agent session-addr]
168                 set port [$agent session-port]
169                 set ttl  [$agent session-ttl]
170 
171                 if { [$agent network] != "none" } {
172                         set sid [[$ui_ get_local_option mbMgr] local_srcid]
173                         set sid [split $sid _]
174                         # convert the address to x.x.x.x format
175                         set addr [expr 0x[lindex $sid 0]]
176                         set addr [binary format I $addr]
177                         binary scan $addr cccc a1 a2 a3 a4
178                         foreach a {a1 a2 a3 a4} {
179                                 # convert from signed to unsigned
180                                 set val [set $a]
181                                 set val [expr ($val + 0x100) % 0x100]
182                                 set $a $val
183                         }
184                         set srcid "[expr 0x[lindex $sid 1]]@$a4.$a3.$a2.$a1"
185                 } else { set srcid none }
186         }
187 
188         $mcm_ update_session_info mb \
189                         "Destination: $dst\nPort: $port\nTTL: $ttl\nID: $srcid"
190 }
191 
192 
193 ControlMenu/Mbv2 public init {mcm ui} {
194         $self set mcm_ $mcm
195         $self set ui_  $ui
196         $self next
197 }
198 
199 
200 ControlMenu/Mbv2 public new_hostspec { } {
201         $self instvar ui_ mcm_
202 
203         set session [$ui_ get_local_option mbv2Session]
204         if { $session == {} } {
205                 set dst none
206                 set port none
207                 set ttl none
208                 set srcid none
209         } else {
210                 set ab [new AddressBlock [$session spec]]
211                 set dst [$ab addr]
212                 set port  [$ab sport]
213                 set rport [$ab rport]
214                 if { $port != $rport } { append port :$rport }
215                 set ttl [$ab ttl]
216                 if { $ttl == {} } { set ttl 15 }
217                 delete $ab
218 
219                 set srcid [[$session sender] source_id]
220         }
221 
222         $mcm_ update_session_info mbv2 \
223                         "Destination: $dst\nPort: $port\nTTL: $ttl\nID: $srcid"
224 }
225 
226 
227 MultiControlMenu public init { path ui } {
228         $self next $path
229         $self instvar ui_ path_
230         set ui_ $ui
231         set path_ $path
232         $self create-window $path "Collaborator Control Menu"
233         $self build_widget $path.book
234 
235         pack $path.book -fill both -expand 1 -padx 5 -pady 5
236         button $path.dismiss -text "Dismiss" -bd 1 -command "$self toggle"
237         pack $path.dismiss -anchor se -padx 5 -pady 1
238 }
239 
240 
241 MultiControlMenu private build_widget { path } {
242         $self instvar ui_ book_
243         UIBook $path -geometry 300x400 -usepack 1
244         set book_ $path
245         $self add_general_page
246         #if [$ui_ get_local_option have_video] {
247         #       $self add_video_page $path
248         #}
249         #if [$ui_ get_local_option have_audio] {
250         #       $self add_audio_page $path
251         #}
252         #if [$ui_ get_local_option have_mb] {
253         #       $self add_mb_page $path
254         #}
255 }
256 
257 
258 MultiControlMenu private add_general_page { } {
259         $self instvar book_
260         ScrolledWindow $book_.general -scrollbar both
261         $self build.general [$book_.general subwidget window]
262         $book_ add $book_.general text {-text General}
263         $book_ configure -toppage $book_.general
264 }
265 
266 
267 MultiControlMenu private build.session_line { w label } {
268         frame $w
269         label $w.label -text $label
270         pack $w.label -side left -anchor nw
271         frame $w.info
272         label $w.info.info -text "" -anchor w -justify left -font \
273                         [WidgetClass widget_default -font] \
274                         -wraplength 250
275         pack $w.info.info -fill both -expand 1 -anchor w -side bottom
276         pack $w.info -side left -fill both -expand 1 -anchor w
277         pack $w -fill x
278 
279         return $w.info
280 }
281 
282 
283 MultiControlMenu public get_rtp_info { agent } {
284         set dst [$agent session-addr]
285         set sport [$agent session-sport]
286         set rport [$agent session-rport]
287         if { $sport != $rport } { set port $sport:$rport } \
288                         else { set port $sport }
289         set ttl [$agent session-ttl]
290         set srcid [$agent get_local_srcid]
291 
292         return "Destination: $dst\nPort: $port\nTTL: $ttl\nID: $srcid"
293 }
294 
295 
296 MultiControlMenu public update_session_info { media info } {
297         $self instvar book_
298         [$book_.general subwidget window].sessions.$media.info.info \
299                         configure -text $info
300 }
301 
302 
303 # use this to notify the control menu of the original spec
304 # in case we are using MeGa
305 MultiControlMenu public original_session_spec { media spec } {
306         $self instvar book_
307         set orig [$book_.general subwidget window].sessions.$media.info.orig
308         if ![winfo exists $orig] {
309                 label $orig -text "" -anchor w -justify left -font \
310                                 [WidgetClass widget_default -font]
311                 pack $orig -fill x -anchor w -side top
312         }
313 
314         $orig configure -text "Original spec: $spec"
315 }
316 
317 
318 MultiControlMenu private crypt_clear { } {
319         $self instvar ui_
320         foreach option {videoAgent audioAgent mbAgent} {
321                 set a [$ui_ get_local_option $option]
322                 if { $a != {} } { $a crypt_clear }
323         }
324 }
325 
326 
327 MultiControlMenu private install-key { key } {
328         $self instvar ui_
329         foreach option {videoAgent audioAgent mbAgent} {
330                 set a [$ui_ get_local_option $option]
331                 if { $a != {} } { $a install-key $key }
332         }
333 }
334 
335 
336 MultiControlMenu private build.general { w } {
337         $self instvar ui_
338         set f [$self get_option smallfont]
339 
340         label $w.slabel -text Sessions -anchor w
341         pack $w.slabel -fill x
342 
343         frame $w.sessions -relief sunken -borderwidth 1
344         pack $w.sessions -fill x
345 
346         if [$ui_ get_local_option have_rover] {
347                 $self set addrspec_(rover) [$self build.session_line \
348                                 $w.sessions.mars Mars:]
349         }
350         set sdp [$ui_ get_local_option sdp]
351         if { $sdp != {} } {
352                 $self set addrspec_(sdp) [$self build.session_line \
353                                 $w.sessions.sdp Info:]
354                 array set asdp $sdp
355                 $self update_session_info sdp \
356                                 "$asdp(session_name)\
357                                 \n$asdp(session_info)\n\
358                                 \nCreator: $asdp(creator)\
359                                 \nURL: $asdp(url)"
360         }
361         if [$ui_ get_local_option have_video] {
362                 $self set addrspec_(video) [$self build.session_line \
363                                 $w.sessions.video Video:]
364         }
365         if [$ui_ get_local_option have_audio] {
366                 $self set addrspec_(audio) [$self build.session_line \
367                                 $w.sessions.audio Audio:]
368         }
369         if [$ui_ get_local_option have_mb] {
370                 $self set addrspec_(mb) [$self build.session_line \
371                                 $w.sessions.mb MediaBoard:]
372         }
373         if [$ui_ get_local_option have_mbv2] {
374                 $self set addrspec_(mbv2) [$self build.session_line \
375                                 $w.sessions.mbv2 "MediaBoard v2:"]
376         }
377 
378         label $w.nlabel -text "" -anchor w
379         pack $w.nlabel -fill x
380 
381         frame $w.stuff -relief sunken -borderwidth 1
382         pack $w.stuff -fill x
383         set name [$self get_option rtpName]
384         frame $w.stuff.name
385         label $w.stuff.name.label -text "Name: " -font $f -anchor e -width 6
386 
387         new TextEntry "$self update_name" $w.stuff.name.entry $name
388 
389         pack $w.stuff.name.label -side left
390         pack $w.stuff.name.entry -side left -expand 1 -fill x -pady 2
391         $self set namespec_ $w.stuff.name
392 
393         frame $w.stuff.msg
394         label $w.stuff.msg.label -text "Note: " -font $f -anchor e -width 6
395         new TextEntry "$self update_note" $w.stuff.msg.entry ""
396         pack $w.stuff.msg.label -side left
397         pack $w.stuff.msg.entry -side left -expand 1 -fill x -pady 2
398 
399         #
400         # Create the entry widget for editing the session's
401         # encryption key.  The audio agent exports methods
402         # (invoked by the KeyEditor) to enable/disable encryption.
403         #
404         new KeyEditor $w.stuff $self
405 
406         pack $w.stuff.name $w.stuff.msg $w.stuff.key \
407                         -fill x -padx 2 -expand 1
408 }
409 
410 
411 MultiControlMenu public add_video_page { } {
412         $self instvar ui_ book_
413         set o [$ui_ get_local_option observer,video]
414         set agent [$ui_ get_local_option videoAgent]
415         set vpipe [$ui_ get_local_option videoPipe]
416         set vframe [$ui_ get_local_option visualFrame]
417         set cm [new ControlMenu/Video $self $agent $vpipe $vframe $o]
418         $ui_ set_local_option controlmenu,video $cm
419 
420         ScrolledWindow $book_.video -scrollbar both
421         set w [$book_.video subwidget window].ctrlmenu
422         $cm build $w
423         pack $w -fill both -expand 1
424         $book_ add $book_.video text {-text Video}
425         $cm new_hostspec
426         return $cm
427 }
428 
429 
430 MultiControlMenu public add_audio_page { } {
431         $self instvar ui_ book_
432 
433         set agent [$ui_ get_local_option audioAgent]
434         set panel [$ui_ get_local_option audioPanel]
435         set cm [new ControlMenu/Audio $self $agent $ui_ $panel]
436         $ui_ set_local_option controlmenu,audio $cm
437 
438         ScrolledWindow $book_.audio -scrollbar both
439         set w [$book_.audio subwidget window].ctrlmenu
440         $cm build $w
441         pack $w -fill both -expand 1
442         $book_ add $book_.audio text {-text Audio}
443         $cm new_hostspec
444         return $cm
445 }
446 
447 
448 MultiControlMenu private add_mb_page { } {
449         $self instvar ui_
450         set cm [new ControlMenu/Mb $self $ui_]
451         $ui_ set_local_option controlmenu,mb $cm
452 }
453 
454 
455 MultiControlMenu private add_mbv2_page { } {
456         $self instvar ui_
457         set cm [new ControlMenu/Mbv2 $self $ui_]
458         $ui_ set_local_option controlmenu,mbv2 $cm
459 }
460 
461 
462 MultiControlMenu private update_name { name } {
463         $self instvar ui_
464         if { $name != ""} {
465                 foreach option {videoAgent audioAgent} {
466                         set a [$ui_ get_local_option $option]
467                         if { $a != {} } { $a set_local_sdes name $name }
468                 }
469 
470                 set mbMgr  [$self get_local_option mbMgr]
471                 if { $mbMgr != {} } { $mbMgr update_name $name }
472                 return 0
473         }
474         return -1
475 }
476 
477 
478 MultiControlMenu private update_note { note } {
479         $self instvar ui_
480         foreach option {videoAgent audioAgent} {
481                 set a [$ui_ get_local_option $option]
482                 if { $a != {} } { $a set_local_sdes note $note }
483         }
484         return 0
485 }
486 

~ [ 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.