home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
osmp
/
root.2
/
usr
/
lib
/
scoadmin
/
psrsetup
/
psrsetupGUI
/
psrsetupGUI~
Wrap
Text File
|
1998-08-19
|
10KB
|
301 lines
#!/bin/osavtcl
# Copyright (c) 1992-1998 The Santa Cruz Operation, Inc.. All Rights Reserved.
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE
# SANTA CRUZ OPERATION INC.
#
# The copyright notice above does not evidence any actual or intended
# publication of such source code.
#******************************************************************************
#
# Copyright (C) 1992-1998 The Santa Cruz Operation, Inc.
# All Rights Reserved.
#
# The information in this file is provided for the exclusive use of
# the licensees of The Santa Cruz Operation, Inc. Such users have the
# right to use, modify, and incorporate this code into other products
# for purposes authorized by the license agreement provided they include
# this notice and the associated copyright notice with any such product.
# The information in this file is provided "AS IS" without warranty.
#
#===============================================================================
#@package: SCO_PSRSETUPGUI_MSGS SCO_PSRSETUPGUI_MSGS
proc SCO_PSRSETUPGUI_MSGS {} {}
global SCO_PSRSETUPGUI_MSGS
set SCO_PSRSETUPGUI_MSGS(@catalog@) {psrsetupGUI.cat@sa 1}
set SCO_PSRSETUPGUI_MSGS(MSG_DLGTITLE) {1 {Processor Setup}}
set SCO_PSRSETUPGUI_MSGS(MSG_FORMTITLE) {2 {Processor Setup %s}}
set SCO_PSRSETUPGUI_MSGS(MSG_MENU_HOSTS) {3 Hosts}
set SCO_PSRSETUPGUI_MSGS(MSG_MN_MENU_HOSTS) {4 t}
set SCO_PSRSETUPGUI_MSGS(MSG_MENU_OPENHOST) {5 {Open host...}}
set SCO_PSRSETUPGUI_MSGS(MSG_MN_MENU_OPENHOST) {6 O}
set SCO_PSRSETUPGUI_MSGS(MSG_MENU_EXIT) {7 Exit}
set SCO_PSRSETUPGUI_MSGS(MSG_MN_MENU_EXIT) {8 x}
set SCO_PSRSETUPGUI_MSGS(MSG_MENU_ACTION) {9 Action}
set SCO_PSRSETUPGUI_MSGS(MSG_MN_MENU_ACTION) {10 A}
set SCO_PSRSETUPGUI_MSGS(MSG_MENU_PROPS) {11 Properties}
set SCO_PSRSETUPGUI_MSGS(MSG_MN_MENU_PROPS) {12 P}
set SCO_PSRSETUPGUI_MSGS(MSG_MENU_START) {13 Start/Stop}
set SCO_PSRSETUPGUI_MSGS(MSG_MN_MENU_START) {14 S}
set SCO_PSRSETUPGUI_MSGS(MSG_USAGE1) {15 {Usage: %s \[host\]}}
set SCO_PSRSETUPGUI_MSGS(MSG_USAGE2) {16 {Usage: %s}}
set SCO_PSRSETUPGUI_MSGS(MSG_SELECT_STOP) {17 {Select a processor start or stop}}
set SCO_PSRSETUPGUI_MSGS(MSG_SELECT_PROP) {18 {Select a processor to look at the properties of}}
proc UiProcessorCfg { parent } {
global appvals
set mainForm \
[VtFormDialog $parent.createDaemonForm \
-okCallback UiProcessorCfgOKCB \
-cancelCallback UiProcessorCfgCancelCB \
-autoLock "UiProcessorCfgOKCB UiProcessorCfgCancelCB" \
-title [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_FORMTITLE \
($appvals(managedhost))] \
-ok \
-cancel \
-marginWidth 1 \
]
set appvals(vtMain) $mainForm
set menuBar [VtMenuBar $mainForm.menuBar ]
set hostMenu [VtPulldown $menuBar.hostMenu \
-label [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MENU_HOSTS] \
-mnemonic [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MN_MENU_HOSTS] ]
VtPushButton $hostMenu.openhost \
-label [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MENU_OPENHOST] \
-mnemonic [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MN_MENU_OPENHOST] \
-callback SaOpenHostCB \
-autoLock SaOpenHostCB
VtSeparator $hostMenu.s1
VtPushButton $hostMenu.exit \
-label [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MENU_EXIT] \
-mnemonic [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MN_MENU_EXIT] \
-callback UiProcessorCfgCancelCB \
-autoLock UiProcessorCfgCancelCB
set actionsPD [VtPulldown $menuBar.actionsPD \
-label [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MENU_ACTION] \
-mnemonic [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MN_MENU_ACTION] ]
VtPushButton $actionsPD.properties \
-label [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MENU_PROPS] \
-mnemonic [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MN_MENU_PROPS] \
-callback "UiProcessorPropertiesCB" \
-autoLock "UiProcessorPropertiesCB"
VtPushButton $actionsPD.startstop \
-label [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MENU_START] \
-mnemonic [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_MN_MENU_START] \
-callback "UiProcessorStartStopCB" \
-autoLock "UiProcessorStartStopCB"
set formatlist {{STRING 50}}
set CHARM_formatlist {{STRING 50}}
set drawnList [VtDrawnList $mainForm.drawnList \
-formatList $formatlist \
-CHARM_formatList $CHARM_formatlist \
-columns 50 \
-rows 6 \
-rightSide FORM]
VxSetVar $mainForm drawnList $drawnList
UiProcessorRefresh $mainForm
VtShow $mainForm
VtUnLock
}
proc UiProcessorRefresh { psrDlg } {
global appvals
set drawnList [VxGetVar $psrDlg drawnList]
VtDrawnListDeleteItem $drawnList -all
set result [osaGetAllProcessorInfo $appvals(managedhost)]
if { [lindex $result 0] != 0 } {
UiDisplayErrorMessage $parent [lindex $result 1]
return
}
set recordlist [list]
foreach i [lindex $result 1] {
append tmpvar " [list [concat Processor $i]]"
lappend recordlist $tmpvar
unset tmpvar
}
VtDrawnListAddItem $drawnList \
-recordList $recordlist
}
proc UiProcessorCfgOKCB { cbs } {
set parent [keylget cbs dialog]
VtDestroy $parent
VtUnLock
UiStop
}
proc UiProcessorCfgCancelCB { cbs } {
set parent [keylget cbs dialog]
VtDestroy $parent
VtUnLock
UiStop
}
proc UiProcessorPropertiesCB { cbs } {
global appvals
set parent [keylget cbs dialog]
set psrno [UiGetSelectProcessorNo $parent]
if [cequal $psrno ""] {
UiDisplayInfoMessage $parent \
[IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_SELECT_PROP]
} else {
set result [osaGetProcessorInfo $appvals(managedhost) $psrno]
if { [lindex $result 0] != 0 } {
UiDisplayErrorMessage $parent [lindex $result 1]
} else {
set info [VtInformationDialog $parent.info \
-message [lindex $result 1]]
VtShow $info
}
}
VtUnLock
}
proc UiProcessorStartStopCB { cbs } {
global appvals
set parent [keylget cbs dialog]
set psrno [UiGetSelectProcessorNo $parent]
if [cequal $psrno ""] {
UiDisplayInfoMessage $parent \
[IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_SELECT_STOP]
} else {
set result [osaStartStopProcessor $appvals(managedhost) $psrno]
if { [lindex $result 0] != 0 } {
UiDisplayErrorMessage $parent [lindex $result 1]
} else {
UiProcessorRefresh $parent
}
}
VtUnLock
}
proc UiGetSelectProcessorNo { psrDlg } {
set drawnList [VxGetVar $psrDlg drawnList]
set posList [VtDrawnListGetSelectedItem $drawnList -byPositionList]
if { $posList != 0 } {
set psrno [expr $posList - 1]
return $psrno
} else {
return ""
}
}
proc UiDisplayErrorMessage { parent msg } {
set errMsgDlg [VtErrorDialog $parent.errMsgDlg \
-message $msg ]
VtShow $errMsgDlg
}
proc UiDisplayInfoMessage { parent msg } {
set infoMsgDlg [VtInformationDialog $parent.errMsgDlg \
-message $msg ]
VtShow $infoMsgDlg
}
proc GetInstanceList { names host} {
set instanceList {}
if { $host == "localhost" } {
foreach name $names {
set instance [list $name]
lappend instanceList $instance
}
} else {
foreach name $names {
set instance [list [list systemId $host] [list $name]]
lappend instanceList $instance
}
}
return $instanceList
}
proc osaPsrSetupOSACall { host actionType args } {
set class [list sco psrsetup]
set instance [GetInstanceList NULL $host]
set command [list ObjectAction $class $instance $actionType $args]
set result [SaMakeObjectCall $command]
set result [lindex $result 0]
if { [BmipResponseErrorIsPresent result] } {
set errorStack [BmipResponseErrorStack result]
ErrorThrow errorStack
return {}
}
set retVal [BmipResponseActionInfo result]
return $retVal
}
proc osaGetAllProcessorInfo { host } {
return [osaPsrSetupOSACall $host GetAllProcessorInfo {}]
}
proc osaStartStopProcessor { host psrno } {
return [osaPsrSetupOSACall $host StartStopProcessor $psrno]
}
proc osaGetProcessorInfo { host psrno } {
return [osaPsrSetupOSACall $host GetProcessorInfo $psrno]
}
set appvals(title) [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_DLGTITLE]
set appvals(script) [file tail [info script]] ;# argv[0]: UNIX command name
set appvals(client) $appvals(script) ;# widget strings, preferences
set appvals(version) 1.0
set appvals(openhost) 1
set appvals(vtMain) ""
proc Exit {{code 0}} {
exit $code
}
proc Usage {} {
global appvals
if $appvals(openhost) {
set usage [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_USAGE1]
} else {
set usage [IntlLocalizeMsg SCO_PSRSETUPGUI_MSG_USAGE2]
}
puts stderr $usage
}
proc ParseCommandLine {} {
global argv argc opterr optind appvals
set optString ""
set argc [llength $argv]
set opterr 0
while {[set opt [getopt $argc $argv $optString]] != -1} {
switch $opt -- {
{?} {
Usage; Exit 1
}
}
}
set optCount [expr "$argc - $optind"]
if {[expr $optCount >= 1]} {
set appvals(managedhost) [lindex $argv $optind]
incr optCount -1
incr optind 1
}
set appvals(groupList) {}
set appvals(errorPrompt) {}
if ([expr $optCount >= 2]) {
set appvals(groupList) [lindex $argv $optind]
incr optind 1
set appvals(errorPrompt) [lindex $argv $optind]
incr optind 1
incr optCount -2
}
if {$optCount != 0} {
Usage; Exit 1
}
}
proc Main {} {
global appvals
set appvals(localhost) [SaHostGetLocalName]
set appvals(managedhost) $appvals(localhost)
ParseCommandLine
if { [catch UiStart catrchres ] } {
echo Problem Starting GUI
echo $catrchres
VtUnLock
if { ! [cequal $appvals(vtMain) ""] } {
VtDestroy $appvals(vtMain)
}
}
}
proc UiStart {} {
global appvals
set vtApp [VtOpen $appvals(client) ]
VtSetAppValues $vtApp \
-versionString "$appvals(title) $appvals(version)" \
-errorCallback {SaUnexpectedErrorCB {}}
UiProcessorCfg $vtApp
VtMainLoop
}
proc UiStop {} {
global appvals
VtClose
}
ErrorTopLevelCatch {Main} $appvals(script)