1 # mbv2-srm.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/mbv2/mbv2-srm.tcl,v 1.9 2002/02/03 04:21:59 lim Exp $
32
33
34 # make MBv2Session be an observable
35
36 import mashutils AddressBlock
37
38
39 # in order to allow apps (such as collaborator) that import MBv2 to work
40 # even if mbv2 is not compiled into the mash binary, we explicitly define
41 # dummy classes MBv2Session, MBv2Sender and MBv2Source here, in case they
42 # don't already exist
43 if { [Class info instances MBv2Session] == "" } {
44 Class MBv2Session
45 Class MBv2Sender
46 Class MBv2Source
47 } else {
48 MBv2Session superclass \
49 [concat [MBv2Session info superclass] Observable]
50 }
51
52 MBv2Session public init { spec cname } {
53 set ab [new AddressBlock $spec]
54 set ttl [$ab ttl]
55 if { $ttl=={} } { set ttl -1 }
56 $self next [$ab addr] [$ab sport] [$ab rport] $ttl
57 delete $ab
58
59 $self set spec_ $spec
60 # create the sender object
61 $self instvar sender_
62 set sender_ [new MBv2Sender $self $cname]
63 # notify the C++ side of this object
64 $self sender $sender_
65 }
66
67
68 MBv2Session public spec { } {
69 $self instvar spec_
70 return $spec_
71 }
72
73
74 MBv2Session public sender { args } {
75 if { [llength $args] == 0 } {
76 return [$self set sender_]
77 } else {
78 eval [list $self] next $args
79 }
80 }
81
82
83 MBv2Session public canvasmgr { canvmgr } {
84 $self set canvmgr_ $canvmgr
85 }
86
87
88 MBv2Session public get_canvas { pageid } {
89 if [catch {set c [$self get_canvas_ $pageid]} m] {
90 global errorInfo
91 puts $m\n$errorInfo
92 return ""
93 }
94 return $c
95 }
96
97
98 MBv2Session public get_canvas_ { pageid } {
99 $self instvar canvmgr_
100 if ![info exists canvmgr_] return ""
101 set c [$canvmgr_ get_canvas $pageid]
102 return $c
103 }
104
105
106 MBv2Session public source_name { srcid } {
107 $self instvar canvmgr_
108 return [$canvmgr_ source_name $srcid]
109 }
110
111
112 MBv2Session public source_update { src info } {
113 set info [split $info \n]
114 set name [lindex $info 0]
115 set cname [lindex $info 1]
116 $self notify_observers source_update $src $name $cname
117 }
118
119
120 MBv2Session public app_info { sender name cname } {
121 set info "$name\n$cname"
122 $sender app_info $info
123 $self source_update $sender $info
124 }
125
126
127 MBv2Session public activity { srcid pageid cmdid canvid islocal } {
128 $self notify_observers activity $srcid $pageid $cmdid $canvid $islocal
129 }
130
131
132 MBv2Sender superclass MBv2Source
133
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.