1 # ui-loadProfile.tcl --
2 #
3 # To save a new Server Profile
4 #
5 # This file has the main ui component of the tgw application. Also, it
6 # contains many of the slightly modified superclasses to make things
7 # work... This is the main file with all the code in it.
8 #
9 # Copyright (c) 2000-2002 The Regents of the University of California.
10 # All rights reserved.
11 #
12 # Redistribution and use in source and binary forms, with or without
13 # modification, are permitted provided that the following conditions are met:
14 #
15 # A. Redistributions of source code must retain the above copyright notice,
16 # this list of conditions and the following disclaimer.
17 # B. Redistributions in binary form must reproduce the above copyright notice,
18 # this list of conditions and the following disclaimer in the documentation
19 # and/or other materials provided with the distribution.
20 # C. Neither the names of the copyright holders nor the names of its
21 # contributors may be used to endorse or promote products derived from this
22 # software without specific prior written permission.
23 #
24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
25 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
28 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35 import TopLevelWindow
36
37 Class ServerProfileSave -superclass TopLevelWindow -configuration { }
38
39 ServerProfileSave instproc init { } {
40 $self next .serverProfileSave
41 }
42
43 ServerProfileSave instproc build w {
44 global saveServerProfileName
45 $self create-window $w "Server Profile Save"
46 wm withdraw $w
47
48 entry $w.nameEntry -textvariable saveServerProfileName -relief sunken
49 frame $w.buttons
50 button $w.buttons.ok -text OK -relief raised \
51 -font [$self get_option smallfont] -highlightthickness 1 \
52 -command "$self toggle newvals"
53 button $w.buttons.cancel -text Cancel -relief raised \
54 -font [$self get_option smallfont] -highlightthickness 1 \
55 -command "$self toggle"
56 pack $w.buttons.ok $w.buttons.cancel -side left
57 pack $w.nameEntry $w.buttons
58 }
59
60 ServerProfileSave instproc toggle { { usevals 0 } } {
61 global saveServerProfileName inputtedSName inputtedSPort inputtedUName inputtedPass
62
63 if { $usevals != 0 } {
64 if [catch {open ~/.mash/realServerProfiles a} fileID] {
65 puts "no ~/.mash/realServerProfiles file"
66 } else {
67 puts $fileID "$saveServerProfileName:$inputtedSName:$inputtedSPort;$inputtedUName;$inputtedPass"
68 close $fileID
69 }
70 } else {
71 set saveServerProfileName ""
72 }
73 $self next
74 }
75
76 # To save a new Stream Profile
77
78 Class StreamProfileSave -superclass TopLevelWindow -configuration { }
79
80 StreamProfileSave instproc init { } {
81 $self next .streamProfileSave
82 }
83
84 StreamProfileSave instproc build w {
85 global saveStreamProfileName
86 $self create-window $w "Stream Profile Save"
87 wm withdraw $w
88
89 entry $w.nameEntry -textvariable saveStreamProfileName -relief sunken
90 frame $w.buttons
91 button $w.buttons.ok -text OK -relief raised \
92 -font [$self get_option smallfont] -highlightthickness 1 \
93 -command "$self toggle newvals"
94 button $w.buttons.cancel -text Cancel -relief raised \
95 -font [$self get_option smallfont] -highlightthickness 1 \
96 -command "$self toggle"
97 pack $w.buttons.ok $w.buttons.cancel -side left
98 pack $w.nameEntry $w.buttons
99 }
100
101 StreamProfileSave instproc toggle { { usevals 0 } } {
102 global saveStreamProfileName use56K use128K use256K use512K other otherInputted useSS outputFPS title author copyright sendtoRealServer streamName saveAsFile fileName sendAudio audioAddr
103
104 if { $usevals != 0 } {
105 if [catch {open ~/.mash/realStreamProfiles a} fileID] {
106 puts "no ~/.mash/realStreamProfiles file"
107 } else {
108 puts $fileID "$saveStreamProfileName:$use56K;$use128K;$use256K;$use512K;$other;$otherInputted;$useSS;$outputFPS;$title;$author;$copyright;$sendtoRealServer;$streamName;$saveAsFile;$fileName;$sendAudio;$audioAddr"
109 close $fileID
110 }
111 } else {
112 set saveStreamProfileName ""
113 }
114 $self next
115 }
116
117 proc Scroll_Set {scrollbar geoCmd offset size} {
118 if {$offset != 0.0 || $size != 1.0} {
119 eval $geoCmd
120 }
121 $scrollbar set $offset $size
122 }
123
124 proc Scrolled_listbox { f args } {
125 frame $f
126 listbox $f.list \
127 -xscrollcommand [list Scroll_Set $f.xscroll \
128 [list grid $f.xscroll -row 1 -column 0 -sticky we]] \
129 -yscrollcommand [list Scroll_Set $f.yscroll \
130 [list grid $f.yscroll -row 0 -column 1 -sticky ns]]
131 eval {$f.list configure} $args
132 scrollbar $f.xscroll -orient horizontal -command [list $f.list xview]
133 scrollbar $f.yscroll -orient vertical -command [list $f.list yview]
134 grid $f.list -sticky news
135 grid rowconfigure $f 0 -weight 1
136 grid columnconfigure $f 0 -weight 1
137 return $f.list
138 }
139
140 # displays the possible Server Profiles available
141
142 Class ServerProfileWindow -superclass TopLevelWindow -configuration { }
143
144 ServerProfileWindow instproc init { mainUI } {
145 $self next .serverProfiles
146 $self instvar ui_
147 set ui_ $mainUI
148 }
149
150 ServerProfileWindow instproc build w {
151 $self instvar listbox_
152 $self create-window $w "Server Profiles"
153 wm withdraw $w
154 set listbox_ [Scrolled_listbox $w.listbox -width 15 -height 5 -selectmode single]
155 $self refreshList
156 frame $w.buttons
157 button $w.buttons.ok -text OK -relief raised \
158 -font [$self get_option smallfont] -highlightthickness 1 \
159 -command "$self toggle newvals"
160 button $w.buttons.cancel -text Cancel -relief raised \
161 -font [$self get_option smallfont] -highlightthickness 1 \
162 -command "$self toggle"
163 pack $w.buttons.ok $w.buttons.cancel -side left
164 pack $w.listbox $w.buttons
165 }
166
167 ServerProfileWindow instproc refreshList { } {
168 $self instvar listbox_
169 if [info exists listbox_] {
170 $listbox_ delete 0 end
171 if [catch {open ~/.mash/realServerProfiles r} fileID] {
172 puts "no ~/.mash/realServerProfiles file"
173 } else {
174 while {![eof $fileID]} {
175 set tempString [gets $fileID]
176 $listbox_ insert end [string range $tempString 0 [expr [string first ":" $tempString] - 1]]
177 }
178 close $fileID
179 }
180 }
181 }
182
183 ServerProfileWindow instproc toggle { { usevals 0 } } {
184 $self instvar ui_ listbox_
185
186 if { $usevals != 0 } {
187 $listbox_ get active
188 if [catch {open ~/.mash/realServerProfiles r} fileID] {
189 puts "no ~/.mash/realServerProfiles file"
190 } else {
191 while {![eof $fileID]} {
192 set tempString [gets $fileID]
193 set tempNum [string first ":" $tempString]
194 if {[string compare [$listbox_ get [$listbox_ curselection]] [string range $tempString 0 [expr $tempNum - 1]]] == 0} {
195 incr tempNum
196 set tempString [string range $tempString $tempNum [string length $tempString]]
197 set sName [string range $tempString 0 [expr [string first ":" $tempString] - 1]]
198 set tempString [string range $tempString [expr 1 + [string first ":" $tempString]] [string length $tempString]]
199 set sPort [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
200 set tempString [string range $tempString [expr 1 + [string first ";" $tempString]] [string length $tempString]]
201 set uName [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
202 set tempString [string range $tempString [expr 1 + [string first ";" $tempString]] [string length $tempString]]
203 $ui_ setServerInfo $sName $sPort $uName $tempString
204 break
205 }
206 }
207 close $fileID
208 }
209 } else {
210 $self refreshList
211 }
212 $self next
213 }
214
215 # To load all the possible Stream Profiles
216
217 Class StreamProfileWindow -superclass TopLevelWindow -configuration { }
218
219 StreamProfileWindow instproc init { } {
220 $self next .streamProfiles
221 }
222
223 StreamProfileWindow instproc build w {
224 $self instvar listbox_
225 $self create-window $w "Stream Profiles"
226 wm withdraw $w
227 set listbox_ [Scrolled_listbox $w.listbox -width 15 -height 5 -selectmode single]
228 $self refreshList
229 frame $w.buttons
230 button $w.buttons.ok -text OK -relief raised \
231 -font [$self get_option smallfont] -highlightthickness 1 \
232 -command "$self toggle newvals"
233 button $w.buttons.cancel -text Cancel -relief raised \
234 -font [$self get_option smallfont] -highlightthickness 1 \
235 -command "$self toggle"
236 pack $w.buttons.ok $w.buttons.cancel -side left
237 pack $w.listbox $w.buttons
238 }
239
240 StreamProfileWindow instproc refreshList { } {
241 $self instvar listbox_
242 if [info exists listbox_] {
243 $listbox_ delete 0 end
244 if [catch {open ~/.mash/realStreamProfiles r} fileID] {
245 puts "no ~/.mash/realStreamProfiles file"
246 } else {
247 while {![eof $fileID]} {
248 set tempString [gets $fileID]
249 $listbox_ insert end [string range $tempString 0 [expr [string first ":" $tempString] - 1]]
250 }
251 close $fileID
252 }
253 }
254 }
255
256 StreamProfileWindow instproc toggle { { usevals 0 } } {
257 global use56K use128K use256K use512K other otherInputted useSS outputFPS title author copyright sendtoRealServer streamName saveAsFile fileName sendAudio audioAddr
258 $self instvar listbox_
259
260 if { $usevals != 0 } {
261 $listbox_ get active
262 if [catch {open ~/.mash/realStreamProfiles r} fileID] {
263 puts "no ~/.mash/realStreamProfiles file"
264 } else {
265 while {![eof $fileID]} {
266 set tempString [gets $fileID]
267 set tempNum [string first ":" $tempString]
268 if {[string compare [$listbox_ get [$listbox_ curselection]] [string range $tempString 0 [expr $tempNum - 1]]] == 0} {
269 incr tempNum
270 set tempString [string range $tempString $tempNum [string length $tempString]]
271 set use56K [string range $tempString 0 0]
272 set use128K [string range $tempString 2 2]
273 set use256K [string range $tempString 4 4]
274 set use512K [string range $tempString 6 6]
275 set other [string range $tempString 8 8]
276 set tempString [string range $tempString 10 [string length $tempString]]
277 set otherInputted [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
278 set tempString [string range $tempString [expr [string first ";" $tempString] + 1] [string length $tempString]]
279 set useSS [string range $tempString 0 0]
280 set tempString [string range $tempString 2 [string length $tempString]]
281 set outputFPS [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
282 set tempString [string range $tempString [expr [string first ";" $tempString] + 1] [string length $tempString]]
283 set title [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
284 set tempString [string range $tempString [expr [string first ";" $tempString] + 1] [string length $tempString]]
285 set author [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
286 set tempString [string range $tempString [expr [string first ";" $tempString] + 1] [string length $tempString]]
287 set copyright [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
288 set tempString [string range $tempString [expr [string first ";" $tempString] + 1] [string length $tempString]]
289 set sendtoRealServer [string range $tempString 0 0]
290 set tempString [string range $tempString 2 [string length $tempString]]
291 set streamName [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
292 set tempString [string range $tempString [expr [string first ";" $tempString] + 1] [string length $tempString]]
293 set saveAsFile [string range $tempString 0 0]
294 set tempString [string range $tempString 2 [string length $tempString]]
295 set fileName [string range $tempString 0 [expr [string first ";" $tempString] - 1]]
296 set tempString [string range $tempString [expr [string first ";" $tempString] + 1] [string length $tempString]]
297 set sendAudio [string range $tempString 0 0]
298 set audioAddr [string range $tempString 2 [string length $tempString]]
299 break
300 }
301 }
302 close $fileID
303 }
304 } else {
305 $self refreshList
306 }
307 $self next
308 }
309
310
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.