home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / update701 / root.16 / usr / lib / scoadmin / license / licenseMgr / licenseMgr~
Text File  |  1998-08-18  |  62KB  |  1,885 lines

  1. #!/bin/osavtcl
  2. # Copyright (c) 1992-1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  3. #                                                                         
  4. #        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  5. #                   SANTA CRUZ OPERATION INC.                             
  6. #                                                                         
  7. #   The copyright notice above does not evidence any actual or intended   
  8. #   publication of such source code.                                      
  9.  
  10. #******************************************************************************
  11. #
  12. #    Copyright (C) 1992-1998 The Santa Cruz Operation, Inc.
  13. #        All Rights Reserved.
  14. #
  15. #    The information in this file is provided for the exclusive use of
  16. #    the licensees of The Santa Cruz Operation, Inc.  Such users have the
  17. #    right to use, modify, and incorporate this code into other products
  18. #    for purposes authorized by the license agreement provided they include
  19. #    this notice and the associated copyright notice with any such product.
  20. #    The information in this file is provided "AS IS" without warranty.
  21. #
  22. #===============================================================================
  23. #@package: SCO_LICENSEMGR_GUI_MSGS SCO_LICENSEMGR_GUI_MSGS
  24. proc SCO_LICENSEMGR_GUI_MSGS {} {}
  25. global SCO_LICENSEMGR_GUI_MSGS
  26. set SCO_LICENSEMGR_GUI_MSGS(@catalog@) {licenseMgr.cat@sa 1}
  27. set SCO_LICENSEMGR_GUI_MSGS(MSG_TITLE) {1 {License Manager}}
  28. set SCO_LICENSEMGR_GUI_MSGS(MSG_ITEMS) {2 licenses}
  29. set SCO_LICENSEMGR_GUI_MSGS(MSG_SELECTED) {3 Selected}
  30. set SCO_LICENSEMGR_GUI_MSGS(MSG_DETAILS) {4 Details}
  31. set SCO_LICENSEMGR_GUI_MSGS(MSG_ON) {5 on}
  32. set SCO_LICENSEMGR_GUI_MSGS(MSG_HOST) {6 Host}
  33. set SCO_LICENSEMGR_GUI_MSGS(MSG_HOST_MN) {7 t}
  34. set SCO_LICENSEMGR_GUI_MSGS(MSG_OBJECT) {8 License}
  35. set SCO_LICENSEMGR_GUI_MSGS(MSG_OBJECT_MN) {9 L}
  36. set SCO_LICENSEMGR_GUI_MSGS(MSG_OPENHOST) {10 {Open Host...}}
  37. set SCO_LICENSEMGR_GUI_MSGS(MSG_OPENHOST_MN) {11 O}
  38. set SCO_LICENSEMGR_GUI_MSGS(MSG_OPENHOST_ACC) {12 Ctrl<Key>O}
  39. set SCO_LICENSEMGR_GUI_MSGS(MSG_OPENHOST_ACCSTR) {13 Ctrl+O}
  40. set SCO_LICENSEMGR_GUI_MSGS(MSG_OPENHOST_SH) {14 {Manage %s on another host}}
  41. set SCO_LICENSEMGR_GUI_MSGS(MSG_EXIT) {15 Exit}
  42. set SCO_LICENSEMGR_GUI_MSGS(MSG_EXIT_MN) {16 x}
  43. set SCO_LICENSEMGR_GUI_MSGS(MSG_EXIT_SH) {17 {Exit %s}}
  44. set SCO_LICENSEMGR_GUI_MSGS(MSG_OPTIONS) {18 Options}
  45. set SCO_LICENSEMGR_GUI_MSGS(MSG_OPTIONS_MN) {19 O}
  46. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE) {20 License...}
  47. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_MN) {21 L}
  48. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_SH) {22 {License an installed product on the system}}
  49. set SCO_LICENSEMGR_GUI_MSGS(MSG_LIC_ADD) {23 Add...}
  50. set SCO_LICENSEMGR_GUI_MSGS(MSG_LIC_ADD_MN) {24 A}
  51. set SCO_LICENSEMGR_GUI_MSGS(MSG_LIC_ADD_SH) {25 {License an installed product on the system}}
  52. set SCO_LICENSEMGR_GUI_MSGS(MSG_LIC_REMOVE) {26 Remove...}
  53. set SCO_LICENSEMGR_GUI_MSGS(MSG_LIC_REMOVE_MN) {27 R}
  54. set SCO_LICENSEMGR_GUI_MSGS(MSG_LIC_REMOVE_SH) {28 {Remove a license from the system}}
  55. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER) {29 Register...}
  56. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_MN) {30 R}
  57. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_SH) {31 {Register a product license on the system}}
  58. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW) {32 View}
  59. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_MN) {33 V}
  60. set SCO_LICENSEMGR_GUI_MSGS(MSG_REFRESH_SH) {34 {Refresh data}}
  61. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_ALL) {35 All}
  62. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_ALL_MN) {36 A}
  63. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_ALL_SH) {37 {View all the installed products}}
  64. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_EXPIRED) {38 {Expired License(s)}}
  65. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_EXPIRED_MN) {39 E}
  66. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_EXPIRED_SH) {40 {View license already expired}}
  67. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_NOTREGT) {41 {Not Registered License(s)}}
  68. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_NOTREGT_MN) {42 R}
  69. set SCO_LICENSEMGR_GUI_MSGS(MSG_VIEW_NOTREGT_SH) {43 {View products not registered}}
  70. set SCO_LICENSEMGR_GUI_MSGS(MSG_TB_OPENHOST) {44 /usr/lib/scoadmin/icons/openhost.px}
  71. set SCO_LICENSEMGR_GUI_MSGS(MSG_TB_ADD) {45 /usr/lib/scoadmin/license/add.px}
  72. set SCO_LICENSEMGR_GUI_MSGS(MSG_TB_REGISTER) {46 /usr/lib/scoadmin/license/register.px}
  73. set SCO_LICENSEMGR_GUI_MSGS(MSG_TB_DELETE) {47 /usr/lib/scoadmin/icons/delete.px}
  74. set SCO_LICENSEMGR_GUI_MSGS(MSG_CLOSE) {48 Close}
  75. set SCO_LICENSEMGR_GUI_MSGS(MSG_OK) {49 Ok}
  76. set SCO_LICENSEMGR_GUI_MSGS(MSG_COUNT_LABEL_STRING) {50 {%1$s %2$s, %3$s %4$s}}
  77. set SCO_LICENSEMGR_GUI_MSGS(MSG_YES_LABEL) {51 Yes}
  78. set SCO_LICENSEMGR_GUI_MSGS(MSG_NO_LABEL) {52 No}
  79. set SCO_LICENSEMGR_GUI_MSGS(MSG_CANCEL_LABEL) {53 Cancel}
  80. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_LABEL) {54 License}
  81. set SCO_LICENSEMGR_GUI_MSGS(MSG_PROD_NAME) {55 {Product Name}}
  82. set SCO_LICENSEMGR_GUI_MSGS(MSG_LIC_NUMBER) {56 {License Number}}
  83. set SCO_LICENSEMGR_GUI_MSGS(MSG_LIC_STATUS) {57 Status}
  84. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_STATUS) {58 Registered}
  85. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_INSTALL_ID) {59 {SCO System ID:}}
  86. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_LICENSE_KEY) {60 {Registration Key:}}
  87. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_LICENSE_NUMBER) {61 {License Number:}}
  88. set SCO_LICENSEMGR_GUI_MSGS(MSG_UNKNOWN_PRODUCT_NAME) {62 {Unknown product with id %s}}
  89. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_NOT_REQUIRED) {63 N/A}
  90. set SCO_LICENSEMGR_GUI_MSGS(MSG_EXPIRED_DATE) {64 {Expired on %s}}
  91. set SCO_LICENSEMGR_GUI_MSGS(MSG_EXPIRED_LABEL) {65 Expired}
  92. set SCO_LICENSEMGR_GUI_MSGS(MSG_WILL_EXPIRE_ON) {66 {Valid until %s}}
  93. set SCO_LICENSEMGR_GUI_MSGS(MSG_PERMANENT_LICENSE) {67 {Permanent License}}
  94. set SCO_LICENSEMGR_GUI_MSGS(MSG_SERIAL_NUMBER_LABEL) {68 {License Number: }}
  95. set SCO_LICENSEMGR_GUI_MSGS(MSG_ACTION_KEY_LABEL) {69 {License Code: }}
  96. set SCO_LICENSEMGR_GUI_MSGS(MSG_EXTENTION_LABEL) {70 {License Data: }}
  97. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_ADD_WIN_TITLE) {71 {Add License on %s}}
  98. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_REMOVE_WIN_TITLE) {72 {Remove License on %s}}
  99. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_REGISTER_WIN_TITLE) {73 {Register License on %s}}
  100. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_STATUS_WIN_TITLE) {74 {Registration Status}}
  101. set SCO_LICENSEMGR_GUI_MSGS(MSG_MAINLIST_SH) {75 {Double click the selected license to start registration...}}
  102. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_ADD_INSTRUCTION) {76 {Please enter the information  as printed on the \nCertificate of License and Authenticity from SCO. }}
  103. set SCO_LICENSEMGR_GUI_MSGS(MSG_SPECIFY_LICENSE_NUMBER) {77 {Please specify the License Number printed on COlA.}}
  104. set SCO_LICENSEMGR_GUI_MSGS(MSG_SPECIFY_LICENSE_CODE) {78 {Please specify the License Code printed on COLA.}}
  105. set SCO_LICENSEMGR_GUI_MSGS(MSG_SPECIFY_LICENSE_DATA) {79 {Please specify the License Data printed on COLA.}}
  106. set SCO_LICENSEMGR_GUI_MSGS(MSG_SPECIFY_REGISTRATION_KEY) {80 {Please specify the Registration Key to register a product.}}
  107. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_DATA_REQUIRED) {81 {License Data is required for this license.\nPlease Enter the data printed on the COLA}}
  108. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_ADD_COMPLETE) {82 {Congratulation!\nLicensing  of <%s> is successfully completed.}}
  109. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_ADD_DUPLICATE) {83 {License with License Number <%s> has been added already!}}
  110. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_REMOVE_WARNING) {84 {License of < %s > will be removed from the system,\ndo you really want to proceed?}}
  111. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_REMOVE_COMPLETE) {85 {License of < %s > is successfully removed!}}
  112. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_REGISTER_INSTRUCT_A) {86 {You have selected to register the following product: }}
  113. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_REGISTER_INSTRUCT_B) {87 {To register this product, please follow the instructions printed on  your SCO \nSoftware Registration Booklet and enter the Registration Key given back to you. \n}}
  114. set SCO_LICENSEMGR_GUI_MSGS(MSG_LICENSE_REGISTER_COMPLETE) {88 {License of < %s > is successfully registered!}}
  115. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_DONE_ALREADY) {89 {License of < %s > has been registered.}}
  116. set SCO_LICENSEMGR_GUI_MSGS(MSG_NOT_REQUIRED_REGISTRATION) {90 {License of < %s > is not required to register.}}
  117. set SCO_LICENSEMGR_GUI_MSGS(MSG_INIT) {91 Initializing...}
  118. set SCO_LICENSEMGR_GUI_MSGS(MSG_REFRESH) {92 {Refreshing data...}}
  119. set SCO_LICENSEMGR_GUI_MSGS(ERR_CMD_BRAND_LIST_UNABLE) {93 {Unable to run brand command}}
  120. set SCO_LICENSEMGR_GUI_MSGS(ERR_CMD_BRAND_CHECK_EXT_UNABLE) {94 {Unable to run brand command to check whether license data is required or not}}
  121. set SCO_LICENSEMGR_GUI_MSGS(ERR_CMD_BRAND_INSTALL_ID_UNABLE) {95 {Unable to run brand to find out the installation ID.}}
  122. set SCO_LICENSEMGR_GUI_MSGS(ERR_INVALID_LICENSE_NUMBER_CODE) {96 {You have entered invalid License Number or License Code. \nPlease check the information printed on the COLA}}
  123. set SCO_LICENSEMGR_GUI_MSGS(ERR_CMD_BRAND_ADD_UNABLE) {97 {Unable to run brand command to add a license on the system}}
  124. set SCO_LICENSEMGR_GUI_MSGS(ERR_CMD_BRAND_REGISTER_UNABLE) {98 {Unable to run brand command to register the license on the system.}}
  125. set SCO_LICENSEMGR_GUI_MSGS(ERR_BRAND_RC1_ERROR) {99 {Brand Usage Error, check details for correct usage.}}
  126. set SCO_LICENSEMGR_GUI_MSGS(ERR_BRAND_RC2_ERROR) {100 {Invalid License Code or License Number was specified.}}
  127. set SCO_LICENSEMGR_GUI_MSGS(ERR_BRAND_RC10_ERROR) {101 {Invalid License Data was specified.}}
  128. set SCO_LICENSEMGR_GUI_MSGS(ERR_BRAND_RC12_ERROR) {102 {Invalid Registration Key was specified.}}
  129. set SCO_LICENSEMGR_GUI_MSGS(ERR_BRAND_RC13_ERROR) {103 {Permission Denied}}
  130. set SCO_LICENSEMGR_GUI_MSGS(ERR_NODELOCKFILE_CAT_UNABLE) {104 {Unable to get the content of nodelock file on managed system. }}
  131. set SCO_LICENSEMGR_GUI_MSGS(ERR_NODELOCKFILE_MODIFY_UNABLE) {105 {Unable to modify the nodelock file on managed system. }}
  132. set SCO_LICENSEMGR_GUI_MSGS(ERR_IFOR_PMD_CAT_UNABLE) {106 {Unable to get the pid of process Ifor_pmd.}}
  133. set SCO_LICENSEMGR_GUI_MSGS(ERR_KILL_PROCESS_UNABLE) {107 {Unable to kill the specified process.}}
  134. set SCO_LICENSEMGR_GUI_MSGS(MSG_REGISTER_INSTALL_ID_NOT_APPLIED) {108 {-- N/A --}}
  135. set SCO_LICENSEMGR_GUI_MSGS(ERR_CHECK_OWNER_UNABLE) {109 {Unable to invoke tfadmin to check owner privilege}}
  136. set SCO_LICENSEMGR_GUI_MSGS(MSG_LOWER_CASE_ITEMS) {110 Items}
  137. loadlibindex /usr/lib/sysadm.tlib
  138. set appvals(intlpre) SCO_LICENSEMGR_GUI            ;# i10n msg prefix
  139. proc IntlMsg {id {argList {}}} {
  140.     global appvals
  141.     return [IntlLocalizeMsg $appvals(intlpre)_MSG_$id $argList]
  142. }
  143. proc IntlErr {id {argList {}}} {
  144.     global appvals
  145.     return [IntlLocalizeMsg $appvals(intlpre)_ERR_$id $argList]
  146. }
  147. proc IntlMsgId {id} {
  148.     global appvals
  149.     return $appvals(intlpre)_MSG_$id
  150. }
  151. proc IntlErrId {id} {
  152.     global appvals
  153.     return $appvals(intlpre)_ERR_$id
  154. }
  155. set appvals(title)     [IntlMsg TITLE]    ;# UI title string
  156. set appvals(vtApp)    {}        ;# VtOpen return; generally not used 
  157. set appvals(vtMain)    {}        ;# widget string of main dialog
  158. set appvals(object)     [IntlMsg OBJECT]    ;# object menu, e.g. file, . .
  159. set appvals(objectmn)      [IntlMsg OBJECT_MN]    ;# object mnemonic
  160. set appvals(itemname)     [IntlMsg ITEMS]        ;# noun for "count label"  
  161. set appvals(openhost)         1        ;# SaOpenHost services 
  162. set appvals(toolbar)         1        ;# toolbar
  163. set appvals(toolbarcust)     1        ;# customizable toolbar
  164. set appvals(autorefresh)         0        ;# SaAutoRefresh services
  165. set appvals(autorefreshcust)    0        ;# customize a-refresh interval 
  166. set appvals(autorefreshmin)     1        ;# min interval (minutes)
  167. set appvals(autorefreshmax)     60        ;# max interval (minutes) 
  168. proc UiWidgetGet {widget {parent {}}} {
  169.     global appvals
  170.     if {[lempty $parent]} {
  171.         set parent $appvals(vtMain)
  172.     }
  173.     return [VxGetVar $parent $widget]
  174. }
  175. proc UiWidgetSet {widget value {parent {}}} {
  176.     global appvals
  177.     if {[lempty $parent]} {
  178.         set parent $appvals(vtMain)
  179.     }
  180.     VxSetVar $parent $widget $value
  181. }
  182. proc UiDefaultFormSpacingSet {form} {
  183.     VtSetValues $form \
  184.         -horizontalSpacing 0 \
  185.         -verticalSpacing 0 \
  186.         -marginWidth 0 \
  187.         -marginHeight 0 
  188. }
  189. proc UiAlignLabels {maxwidth labellist formlist} {
  190.     set index [llength $labellist]
  191.     set maxwidth [expr {$maxwidth + 1}]
  192.     for {set i 0} {$i < $index} {incr i} {
  193.         set label [lindex $labellist $i]
  194.         set form [lindex $formlist $i]
  195.         set width [VtGetValues $label -width]
  196.         if {$width < $maxwidth} {
  197.             set offset [expr {($maxwidth - $width) + 10}]
  198.             set charmoffset [expr {($maxwidth - $width) + 1}]
  199.             VtSetValues $form \
  200.                         -leftOffset $offset -CHARM_leftOffset $charmoffset
  201.         }
  202.      }
  203. }; # UiAlignLables
  204. proc UiDisplayErrorStackCB {callback cbs} {
  205.     global appvals
  206.     set dialog [keylget cbs dialog]
  207.     VtDestroyDialog $dialog
  208.     SaStatusBarClear [VxGetVar $appvals(vtMain) statusBar]
  209.     if {$appvals(autorefresh)} {
  210.         SaAutoRefreshResume
  211.     }
  212.     if {![lempty $callback]} {
  213.         eval $callback [list $cbs]
  214.     }
  215. }
  216. proc UiDisplayErrorStacks {caller stack {callback ""}} {
  217.     global appvals
  218.     if {$appvals(autorefresh)} {
  219.         SaAutoRefreshPause
  220.     }
  221.     SaDisplayErrorStacks $appvals(vtMain).$caller [list $stack] HELP \
  222.         [list UiDisplayErrorStackCB $callback]
  223. }
  224. proc UiShowErrorDialog { parent caller message } {
  225.     global appvals
  226.     VtShow [VtInformationDialog $parent.$caller \
  227.                 -message $message \
  228.                 -cancel \
  229.                 -cancelLabel [IntlMsg OK] \
  230.                 -cancelButton CANCEL\
  231.             ]
  232.     VtUnLock
  233.     return
  234. }
  235. proc UiSetAppFocus {} {
  236.     global appvals
  237.     VtSetFocus [VxGetVar $appvals(vtMain) menuBar] 
  238.         if {![lempty [UiMainListGetItems]]} {
  239.             VtSetFocus [VxGetVar $appvals(vtMain) mainList]
  240.         }
  241. }
  242. proc UiSetFocusNextTabGroup { cbs } {
  243.     global appvals
  244.     set mode [keylget cbs mode]
  245.     if {$mode != "done"} {
  246.         return
  247.     }
  248.     VtSetFocus [keylget cbs dialog] -direction NEXT_TAB_GROUP
  249. }; # UiSetFocusNextTabGroup
  250. proc UiMainListSetItems {items} {
  251.     global appvals
  252.     set mainList [VxGetVar $appvals(vtMain) mainList]
  253.     UiListSetItems $mainList $items
  254.     if { ![ lempty $items] } {
  255.         VtDrawnListSelectItem $mainList -position 1
  256.     }
  257. }
  258. proc UiMainListGetItems {} {
  259.     global appvals
  260.     return [VtDrawnListGetItem [VxGetVar $appvals(vtMain) mainList] -all]
  261. }
  262. proc UiMainListCB {cbs} {
  263.     global appvals
  264.     UiUpdateCountLabel
  265.     UiSensitizeFunctions
  266. }
  267. proc UiMainListDoubleCB {cbs} {
  268.     global appvals
  269.     set parent $appvals(vtMain)
  270.     set mainList [VxGetVar $appvals(vtMain) mainList]
  271.     set selectedItem [UiListGetSelectedItem]  
  272.      set registerState [lindex $selectedItem $appvals(registerListIndex)]
  273.     set productName [lindex $selectedItem $appvals(nameListIndex)]
  274.     if { [string compare $registerState [IntlMsg NO_LABEL]] !=0 } {
  275.         if { [string compare $registerState [IntlMsg YES_LABEL] ] ==0 } {
  276.             set message [IntlMsg REGISTER_DONE_ALREADY [list $productName] ]
  277.         } else {
  278.             set message [IntlMsg NOT_REQUIRED_REGISTRATION [list $productName] ] 
  279.         }
  280.         VtShow [VtInformationDialog $parent.info \
  281.                     -title [IntlMsg REGISTER_STATUS_WIN_TITLE] \
  282.                     -ok \
  283.                     -message $message \
  284.                ] 
  285.         VtUnLock
  286.         return
  287.     } else {
  288.         UiRegisterBtnCB $cbs
  289.     }    
  290.     VtUnLock
  291. }; # UiMainListDoubleCB
  292. proc UiUpdateCountLabel {} {
  293.     global appvals
  294.     set mainList [VxGetVar $appvals(vtMain) mainList]
  295.     set countLabel [VxGetVar $appvals(vtMain) countLabel]
  296.     if {[VtDrawnListGetSelectedItem $mainList] == 0} {
  297.         set  numSelected 0
  298.     } else  {
  299.         set numSelected [llength [VtDrawnListGetSelectedItem $mainList]]
  300.     }
  301.         lappend labelArgs [llength [VtDrawnListGetItem $mainList -all]]
  302.         lappend labelArgs [IntlMsg LOWER_CASE_ITEMS] 
  303.         lappend labelArgs $numSelected
  304.         lappend labelArgs [VxGetVar $countLabel selected ]
  305.         set labelValue [IntlMsg COUNT_LABEL_STRING $labelArgs]
  306.     VtSetValues $countLabel -label $labelValue
  307. }
  308. proc UiCloseCB {cbs} {
  309.     CloseWithUi
  310.     UiStop    UiCloseCB2
  311. }
  312. proc UiCloseCB2 {{cbs {}}} {
  313.     CloseAfterUi
  314. }
  315. proc ErrExitCB { cbs } {
  316.     global appvals
  317.     VtClose
  318.     Exit 1
  319. }
  320. proc UiRefreshCB { {cbs {}}} {
  321.     global appvals
  322.     SaStatusBarSet [VxGetVar $appvals(vtMain) statusBar] [IntlMsg REFRESH] 
  323.     UiListSaveSelectedItems [VxGetVar $appvals(vtMain) mainList]
  324.     Refresh 
  325.     UiListRestoreSelectedItems [VxGetVar $appvals(vtMain) mainList]
  326.     UiUpdateCountLabel
  327.     UiSensitizeFunctions
  328.     SaStatusBarClear [VxGetVar $appvals(vtMain) statusBar]
  329.     VtUnLock
  330. }
  331. proc UiSensitizeFunctions {} {
  332.     global appvals
  333.     set mainList [VxGetVar $appvals(vtMain) mainList]
  334.     if {[VtDrawnListGetSelectedItem $mainList] == 0} {
  335.         set  selected 0
  336.     } else  {
  337.         set selected [llength [VtDrawnListGetSelectedItem $mainList]]
  338.     }
  339.     set menuBar [VxGetVar $appvals(vtMain) menuBar]
  340.     set AddBtn [VxGetVar $menuBar AddBtn]
  341.     set RemoveBtn [VxGetVar $menuBar RemoveBtn]
  342.     set RegisterBtn [VxGetVar $menuBar RegisterBtn]
  343.     VtSetSensitive $AddBtn 1
  344.     UiToolBarSetSensitive add 1
  345.     if {$selected == 0} {
  346.         VtSetSensitive $RemoveBtn 0
  347.         UiToolBarSetSensitive remove 0
  348.         VtSetSensitive $RegisterBtn 0
  349.         UiToolBarSetSensitive register 0
  350.     } else {
  351.         VtSetSensitive $RemoveBtn 1
  352.         UiToolBarSetSensitive remove 1
  353.         set selectedItem [UiListGetSelectedItem]
  354.         set registerState [lindex $selectedItem $appvals(registerListIndex)]
  355.         if { [string compare $registerState [IntlMsg NO_LABEL]] == 0 } {
  356.             VtSetSensitive $RegisterBtn 1
  357.             UiToolBarSetSensitive register 1
  358.         } else {
  359.             VtSetSensitive $RegisterBtn 0
  360.             UiToolBarSetSensitive register 0
  361.         }
  362.     }
  363. }
  364. proc UiStart {} {
  365.     global appvals
  366.     set HELPBOOK licenseMgr
  367.     set vtApp [VtOpen $appvals(client) $HELPBOOK]
  368.     set appvals(vtApp) $vtApp 
  369.     VtSetAppValues $vtApp \
  370.                 -versionString "$appvals(title) $appvals(version)" \
  371.                 -errorCallback {SaUnexpectedErrorCB {}}
  372.     if {$appvals(openhost)} {
  373.         set title \
  374.     "$appvals(title) [IntlMsg ON] [SaHostExtractSystemName $appvals(managedhost)]"
  375.     } else {
  376.         set title "$appvals(title)"
  377.     }
  378.     set vtMain [VtFormDialog $vtApp.main \
  379.                     -title $title \
  380.                     -wmShadowThickness 0 \
  381.                     -wmCloseCallback UiCloseCB] 
  382.     set appvals(vtMain) $vtMain
  383.     VxSetVar appvals(vtMain) vtMain $vtMain
  384.     UiDefaultFormSpacingSet $vtMain
  385.     SaCharmSetMaxFormDimensions $vtMain
  386.     set menuBar [UiBuildMenus $vtMain]
  387.     VxSetVar $appvals(vtMain) menuBar $menuBar
  388.     if {! [VtInfo -charm]} {
  389.         if {$appvals(toolbar)} {
  390.             set toolbar [UiBuildToolBar $vtMain $menuBar]
  391.         }
  392.     }
  393.     set mainlabel [VtLabel $vtMain.mainlabel \
  394.         -label "$appvals(title) [IntlMsg ON] $appvals(managedhost)"]
  395.     VxSetVar $appvals(vtMain) mainlabel $mainlabel
  396.     if { [VtInfo -charm]} {
  397.         set header [VtLabel $vtMain.header \
  398.                     -topOffset 1 \
  399.                     -labelLeft \
  400.                     -leftSide FORM \
  401.                     -rightSide FORM \
  402.                     -bottomSide NONE \
  403.                     -label "" ]
  404.         VxSetVar $appvals(vtMain) header $header
  405.     }
  406.     set vtSub [VtForm $vtMain.sub \
  407.                 -MOTIF_leftOffset 5 \
  408.                 -MOTIF_rightOffset 5 \
  409.                 -rightSide FORM ]
  410.     UiDefaultFormSpacingSet $vtSub
  411.     set form $vtSub
  412.     set cmd [list BuildMainList $form ]
  413.     set mainList [eval $cmd]
  414.     UiWidgetSet mainList $mainList
  415.     set countLabel [VtLabel $form.countLabel -label " " \
  416.                         -topSide NONE \
  417.                         -leftSide FORM \
  418.                         -rightSide FORM \
  419.                         -bottomSide FORM \
  420.                         -labelRight 
  421.                     ]
  422.     UiWidgetSet countLabel $countLabel
  423.     VtSetValues $mainList -bottomSide $countLabel
  424.     VxSetVar $countLabel selected [IntlMsg SELECTED]
  425.     set logofile {}
  426.     if {[lempty $logofile]} {
  427.         set statusBar [SaStatusBar $vtMain.statusBar 1]
  428.     } else {
  429.         set statusBar [SaStatusBar $vtMain.statusBar 1 $logofile]
  430.     }
  431.     VxSetVar $appvals(vtMain) statusBar $statusBar
  432.     VtSetValues $form -bottomSide $statusBar
  433.     VtShow $vtMain
  434.     VtLock
  435. }
  436. proc UiStop {cb} {
  437.     global appvals
  438.     if {$appvals(autorefresh)} {
  439.         SaAutoRefreshPause
  440.     }
  441.     set vtMain $appvals(vtMain)
  442.     set client $appvals(client)
  443.     set cmd [list SaShortHelpStore $client]
  444.     if {[ErrorCatch errorStack 0 $cmd dummy] != 0 } {
  445.         lappend errorStacks $errorStack
  446.     }
  447.     if {$appvals(autorefresh)} {
  448.         set cmd [list SaAutoRefreshStore $client]
  449.         if {[ErrorCatch errorStack 0 $cmd dummy] != 0 } {
  450.             lappend errorStacks $errorStack
  451.         }
  452.     }
  453.     if {$appvals(toolbarcust)} {
  454.         set cmd {UiToolBarStore}
  455.         if {[ErrorCatch errorStack 0 $cmd dummy] != 0 } {
  456.             lappend errorStacks $errorStack
  457.         }
  458.     }
  459.     if [info exists errorStacks] {
  460.         SaDisplayErrorStacks $vtMain.UIStop $errorStacks {} \
  461.             [list UiStop2 $cb]
  462.         VtUnLock
  463.         VtMainLoop
  464.     } else {
  465.         VtUnLock
  466.         VtClose
  467.         eval $cb
  468.     }
  469. }
  470. proc UiStop2 {cb {cbs {}}} {
  471.     VtUnLock
  472.     VtClose
  473.     eval $cb
  474. }
  475. proc UiAddBtnCB {cbs} {
  476.     global appvals
  477.     set parent [keylget cbs dialog]
  478.     set addWid [CreateAddLicenseWindow $parent ]
  479.     set extentLabel [VxGetVar $addWid extentLabel]
  480.     set extentText [VxGetVar $addWid extentText]
  481.     VtHide $extentLabel
  482.     VtHide $extentText
  483.     VtShow $addWid 
  484.     VtSetFocus [VxGetVar $addWid serNumText]
  485.     VtUnLock
  486. }
  487. proc CreateAddLicenseWindow { parent } {
  488.     global appvals productNames
  489.     set title [IntlMsg LICENSE_ADD_WIN_TITLE $appvals(managedhost)]
  490.     set addWid [VtFormDialog $parent.addWid \
  491.                     -title $title \
  492.                     -ok -okLabel [IntlMsg LICENSE_LABEL] \
  493.                     -okCallback UiAddBtnOkCB \
  494.                     -cancel -cancelCallback VxEndFormCB \
  495.                     -cancelButton CANCEL \
  496.                     -help \
  497.                 ]
  498.     VxSetVar $parent addWid $addWid
  499.     set instructLabel    [VtLabel $addWid.instructLabel \
  500.                             -label [IntlMsg LICENSE_ADD_INSTRUCTION] \
  501.                             -labelLeft \
  502.                             -CHARM_topOffset 1 -CHARM_leftOffset 2 \
  503.                         ]
  504.     set alignFrame     [VtForm $addWid.alignFrame \
  505.                         -rightSide FORM -leftSide FORM \
  506.                         -alignLeft $instructLabel \
  507.                         -bottomSide FORM \
  508.                       ]
  509.     set serNumLabel [VtLabel $alignFrame.serNumLabel \
  510.                         -label [IntlMsg SERIAL_NUMBER_LABEL] \
  511.                         -topSide FORM \
  512.                     ]
  513.     set serNumText    [VtText $alignFrame.serNumText \
  514.                         -leftSide $serNumLabel \
  515.                         -rightSide FORM \
  516.                         -alignTop $serNumLabel \
  517.                         -callback serNumWidCB \
  518.                     ]
  519.     set actKeyLabel    [VtLabel $alignFrame.actKeyLabel \
  520.                         -label [IntlMsg ACTION_KEY_LABEL] \
  521.                     ]
  522.     set actKeyText    [VtText $alignFrame.actKeyText \
  523.                         -leftSide $actKeyLabel \
  524.                         -rightSide FORM \
  525.                         -alignLeft $serNumText \
  526.                         -alignTop $actKeyLabel \
  527.                         -callback actKeyWidCB \
  528.                         -losingFocusCallback UiSNLosingFocusCB \
  529.                     ]
  530.     set extentLabel    [VtLabel $alignFrame.extentLabel \
  531.                         -label [IntlMsg EXTENTION_LABEL] \
  532.                         -bottomSide FORM \
  533.                     ]
  534.     set extentText    [VtText $alignFrame.extentText \
  535.                         -leftSide $extentLabel \
  536.                         -rightSide FORM \
  537.                         -alignLeft $actKeyText \
  538.                         -alignTop $extentLabel\
  539.                         -bottomSide    FORM \
  540.                         -callback extentWidCB \
  541.                     ]
  542.     VxSetVar $addWid instructLabel $instructLabel
  543.     VxSetVar $addWid alignFrame $alignFrame
  544.     VxSetVar $addWid serNumLabel $serNumLabel
  545.     VxSetVar $addWid serNumText $serNumText
  546.     VxSetVar $addWid actKeyLabel $actKeyLabel
  547.     VxSetVar $addWid actKeyText $actKeyText
  548.     VxSetVar $addWid extentLabel $extentLabel
  549.     VxSetVar $addWid extentText $extentText
  550.     return $addWid
  551. }
  552. proc UiSNLosingFocusCB { cbs } {
  553.     global appvals
  554.     set addWid [keylget cbs dialog]
  555.     set widget [keylget cbs widget]
  556.     set textContent [VtGetValues $widget -value]
  557.     set serNum [VtGetValues [VxGetVar $addWid serNumText] -value]
  558.     set actKey [VtGetValues [VxGetVar $addWid actKeyText] -value]
  559.     if { [ExtensionRequired $serNum $actKey] } {
  560.         VtShow [VxGetVar $addWid extentLabel]
  561.         VtShow [VxGetVar $addWid extentText]
  562.         VtSetFocus [VxGetVar $addWid extentText]
  563.     }
  564.     if { [ErrorCatch errStack 0 {GetLicenseId $serNum $actKey} \
  565.                 result] } {
  566.         SaDisplayErrorStacks $addWid.error [list $errorStack] NOHELP
  567.         return
  568.     }
  569.     VtUnLock
  570. }
  571. proc UiAddBtnOkCB { cbs } {
  572.     global appvals   
  573.     set parent $appvals(vtMain)
  574.     set mainList [VxGetVar $appvals(vtMain) mainList]
  575.     set addWid [keylget cbs dialog]
  576.     set serNum [VtGetValues [VxGetVar $addWid serNumText] -value]
  577.     set actKey [VtGetValues [VxGetVar $addWid actKeyText] -value]
  578.     set extent {}
  579.     set lenBefore [llength [VtDrawnListGetItem [VxGetVar $parent mainList] -all]]
  580.     if { [lempty $serNum] } {
  581.         set message [IntlMsg SPECIFY_LICENSE_NUMBER]
  582.         UiShowErrorDialog $addWid serNum $message
  583.         VtSetFocus [VxGetVar $addWid serNumText]
  584.         return
  585.     }
  586.     if { [lempty $actKey] } {
  587.         set message [IntlMsg SPECIFY_LICENSE_CODE]
  588.         UiShowErrorDialog $addWid actKey $message
  589.         VtSetFocus [VxGetVar $addWid actKeyText]
  590.         return
  591.     }
  592.     if { [ErrorCatch errStack 0 {GetLicenseId $serNum $actKey} \
  593.                 result] } {
  594.         SaDisplayErrorStacks $addWid.error [list $errorStack] NOHELP
  595.         return
  596.     }
  597.     if { [ExtensionRequired $serNum $actKey] }  {
  598.         set extent [VtGetValues [VxGetVar $addWid extentText] -value]
  599.         if { [lempty $extent] } {
  600.             set message [IntlMsg SPECIFY_LICENSE_DATA]
  601.             UiShowErrorDialog $addWid extentWid $message
  602.             return
  603.         }
  604.     }
  605.     set licenseId [lindex $result 0]
  606.     if { ![ErrorCatch errStack 0 {AddLicense $serNum $actKey $extent } \
  607.                 ret] } {
  608.         if { [ErrorCatch errStack 0 {KillIfor_pmd} ret]} {
  609.             SaDisplayErrorStacks $addWid.error [list $errStack] HELP
  610.             return
  611.         }
  612.         VtDestroyDialog $addWid
  613.         set items [BrowserGetData]
  614.         set count 0
  615.         foreach item $items {
  616.             incr count
  617.             if { [lsearch $item $serNum]  != -1 } {
  618.                 break
  619.             }
  620.         }
  621.         UiListSetItems $mainList $items
  622.         set lenAfter [llength [VtDrawnListGetItem [VxGetVar $parent mainList] -all]]
  623.            if { ![ lempty $items] } {
  624.             VtDrawnListSelectItem $mainList -position $count
  625.         }
  626.         if { $lenBefore == $lenAfter } {
  627.             VtShow [VtInformationDialog $parent.inform \
  628.                         -message [IntlMsg LICENSE_ADD_DUPLICATE [list $serNum] ] \
  629.                         -ok \
  630.                     ]
  631.             VtUnLock
  632.             return
  633.         } else {
  634.             set selectedItem  [UiListGetSelectedItem]
  635.             set product [lindex $selectedItem $appvals(nameListIndex)]
  636.             VtShow [VtInformationDialog $parent.inform \
  637.                         -message [IntlMsg LICENSE_ADD_COMPLETE [list $product] ] \
  638.                         -ok \
  639.                     ]
  640.             VtUnLock
  641.             return
  642.         }
  643.     } else {
  644.         set retCode  [lindex [lindex $errStack end] end]
  645.         ErrorPush newStack 0 [GetBrandErrorMessage $retCode]
  646.         ErrorPush newStack 0 [IntlErrId CMD_BRAND_ADD_UNABLE] 
  647.         SaDisplayErrorStacks $addWid.addLicError [list $newStack] NOHELP
  648.         VtSetFocus [VxGetVar $addWid extentText]
  649.         return
  650.     }
  651.     VtUnLock
  652. }
  653. proc UiShowExtentWid { cbs } {
  654.     global appvals
  655.     set extentText [VxGetVar [UiWidgetGet addWid] extentText]
  656.     set extentLabel [VxGetVar [UiWidgetGet addWid] extentLabel]
  657.     VtShow $extentLabel
  658.     VtShow $extentText
  659.     VtSetFocus $extentText 
  660.     VtUnLock
  661. }
  662. proc serNumWidCB { cbs } {
  663.     global appvals
  664.     set dialog [keylget cbs dialog]
  665.     set widget [keylget cbs widget]
  666.     set textContent [VtGetValues $widget -value]
  667.     if { [lempty $textContent] } {
  668.         set message [IntlMsg SPECIFY_LICENSE_NUMBER]
  669.         UiShowErrorDialog $dialog serNumWid $message
  670.         VtSetFocus $widget
  671.         return
  672.     } else {
  673.         UiSetFocusNextTabGroup $cbs
  674.     }
  675. }; # serNumWidCB
  676. proc actKeyWidCB { cbs } {
  677.     global appvals
  678.     set dialog [keylget cbs dialog]
  679.     set widget [keylget cbs widget]
  680.     set textContent [VtGetValues $widget -value]
  681.     if { [lempty $textContent] } {
  682.         set message [IntlMsg SPECIFY_LICENSE_CODE]
  683.         UiShowErrorDialog $dialog actKeyWid $message
  684.         VtSetFocus $widget
  685.         return
  686.     } else {
  687.         UiSetFocusNextTabGroup $cbs
  688.     }
  689. }; # actKeyWidCB
  690. proc extentWidCB { cbs } {
  691.     global appvals
  692.     set dialog [keylget cbs dialog]
  693.     set widget [keylget cbs widget]
  694.     set textContent [VtGetValues $widget -value]
  695.     if { [lempty $textContent] } {
  696.         set message [IntlMsg SPECIFY_LICENSE_DATA]
  697.         UiShowErrorDialog $dialog extentWid $message
  698.         VtSetFocus $widget
  699.         return
  700.     } else {
  701.         set btn [VtGetValues $dialog -ok]
  702.         VtSetFocus $btn
  703.     }
  704.     VtUnLock
  705. }; # extentWidCB
  706. proc UiRemoveBtnCB {cbs} {
  707.     global appvals
  708.     set parent [keylget cbs dialog]
  709.     set removeWid [CreateRemoveWindow $parent]
  710.     VtShow $removeWid
  711.     VtSetFocus [VtGetValues $removeWid -cancel]
  712.     VtUnLock
  713. }
  714. proc CreateRemoveWindow { parent } {
  715.     global appvals
  716.     set selectedItem [UiListGetSelectedItem]
  717.     set serNum [lindex $selectedItem $appvals(serNumListIndex)]
  718.     set product [lindex $selectedItem $appvals(nameListIndex)]
  719.     set title [IntlMsg LICENSE_REMOVE_WIN_TITLE $appvals(managedhost)]
  720.     set message [IntlMsg LICENSE_REMOVE_WARNING [list $product] ]
  721.     set removeWid     [VtWarningDialog $parent.removeWid \
  722.                         -title $title \
  723.                         -message $message \
  724.                         -ok \
  725.                         -okCallback [list \
  726.                             UiRemoveBtnOkCB $serNum $product ] \
  727.                         -cancel \
  728.                         -cancelButton CANCEL \
  729.                         -help \
  730.                     ]
  731.     VxSetVar $parent removeWid $removeWid 
  732.     return $removeWid
  733. }
  734. proc UiRemoveBtnOkCB { serialNum productName cbs } {
  735.     global appvals
  736.     set parent $appvals(vtMain)
  737.     if { [ErrorCatch errStack 0 \
  738.             {RemoveLicenseFromNodelockFile $serialNum} ret] } {
  739.         SaDisplayErrorStacks $parent.RemoveLicense [list $errStack] NOHELP
  740.         VtUnLock
  741.         return
  742.     }
  743.     if { [ErrorCatch errStack 0 {KillIfor_pmd} ret]} {
  744.         SaDisplayErrorStacks $parent.error [list $errStack] HELP
  745.         return
  746.     }
  747.     VtShow [VtMessageDialog $parent.complete \
  748.                 -message [IntlMsg LICENSE_REMOVE_COMPLETE [list $productName] ] \
  749.                 -ok \
  750.             ]
  751.     UiRefreshCB    
  752.     VtUnLock
  753. }
  754. proc UiRegisterBtnCB {cbs} {
  755.     global appvals
  756.     set parent $appvals(vtMain)
  757.     set selectedItem [UiListGetSelectedItem]
  758.     set serialNumber [lindex $selectedItem  $appvals(serNumListIndex)]
  759.     set productName [lindex $selectedItem  $appvals(nameListIndex)]
  760.     set registerWid [CreateRegisterWindow $parent $serialNumber $productName]
  761.     VtShow $registerWid
  762.     VtSetFocus [VxGetVar $registerWid regIdWid]
  763.     VtUnLock
  764. }; # UiRegisterBtnCB
  765. proc CreateRegisterWindow { parent serialNumber productName } {
  766.     global appvals
  767.     if { ![ErrorCatch errStack 0 { GetInstallId} return]} {
  768.         set installId $return
  769.         set retString "N/A"
  770.         if { [string first $retString $installId ] != -1} {
  771.                 set installId [IntlMsg  REGISTER_INSTALL_ID_NOT_APPLIED]
  772.         }
  773.     } else {
  774.         set installId {}
  775.     }
  776.     set title [IntlMsg LICENSE_REGISTER_WIN_TITLE $appvals(managedhost)]
  777.     set registerWid [VtFormDialog $parent.registerWid \
  778.                         -title $title \
  779.                         -ok \
  780.                         -okCallback [list RegisterLicenseOkCB $serialNumber $productName] \
  781.                         -cancel -cancelCallback VxEndFormCB \
  782.                         -cancelButton CANCEL \
  783.                         -autoLock [list RegisterLicenseOkCB DestroyDialogCB] \
  784.                         -defaultButton OK \
  785.                         -help \
  786.                     ]
  787.     VxSetVar $parent registerWid $registerWid
  788.     set instLabelA [VtLabel $registerWid.instLabelA \
  789.                         -label [IntlMsg LICENSE_REGISTER_INSTRUCT_A] \
  790.                         -labelLeft \
  791.                         -CHARM_topOffset 1 \
  792.                         -CHARM_leftOffset 1 \
  793.                     ]
  794.     set productFrame [VtFrame $registerWid.productframe \
  795.                         -rightSide FORM \
  796.                         -shadowType IN]
  797.     set nameLabel [VtLabel $productFrame.nameLabel \
  798.                         -label $productName -labelLeft \
  799.                         -CHARM_leftOffset 1 ]
  800.     set instLabelB [VtLabel $registerWid.instLabelB \
  801.                         -label [IntlMsg LICENSE_REGISTER_INSTRUCT_B] \
  802.                         -labelLeft \
  803.                         -MOTIF_topOffset 15 -CHARM_topOffset 1 \
  804.                         -CHARM_leftOffset 1 -topSide $productFrame]
  805.     set  frameWid [VtFrame $registerWid.frame -rightSide FORM \
  806.                            -MOTIF_topOffset 15 \
  807.                         -CHARM_topOffset 1 -topSide $instLabelB]
  808.       set infoForm [VtForm $frameWid.form -rightSide FORM]
  809.     UiDefaultFormSpacingSet $infoForm
  810.     set maxWidth 0
  811.     set serNumForm    [VtForm $infoForm.serNumForm    -rightSide FORM]
  812.     set installIdForm [VtForm $infoForm.installIdForm -rightSide FORM]
  813.     UiDefaultFormSpacingSet $serNumForm
  814.     UiDefaultFormSpacingSet $installIdForm
  815.     set serNumLabel [VtLabel $serNumForm.serialNumberLabel \
  816.                          -label [IntlMsg REGISTER_LICENSE_NUMBER] \
  817.                         -bottomSide FORM -leftOffset 0]
  818.     set serialNumWid [VtLabel $serNumForm.serialNumberVal \
  819.                         -leftSide $serNumLabel \
  820.                         -label $serialNumber -topSide FORM]
  821.     set width [VtGetValues $serNumLabel -width]
  822.     if {$width > $maxWidth} {
  823.         set maxWidth $width
  824.     }
  825.     set installIdLabel [VtLabel $installIdForm.installIdLabel \
  826.             -label [IntlMsg REGISTER_INSTALL_ID] \
  827.             -bottomSide FORM -leftOffset 0]
  828.     set installIdWid [VtLabel $installIdForm.installIdVal \
  829.             -leftSide $installIdLabel \
  830.             -label $installId -topSide FORM]
  831.     set width [VtGetValues $installIdLabel -width]
  832.     if {$width > $maxWidth} {
  833.         set maxWidth $width
  834.     }
  835.     set labelList [list $serNumLabel $installIdLabel]
  836.     set formList  [list $serNumForm $installIdForm]
  837.     UiAlignLabels $maxWidth $labelList $formList
  838.     set regForm [VtForm $registerWid.regForm -rightSide FORM \
  839.                         -MOTIF_topOffset 15 -CHARM_topOffset 1]
  840.     UiDefaultFormSpacingSet $regForm
  841.     set regIdLabel [VtLabel $regForm.regIdLabel \
  842.                         -label [IntlMsg REGISTER_LICENSE_KEY] \
  843.                         -labelLeft -CHARM_leftOffset 1 -bottomSide FORM]
  844.     set regIdWid [VtText $regForm.regIdText \
  845.                         -callback [list UiSetFocusNextTabGroup ] \
  846.                         -leftSide $regIdLabel \
  847.                         -rightSide FORM -topSide FORM -bottomSide FORM]
  848.     VxSetVar $registerWid regIdWid $regIdWid
  849.     if { [VtInfo -charm] } {
  850.          VtLabel $registerWid.space -label " "
  851.      }
  852.     return $registerWid 
  853. }; # CreateRegisterWindow
  854. proc RegisterLicenseOkCB { serialNumber productName cbs } {
  855.     global appvals
  856.     set parent [keylget cbs dialog]
  857.     set regIdWid [VxGetVar $parent regIdWid]
  858.     set registrationId [VtGetValues $regIdWid -value]
  859.     if [lempty $registrationId] {
  860.         set message [IntlMsg SPECIFY_REGISTRATION_KEY]
  861.         UiShowErrorDialog $parent specifyLicKey $message  
  862.         VtSetFocus $regIdWid
  863.         VtUnLock    
  864.         return
  865.     }    
  866.     if {[ErrorCatch errorStack 0 \
  867.             {RegisterLicense $serialNumber $registrationId} result] != 0} {
  868.         SaDisplayErrorStacks $parent.registerLicenseError [list $errorStack] HELP
  869.         VtSetFocus $regIdWid
  870.         VtUnLock
  871.         return
  872.     } 
  873.     VtDestroyDialog $parent
  874.     set message [IntlMsg LICENSE_REGISTER_COMPLETE [list $productName]]
  875.     VtShow [VtMessageDialog $appvals(vtMain).complete \
  876.                 -message $message \
  877.                 -ok \
  878.             ]
  879.      set state [IntlMsg YES_LABEL]
  880.      UiUpdateMainList $appvals(registerListIndex) $state
  881.     UiSensitizeFunctions
  882.     VtUnLock
  883. }
  884. proc UiUpdateMainList { positionIndex state } {
  885.     global appvals
  886.     set mainList [VxGetVar $appvals(vtMain) mainList]
  887.     set position [VtDrawnListGetSelectedItem $mainList -byPositionList]
  888.      set selectedItem  [UiListGetSelectedItem]
  889.     set index $positionIndex
  890.     set selectedItem [lreplace $selectedItem $index $index $state] 
  891.     VtDrawnListSetItem $mainList -position $position -fieldList $selectedItem    
  892. }
  893. proc UiViewAllBtnCB {cbs} {
  894.     global appvals
  895.     set widget [keylget cbs widget]
  896.     VtSetValues [VxGetVar [UiWidgetGet menuBar] ViewAllBtn] -value 1 
  897.     VtSetValues [VxGetVar [UiWidgetGet menuBar] ExpiredBtn] -value 0
  898.     VtSetValues [VxGetVar [UiWidgetGet menuBar] NotRegtBtn] -value 0
  899.     UiRefreshCB
  900.     VtUnLock
  901. }; # UiViewAllBtnCB
  902. proc UiViewExpiredBtnCB {cbs} {
  903.     global appvals
  904.     set dialog [keylget cbs dialog]
  905.     set widget [keylget cbs widget]
  906.     VtSetValues [VxGetVar [UiWidgetGet menuBar] ExpiredBtn] -value 1 
  907.     VtSetValues [VxGetVar [UiWidgetGet menuBar] ViewAllBtn] -value 0
  908.     VtSetValues [VxGetVar [UiWidgetGet menuBar] NotRegtBtn] -value 0
  909.     if { ![ErrorCatch errStack 0 {BrowserGetData} ret] } {
  910.         set licenseList $ret
  911.     } else {
  912.         UiDisplayErrorStacks BrowserData  $errStack ErrExitCB
  913.         return
  914.     }
  915.     set newList ""
  916.     foreach item $licenseList {
  917.         set stringValue [lindex $item 3]
  918.         if { [lsearch $stringValue [IntlMsg EXPIRED_LABEL] ] != -1 } {
  919.             lappend newList $item
  920.         }
  921.     }
  922.     UiListSaveSelectedItems [VxGetVar $dialog mainList]
  923.     UiMainListSetItems $newList
  924.     UiListRestoreSelectedItems [VxGetVar $dialog mainList]
  925.     UiUpdateCountLabel
  926.     UiSetAppFocus
  927.     UiSensitizeFunctions
  928.     VtUnLock
  929. }
  930. proc UiViewNotRegtBtnCB {cbs} {
  931.     global appvals
  932.     set dialog [keylget cbs dialog]
  933.     set widget [keylget cbs widget]
  934.     VtSetValues [VxGetVar [UiWidgetGet menuBar] NotRegtBtn] -value 1 
  935.     VtSetValues [VxGetVar [UiWidgetGet menuBar] ViewAllBtn] -value 0
  936.     VtSetValues [VxGetVar [UiWidgetGet menuBar] ExpiredBtn] -value 0
  937.     set newList {}
  938.     if { ![ErrorCatch errStack 0 {BrowserGetData} ret] } {
  939.         set licenseList $ret
  940.     } else {
  941.         UiDisplayErrorStacks BrowserData  $errStack ErrExitCB
  942.         return
  943.     }
  944.     foreach item $licenseList {
  945.         set stringValue [lindex $item 2]
  946.         if { [lsearch $stringValue [IntlMsg NO_LABEL] ] != -1 } {
  947.             lappend newList $item
  948.         }
  949.     }
  950.     UiListSaveSelectedItems [VxGetVar $dialog mainList]
  951.     UiMainListSetItems $newList
  952.     UiListRestoreSelectedItems [VxGetVar $dialog mainList]
  953.     UiUpdateCountLabel
  954.     UiSetAppFocus
  955.     UiSensitizeFunctions
  956. }
  957. proc ViewAllBtnGetState { } {
  958.     global appvals
  959.     return $appvals(ViewAllBtnState)
  960. }
  961. proc ExpiredBtnGetState { } {
  962.     global appvals
  963.     return $appvals(ExpiredBtnState) 
  964. }
  965. proc NotRegtBtnGetState { } {
  966.     global appvals
  967.     return $appvals(NotRegtBtnState)
  968. }
  969. proc UiBuildMenus {form} {
  970.     global appvals
  971.     set menuBar [VtMenuBar $form.menuBar \
  972.             -helpMenuItemList [SaHelpGetOptionsList]]
  973.     VxSetVar $form menuBar $menuBar
  974.     set openhost $appvals(openhost)
  975.     if {$openhost} {
  976.         UiBuildHostMenu $menuBar
  977.     }
  978.     UiBuildObjectMenu $menuBar
  979.     UiBuildViewMenu $menuBar
  980.     UiBuildOptionsMenu $menuBar
  981.     return $menuBar
  982. }
  983. proc UiBuildHostMenu {parent} {
  984.     global appvals
  985.     set hostMenu [VtPulldown $parent.hostMenu \
  986.             -label [IntlMsg HOST] \
  987.             -mnemonic [IntlMsg HOST_MN] \
  988.             ]
  989.     VxSetVar $parent hostMenu $hostMenu
  990.     VtPushButton $hostMenu.openhost \
  991.         -label [IntlMsg OPENHOST] \
  992.         -mnemonic [IntlMsg OPENHOST_MN]  \
  993.         -acceleratorString [IntlMsg OPENHOST_ACCSTR] \
  994.         -accelerator [IntlMsg OPENHOST_ACC] \
  995.         -shortHelpCallback SaShortHelpCB \
  996.         -shortHelpString  [IntlMsg OPENHOST_SH \
  997.                   [list $appvals(itemname)]] \
  998.         -callback SaOpenHostCB  \
  999.         -autoLock SaOpenHostCB
  1000.     VtSeparator $hostMenu.s1
  1001.     set exitMenu $hostMenu
  1002.     VtPushButton $exitMenu.exit \
  1003.         -label [IntlMsg EXIT] \
  1004.         -mnemonic [IntlMsg EXIT_MN]  \
  1005.         -shortHelpCallback SaShortHelpCB \
  1006.         -shortHelpString  [IntlMsg EXIT_SH [list $appvals(title)]] \
  1007.         -callback UiCloseCB  \
  1008.         -autoLock UiCloseCB
  1009. }
  1010. proc UiBuildObjectMenu {parent} {
  1011.     global appvals
  1012.         set label $appvals(object) 
  1013.         set mnemonic $appvals(objectmn) 
  1014.         set fileMenu [VtPulldown $parent.fileMenu \
  1015.                 -label $label \
  1016.                 -mnemonic $mnemonic \
  1017.                 ]
  1018.         VxSetVar $parent fileMenu $fileMenu
  1019.         set AddBtn [VtPushButton $fileMenu.AddBtn \
  1020.             -label [IntlMsg LIC_ADD] \
  1021.             -mnemonic [IntlMsg LIC_ADD_MN]  \
  1022.             -shortHelpCallback SaShortHelpCB \
  1023.             -shortHelpString  [IntlMsg LIC_ADD_SH] \
  1024.             -callback UiAddBtnCB  \
  1025.             -autoLock UiAddBtnCB]
  1026.         VxSetVar $parent AddBtn $AddBtn 
  1027.         VtSeparator $fileMenu.s1
  1028.         set RegisterBtn [VtPushButton $fileMenu.RegisterBtn \
  1029.             -label [IntlMsg REGISTER] \
  1030.             -mnemonic [IntlMsg REGISTER_MN]  \
  1031.             -shortHelpCallback SaShortHelpCB \
  1032.             -shortHelpString  [IntlMsg REGISTER_SH] \
  1033.             -callback UiRegisterBtnCB  \
  1034.             -autoLock UiRegisterBtnCB \
  1035.             ]
  1036.         VxSetVar $parent RegisterBtn $RegisterBtn 
  1037.         VtSeparator $fileMenu.s2
  1038.         set RemoveBtn [VtPushButton $fileMenu.RemoveBtn \
  1039.             -label [IntlMsg LIC_REMOVE] \
  1040.             -mnemonic [IntlMsg LIC_REMOVE_MN]  \
  1041.             -shortHelpCallback SaShortHelpCB \
  1042.             -shortHelpString  [IntlMsg LIC_REMOVE_SH] \
  1043.             -callback UiRemoveBtnCB  \
  1044.             ]
  1045.         VxSetVar $parent RemoveBtn $RemoveBtn
  1046.         if {! $appvals(openhost)} {
  1047.             VtSeparator $fileMenu.s2
  1048.             set exitMenu $fileMenu
  1049.             VtPushButton $exitMenu.exit \
  1050.                 -label [IntlMsg EXIT] \
  1051.                 -mnemonic [IntlMsg EXIT_MN]  \
  1052.                 -shortHelpCallback SaShortHelpCB \
  1053.                 -shortHelpString  [IntlMsg EXIT_SH [list $appvals(title)]] \
  1054.                 -callback UiCloseCB  \
  1055.                 -autoLock UiCloseCB
  1056.         }
  1057. }
  1058. proc UiBuildOptionsMenu {form} {
  1059.     global appvals 
  1060.     set optionMenu [VtPulldown $form.optionMenu \
  1061.         -label  [IntlMsg OPTIONS] \
  1062.         -mnemonic [IntlMsg OPTIONS_MN] \
  1063.         ] 
  1064.     SaShortHelpLoad $appvals(client)
  1065.     SaShortHelpMenuOptions $optionMenu
  1066.     if {$appvals(toolbar)} {
  1067.         UiToolBarBuildMenuOptions $optionMenu
  1068.     }
  1069.     VxSetVar $form optionMenu $optionMenu
  1070.     return $optionMenu
  1071. }
  1072. proc UiBuildViewMenu {form} {
  1073.     global appvals 
  1074.     set viewMenu [VtPulldown $form.viewMenu \
  1075.         -label  [IntlMsg VIEW] \
  1076.         -mnemonic [IntlMsg VIEW_MN] \
  1077.         ] 
  1078.     VxSetVar $form viewMenu $viewMenu
  1079.     set ViewAllBtn [VtToggleButton $viewMenu.ViewAllBtn \
  1080.         -label [IntlMsg VIEW_ALL] \
  1081.         -callback UiViewAllBtnCB \
  1082.         -value [ViewAllBtnGetState] \
  1083.         -mnemonic [IntlMsg VIEW_ALL_MN]  \
  1084.         -shortHelpCallback SaShortHelpCB \
  1085.         -shortHelpString  [IntlMsg VIEW_ALL_SH] \
  1086.         ]
  1087.     VxSetVar $form ViewAllBtn $ViewAllBtn
  1088.      VtSeparator $viewMenu.s1
  1089.     set ExpiredBtn [VtToggleButton $viewMenu.ExpiredBtn \
  1090.         -label [IntlMsg VIEW_EXPIRED] \
  1091.         -mnemonic [IntlMsg VIEW_EXPIRED_MN]  \
  1092.         -shortHelpCallback SaShortHelpCB \
  1093.         -shortHelpString  [IntlMsg VIEW_EXPIRED_SH] \
  1094.         -callback UiViewExpiredBtnCB \
  1095.         -value [ExpiredBtnGetState] ] 
  1096.     VxSetVar $form ExpiredBtn $ExpiredBtn
  1097.     set NotRegtBtn [VtToggleButton $viewMenu.NotRegtBtn \
  1098.         -label [IntlMsg VIEW_NOTREGT ] \
  1099.         -mnemonic [IntlMsg VIEW_NOTREGT_MN]  \
  1100.         -shortHelpCallback SaShortHelpCB \
  1101.         -shortHelpString  [IntlMsg VIEW_NOTREGT_SH] \
  1102.         -callback UiViewNotRegtBtnCB \
  1103.         -value [NotRegtBtnGetState] ] 
  1104.     VxSetVar $form NotRegtBtn $NotRegtBtn 
  1105. }
  1106. set appvals(toolbarIcons) {}        ;# set of available icons
  1107. set appvals(toolbarCommands) {}        ;# set of available command definitions
  1108. set appvals(toolbarStandard) {}        ;# default toolbar (icon/command pairs)
  1109. proc UiToolBarStore {} {
  1110.     global appvals
  1111.     if {[VtInfo -charm] || ! $appvals(toolbar)} {
  1112.         return
  1113.     }
  1114.     SaToolbarGet visibility current frame
  1115.     if {$appvals(toolbarcust)} {
  1116.         SaToolbarStore     $appvals(client) visibility current frame 
  1117.     } else {
  1118.         SaToolbarStore     $appvals(client) visibility
  1119.     }
  1120. }
  1121. proc UiToolBarBuildMenuOptions {menu} {
  1122.     global appvals
  1123.     if {[VtInfo -charm]} {
  1124.         return
  1125.     }
  1126.     VtSeparator $menu.s1
  1127.     if {$appvals(toolbarcust)} {
  1128.         set opts {show custom}
  1129.     } else {
  1130.         set opts {show}
  1131.     }
  1132.     SaToolbarMenuOptions $menu $opts 
  1133. }
  1134. proc UiToolBarCustomizeCB {state cbs} {
  1135.     global appvals
  1136.     if {$appvals(autorefresh)} {
  1137.         if {$state} {
  1138.             SaAutoRefreshPause
  1139.         } else {
  1140.             SaAutoRefreshResume
  1141.         }
  1142.     }
  1143. }
  1144. proc UiToolBarResensitizeCB {keys cbs} {
  1145.     UiSensitizeFunctions
  1146. }
  1147. proc UiToolBarSetSensitive {button state} {
  1148.     SaToolbarButtonSetSensitive $button $state
  1149. }
  1150. proc UiBuildToolBar {form top} {
  1151.     global appvals
  1152.     set client $appvals(client)
  1153.     set frame IN
  1154.     set visibility 1
  1155.     set appvals(toolbarIcons) [list \
  1156.         [IntlMsg TB_OPENHOST] \
  1157.         [IntlMsg TB_ADD] \
  1158.         [IntlMsg TB_REGISTER] \
  1159.         [IntlMsg TB_DELETE] \
  1160.         ] 
  1161.     set appvals(toolbarCommands) [list \
  1162.         [list openhost SaOpenHostCB \
  1163.             [IntlMsg OPENHOST_SH [list $appvals(itemname)]]] \
  1164.         [list add UiAddBtnCB \
  1165.             [IntlMsg LIC_ADD_SH]] \
  1166.         [list register UiRegisterBtnCB \
  1167.             [IntlMsg REGISTER_SH]] \
  1168.         [list remove UiRemoveBtnCB \
  1169.             [IntlMsg LIC_REMOVE_SH]] \
  1170.         ]
  1171.     set standard {}
  1172.     if {$appvals(openhost)} {
  1173.         lappend standard {0 0}
  1174.         lappend standard {{} S}
  1175.     } 
  1176.     lappend standard {1 1}
  1177.     lappend standard {2 2}
  1178.     lappend standard {3 3}
  1179.     set appvals(toolbarStandard) $standard 
  1180.     set current $appvals(toolbarStandard)
  1181.     if {$appvals(toolbarcust)} {
  1182.         SaToolbarLoad $client visibility current frame
  1183.     } else {
  1184.         SaToolbarLoad $client visibility
  1185.     }    
  1186.     set toolbar \
  1187.         [SaToolbar     $form.toolbar $top \
  1188.                 $appvals(toolbarIcons) \
  1189.                 $appvals(toolbarCommands) \
  1190.                 $appvals(toolbarStandard) \
  1191.                 SaShortHelpCB \
  1192.                 $visibility \
  1193.                 $current \
  1194.                 $frame \
  1195.                 UiToolBarResensitizeCB \
  1196.                 UiToolBarCustomizeCB \
  1197.                 ]
  1198.     VxSetVar $appvals(vtMain) toolbar $toolbar
  1199.     return $toolbar
  1200. }
  1201. proc UiListSetItems {list items} {
  1202.     VtDrawnListDeleteItem $list -all
  1203.     VtDrawnListAddItem $list -recordList $items
  1204. }
  1205. proc UiListSaveSelectedItems {list} {
  1206.     set selected [VtDrawnListGetSelectedItem $list -byRecordList]
  1207.     VxSetVar $list selected $selected
  1208. }
  1209. proc UiListRestoreSelectedItems {list} {
  1210.     set selected [VxGetVar $list selected ]
  1211.     if {[lempty $selected]} {
  1212.         return
  1213.     }
  1214.     set items [VtDrawnListGetItem $list -all]
  1215.     set positions {}
  1216.     foreach item $selected {
  1217.         if {[set position [lsearch $items $item]] != -1} {
  1218.             incr position
  1219.             lappend positions $position
  1220.         }
  1221.     }
  1222.     if {![lempty $positions]} {
  1223.         VtDrawnListSelectItem $list -positionList $positions
  1224.     }
  1225. }
  1226. proc UiListGetSelectedItem { { list {} } } {
  1227.     global appvals
  1228.     if { [lempty $list] } {
  1229.         set list [VxGetVar $appvals(vtMain) mainList]
  1230.     }
  1231.     set selectedItem [VtDrawnListGetSelectedItem $list -byRecordList ]
  1232.     set content [lindex $selectedItem 0]
  1233.     return $content
  1234. }
  1235. proc GetInstanceList { names host} {
  1236.        set instanceList {}
  1237.        if { $host == "localhost" } {
  1238.            foreach name $names {
  1239.               set instance [list $name]
  1240.                lappend instanceList $instance
  1241.            }
  1242.        } else {
  1243.            foreach name $names {
  1244.                set instance [list [list systemId $host] [list $name]]
  1245.                lappend instanceList $instance
  1246.            }
  1247.        }
  1248.        return $instanceList
  1249. }
  1250. proc RunCmd {host cmd args errMsgId} {
  1251.        global appvals
  1252.     set class    [list sco remoteCommand]
  1253.        set instance [GetInstanceList NULL $appvals(managedhost)]
  1254.        set command [list ObjectAction $class $instance $cmd $args]
  1255.     VtLock
  1256.        set result [SaMakeObjectCall $command]
  1257.        VtUnLock
  1258.        set result [lindex $result 0]
  1259.     if { [BmipResponseErrorIsPresent result] } {
  1260.              set errorStack [BmipResponseErrorStack result]
  1261.             set topErrorCode [lindex [lindex $errorStack end ] end ]
  1262.             if { $topErrorCode == 8 } {
  1263.                 set retVal 8 
  1264.             } else {
  1265.                 ErrorPush errorStack 1  $errMsgId
  1266.                    return {}
  1267.             }
  1268.        } else {
  1269.         set retVal [BmipResponseActionInfo result]
  1270.     }
  1271.        return $retVal
  1272. }
  1273. proc RunCopy {host fileName list errMsgId} {
  1274.      global appvals
  1275.      set class    [list sco remoteCopy]
  1276.      set instance [GetInstanceList NULL $appvals(managedhost)]
  1277.      set command [list ObjectAction $class $instance $fileName $list]
  1278.      VtLock
  1279.       set result [SaMakeObjectCall $command]
  1280.      VtUnLock
  1281.      set result [lindex $result 0]
  1282.      if { [BmipResponseErrorIsPresent result] } {
  1283.          set errorStack [BmipResponseErrorStack result]
  1284.          ErrorPush errorStack 1 $errMsgId
  1285.          return {}
  1286.      }
  1287.      return 1
  1288. }
  1289. proc BrowserGetData { } {
  1290.     global appvals
  1291.     set host $appvals(managedhost)
  1292.     set cmd    $appvals(brandPath) 
  1293.     set args "-L"
  1294.     if { [ErrorCatch errStack 0 \
  1295.             {RunCmd $host $cmd $args [IntlErrId CMD_BRAND_LIST_UNABLE]} ret ]} {
  1296.         ErrorThrow errStack
  1297.         set licenseLists {} 
  1298.     } else {
  1299.         set licenses [lindex $ret 0]
  1300.         set licenseLists [SeparateLicenses $licenses]
  1301.         set licenseLists [FormatLicenseList $licenseLists]
  1302.     }        
  1303.     return $licenseLists
  1304. }; # BrowserGetData
  1305. proc SeparateLicenses { licenses } {
  1306.     global appvals productNames indexes
  1307.     set registeredLicenses     {}
  1308.     set addedLicenses         {}
  1309.     set notDisplayed        {}
  1310.     foreach product $licenses {
  1311.         lappend product {}
  1312.         set licenseId [lindex $product $indexes(LICENSE_ID)]
  1313.         set serialNum [lindex $product $indexes(SERIAL_NUMBER)]
  1314.         set name      [lindex $product $indexes(NAME)]
  1315.         if {$licenseId != "254"} {
  1316.             if {$licenseId == "255"} {
  1317.                 lappend registeredLicenses $product
  1318.             } elseif { [lempty $serialNum]} {
  1319.                 if {$name != $productNames(MPX) && \
  1320.                     $name != $productNames(MPX_ENT)} {
  1321.                     set index [FindProductInList $product $addedLicenses]
  1322.                     if {! [lempty $index]} {
  1323.                         set addedLicenses [UpdateAlternateLicenseId \
  1324.                         $product $addedLicenses $index]
  1325.                      } else {
  1326.                         lappend addedLicenses $product
  1327.                      }    
  1328.                  }
  1329.             } else {
  1330.                 lappend addedLicenses $product
  1331.             }
  1332.         }
  1333.     }
  1334.     return [list $addedLicenses $registeredLicenses $notDisplayed]
  1335. }
  1336. proc FindProductInList {product licenses} {
  1337.     global indexes
  1338.     set productName      [lindex $product $indexes(NAME)]
  1339.     set productVersion   [lindex $product $indexes(VERSION)]
  1340.     set index {}
  1341.     set cnt 0
  1342.     foreach license $licenses {
  1343.         set licProductName    [lindex $license $indexes(NAME)]
  1344.         set licProductVersion [lindex $license $indexes(VERSION)]
  1345.         if {$licProductName    == $productName && \
  1346.             $licProductVersion == $productVersion} {
  1347.             set index $cnt
  1348.             break
  1349.         }
  1350.         incr cnt
  1351.     }
  1352.     return $index
  1353. }; # FindProductInList
  1354. proc FormatLicenseList {licenses} {
  1355.     global appval indexes
  1356.     set addedLicenses      [lindex $licenses 0]
  1357.     set registeredLicenses [lindex $licenses 1]
  1358.     set key {}
  1359.     set formattedLicenses {}
  1360.     foreach license $addedLicenses {
  1361.         set description  [lindex $license $indexes(DESCRIPTION)]
  1362.         if [lempty $description] {
  1363.             set productId [lindex $license $indexes(LICENSE_ID)]
  1364.             set description [IntlMsg UNKNOWN_PRODUCT_NAME $productId] 
  1365.         }
  1366.         set serialNumber [lindex $license $indexes(SERIAL_NUMBER)]
  1367.         if [lempty $serialNumber] {
  1368.             set serialNumber " "
  1369.             set registered [IntlMsg NO_LABEL]
  1370.             set status [IntlMsg NO_LABEL]
  1371.         } else {
  1372.             set registered [GetRegistrationState $license $registeredLicenses]
  1373.             set status [GetLicenseState $license]
  1374.         }
  1375.         set item [list $description $serialNumber $registered $status\
  1376.            $license $key]
  1377.         lappend formattedLicenses $item
  1378.     }
  1379.     return $formattedLicenses
  1380. }; # FormatLicenseList
  1381. proc UpdateAlternateLicenseId {product licenses index} {
  1382.     global appvals indexes
  1383.     set productLicenseId      [lindex $product $indexes(LICENSE_ID)]
  1384.     set productLicenseVersion [lindex $product $indexes(LICENSE_VERSION)]
  1385.     set license [lindex $licenses $index]
  1386.     set alternateIdsIndex $indexes(ALTERNATE_IDS)
  1387.     set alternateIds [lindex $license $alternateIdsIndex]
  1388.     lappend alternateIds "$productLicenseId/$productLicenseVersion"
  1389.     set license [lreplace $license $alternateIdsIndex $alternateIdsIndex \
  1390.             $alternateIds]
  1391.     set licenses [lreplace $licenses $index $index $license]
  1392.     return $licenses
  1393. }; # UpdateAlternateLicenseId
  1394. proc GetRegistrationState {license registeredLicenses {returnBoolean 0}} {
  1395.     global appvals indexes
  1396.     set anotation [lindex $license $indexes(ANOTATION)]
  1397.     set anotationList [ParseAnotation $anotation]
  1398.     if {[AnotationFlagExists k $anotationList]} {
  1399.         set kvalue [SearchAnotationList k $anotationList]
  1400.         if {$kvalue == "0"} {
  1401.            if {$returnBoolean} {
  1402.                set state 0
  1403.            } else {
  1404.                set state [IntlMsg REGISTER_NOT_REQUIRED]
  1405.            }
  1406.         } else {
  1407.             set licenseId [ctoken kvalue /]
  1408.             set serialNum [ctoken kvalue /]
  1409.             if [IfRegistered $licenseId $serialNum $registeredLicenses] {
  1410.                if {$returnBoolean} {
  1411.                    set state 1
  1412.                } else {
  1413.                    set state [IntlMsg YES_LABEL]
  1414.                }
  1415.             } else {
  1416.                if {$returnBoolean} {
  1417.                    set state 2
  1418.                } else {
  1419.                    set state [IntlMsg NO_LABEL]
  1420.                }
  1421.             }
  1422.         }
  1423.     } else {
  1424.         if {$returnBoolean} {
  1425.            set state 0
  1426.         } else {
  1427.             set state [IntlMsg REGISTER_NOT_REQUIRED]
  1428.         }
  1429.     }
  1430.     return $state
  1431. }; # GetRegistrationState
  1432. proc ParseAnotation {anotation} {
  1433.     set anotationList {}
  1434.     while {! [lempty $anotation]} {
  1435.         set item [ctoken anotation ";"]
  1436.         lappend anotationList $item
  1437.     }
  1438.     return $anotationList
  1439. }; # ParseAnotation
  1440. proc SearchAnotationList {flag anotationList} {
  1441.     set value {}
  1442.     foreach item $anotationList {
  1443.         set flagChar [crange $item 0 0]
  1444.         if {$flagChar == $flag} {
  1445.             set value [crange $item 1 [expr [clength $item] - 1]]
  1446.             break;
  1447.         }
  1448.     }
  1449.     return $value
  1450. }; # SearchAnotationList
  1451. proc AnotationFlagExists {flag anotationList} {
  1452.     set found 0
  1453.     foreach item $anotationList {
  1454.         set flagChar [crange $item 0 0]
  1455.         if {$flagChar == $flag} {
  1456.             set found 1
  1457.             break;
  1458.         }
  1459.     }
  1460.     return $found
  1461. }; # AnotationFlagExists
  1462. proc IfRegistered {licenseId serialNum registeredLicenses} {
  1463.     global appvals indexes
  1464.     set registered 0
  1465.     foreach license $registeredLicenses {
  1466.          set lid  [lindex $license $indexes(LICENSE_ID)]
  1467.          set snum [lindex $license $indexes(SERIAL_NUMBER)]
  1468.          if {$lid == $licenseId && $snum == $serialNum} {
  1469.              set registered 1
  1470.              break
  1471.          }
  1472.     }
  1473.     return $registered
  1474. }; # IfRegistered
  1475. proc GetLicenseState { license } {
  1476.     global appvals indexes
  1477.     set currentDate [getclock]
  1478.     set startDate [lindex $license $indexes(START_DATE)]
  1479.     set endDate   [lindex $license $indexes(END_DATE)]
  1480.     if { $currentDate >= $endDate } {
  1481.         set date [FormatDate $endDate]
  1482.         set state [IntlMsg EXPIRED_DATE $date]
  1483.     } else {
  1484.          if { $endDate > $appvals(timeLimit) } {
  1485.             set state [IntlMsg PERMANENT_LICENSE]
  1486.         } else {
  1487.             set date [FormatDate $endDate]
  1488.             set state [IntlMsg WILL_EXPIRE_ON $date]
  1489.         }
  1490.     }
  1491.     return $state
  1492. }; # GetLicenseState
  1493. proc FormatDate { date } {
  1494.     global appvals 
  1495.     set date [fmtclock $date %m/%d/%Y]
  1496.     return $date
  1497. }; # FormatDate
  1498. proc ExtensionRequired { serialNumber actionKey } {
  1499.     global appvals indexes productName
  1500.     set host $appvals(managedhost)
  1501.     set cmd $appvals(brandPath) 
  1502.     set args [list -h $serialNumber $actionKey]
  1503.     if { ![ErrorCatch errStack 0 {RunCmd $host $cmd $args \
  1504.                 [IntlErrId CMD_BRAND_CHECK_EXT_UNABLE]} ret] } {
  1505.             if { $ret == 8 } {
  1506.                 return 0 
  1507.             } else {
  1508.                 return 1 
  1509.             }
  1510.     } else {
  1511.             return -1 
  1512.     }
  1513. }; # ExtensionRequired
  1514. proc GetLicenseId { serialNum actionKey } {
  1515.     global appvals indexes
  1516.     set licenseIdList {}
  1517.     set host $appvals(managedhost)
  1518.     set cmd $appvals(brandPath)
  1519.     lappend args -Q $serialNum $actionKey 
  1520.     if { ![ErrorCatch errStack 0 {RunCmd $host $cmd $args \
  1521.                 [IntlErrId INVALID_LICENSE_NUMBER_CODE]} result]} {
  1522.         lappend licenseIdList [ctoken result .]        
  1523.         lappend licenseIdList [ctoken result .]
  1524.     } else {
  1525.         ErrorThrow errStack
  1526.     }
  1527.     return $licenseIdList
  1528. }; # GetLicenseId
  1529. proc AddLicense { serNum actKey extent } {
  1530.     global appvals
  1531.     set host $appvals(managedhost)
  1532.     if { $appvals(owner) == 0 } {
  1533.         set cmd $appvals(brandPath)
  1534.         if { ![lempty $extent] } {
  1535.             lappend args -a $extent
  1536.         }
  1537.         lappend args -g $serNum $actKey
  1538.     } else {
  1539.         set cmd /sbin/tfadmin
  1540.         set args brand
  1541.         if { ![lempty $extent] } {
  1542.             lappend args -a $extent
  1543.         }
  1544.         lappend args -g $serNum $actKey
  1545.     }
  1546.     if { [ErrorCatch errStack 0 {RunCmd $host $cmd $args \
  1547.                 [IntlErrId CMD_BRAND_ADD_UNABLE]} result]} {
  1548.         ErrorThrow errStack
  1549.     }
  1550.     return 0
  1551. }; # AddLicense
  1552. proc GetBrandErrorMessage { rc } {
  1553.     global appvals
  1554.     case $rc {
  1555.         1     {
  1556.              set message [IntlErrId BRAND_RC1_ERROR]
  1557.         }
  1558.          2     {
  1559.             set message [IntlErrId BRAND_RC2_ERROR]
  1560.           }
  1561.          8     {
  1562.              set message [IntlErrId BRAND_RC8_ERROR]
  1563.          }
  1564.          10     {
  1565.               set message [IntlErrId BRAND_RC10_ERROR]
  1566.         }
  1567.         12     {
  1568.              set message [IntlErrId BRAND_RC12_ERROR]
  1569.          }
  1570.          13 {
  1571.             set message [IntlErrId BRAND_RC13_ERROR]
  1572.          }
  1573.          default {
  1574.              set message {}
  1575.          }
  1576.     }
  1577.     return $message
  1578. }; # GetBrandErrorMessage
  1579. proc RemoveLicenseFromNodelockFile { serialNumber } {
  1580.     global appvals 
  1581.      set cmd /usr/bin/cat
  1582.     set args $appvals(nodeLockFile)
  1583.     set host $appvals(managedhost)
  1584.     if { [ErrorCatch errStack 0 {RunCmd $host $cmd $args \
  1585.                 [IntlErrId NODELOCKFILE_CAT_UNABLE]} ret] } {
  1586.         ErrorThrow errStack
  1587.     } 
  1588.     set oldLicenses $ret
  1589.     set modifiedList [RemoveItemFromList $oldLicenses $serialNumber]
  1590.     if { $appvals(owner) == 0} {
  1591.         if { [ErrorCatch errorStack 0 {RunCopy $host $args $modifiedList \
  1592.                 [IntlErrId NODELOCKFILE_MODIFY_UNABLE] } ret] } {
  1593.             ErrorThrow errorStack
  1594.         } 
  1595.     } else {
  1596.         set tmpFile "/tmp/nodelock.[pid]"
  1597.         if { ![ErrorCatch errorStack 0 {RunCopy $host $tmpFile $modifiedList \
  1598.                 [IntlErrId NODELOCKFILE_MODIFY_UNABLE] } ret] } {
  1599.             set cmd  /sbin/tfadmin
  1600.             set argsA "cpfile $tmpFile $args"
  1601.             if { [ErrorCatch errStack 0 {RunCmd $host $cmd $argsA \
  1602.                     [IntlErrId NODELOCKFILE_CAT_UNABLE]} ret] } {
  1603.                 ErrorThrow errStack
  1604.             }
  1605.         }
  1606.     }
  1607.     return
  1608. }; # RemoveLicenseFromNodelockFile
  1609. proc RemoveItemFromList { licenses  serialNumber } {
  1610.     global appvals
  1611.     set modifiedList {}
  1612.     set licenses [split $licenses "\n"]
  1613.     foreach line $licenses {
  1614.         set anotation [lindex $line 2]
  1615.         set anotationList [ParseAnotation $anotation]
  1616.         set id [lindex [split $anotationList "/"] 0 ]
  1617.         set nvalue [SearchAnotationList n $anotationList]
  1618.         if {$nvalue != $serialNumber} {
  1619.             lappend modifiedList $line
  1620.         }
  1621.     } 
  1622.     return $modifiedList
  1623. }; # RemoveItemFromList
  1624. proc KillIfor_pmd { } {
  1625.     global appvals
  1626.     set pidFile /pmd/ifor_pmd.pid
  1627.     set host $appvals(managedhost)
  1628.     set cmd /usr/bin/cat
  1629.     set args $pidFile
  1630.     set errOccur 0
  1631.     if { ![ErrorCatch errStack 0 {RunCmd $host $cmd $args \
  1632.                 [IntlErrId IFOR_PMD_CAT_UNABLE]} ret]} {
  1633.         set pid $ret
  1634.     } else {
  1635.         set errOccur 1
  1636.         ErrorPush newStack 0 [IntlErrId IFOR_PMD_CAT_UNABLE] 
  1637.     }
  1638.     if { $appvals(owner) == 0 } {
  1639.         set cmd kill
  1640.         lappend pidArgs -9 $pid
  1641.         if { [ErrorCatch errStack 0 {RunCmd $host $cmd $pidArgs \
  1642.                 [IntlErrId KILL_PROCESS_UNABLE]} ret]} {
  1643.             ErrorPush newStack 0  [IntlErrId KILL_PROCESS_UNABLE]
  1644.             set errOccur 1
  1645.         }
  1646.     } else {
  1647.         set cmd /sbin/tfadmin
  1648.         lappend newArgs kill -9 $pid
  1649.         if { [ErrorCatch errStack 0 {RunCmd $host $cmd $newArgs \
  1650.                 [IntlErrId KILL_PROCESS_UNABLE]} ret]} {
  1651.             ErrorPush newStack 0  [IntlErrId KILL_PROCESS_UNABLE]
  1652.             set errOccur 1
  1653.         }
  1654.     }
  1655.     if { $errOccur == 1 } {
  1656.         ErrorThrow newStack
  1657.     }
  1658.     return
  1659. }; # KillIfor_pmd
  1660. proc GetInstallId { } {
  1661.     global appvals
  1662.     set installId {}
  1663.     set cmd $appvals(brandPath)
  1664.     set host $appvals(managedhost)
  1665.     lappend args -I
  1666.     if { ![ErrorCatch errStack 0 {RunCmd $host $cmd $args \
  1667.                     [IntlErrId CMD_BRAND_INSTALL_ID_UNABLE] } ret]} {
  1668.         set installId $ret
  1669.     } else {
  1670.         ErrorThrow errStack
  1671.     }
  1672.     return $installId
  1673. }; # GetInstallId
  1674. proc RegisterLicense { serialNumber registrationId } {
  1675.     global appvals indexes
  1676.     set host $appvals(managedhost)
  1677.     if { $appvals(owner) == 0 } {
  1678.         set cmd $appvals(brandPath)
  1679.         lappend args -R $serialNumber $registrationId
  1680.     } else {
  1681.         set cmd /sbin/tfadmin
  1682.         set args " "
  1683.         lappend  args brand  -R $serialNumber $registrationId
  1684.     }
  1685.     if { [ErrorCatch errStack 0 {RunCmd $host $cmd $args \
  1686.                 [IntlErrId CMD_BRAND_REGISTER_UNABLE] } ret] } {
  1687.         set retCode  [lindex [lindex $errStack end] end]
  1688.         ErrorPush newStack 0 [GetBrandErrorMessage $retCode]
  1689.         ErrorPush newStack 0 [IntlErrId CMD_BRAND_REGISTER_UNABLE]
  1690.         ErrorThrow newStack
  1691.     }
  1692. }; # RegisterLicense
  1693. proc BuildMainList {form} {
  1694.     global appvals
  1695.     set columns 80 
  1696.     set formatList { \
  1697.         {STRING 35 4} \
  1698.         {STRING 15 4} \
  1699.         {STRING 15 4} \
  1700.         {STRING 22 4} \
  1701.         {DATA} \
  1702.         {DATA} \
  1703.         }
  1704.     set CHARM_formatList { \
  1705.         {STRING 45 1} \
  1706.         {STRING 15 1} \
  1707.         {STRING 10 1} \
  1708.         {STRING 22 } \
  1709.         {DATA} \
  1710.         {DATA} \
  1711.         }
  1712.     set labelList [list \
  1713.         [IntlMsg PROD_NAME] \
  1714.         [IntlMsg LIC_NUMBER] \
  1715.         [IntlMsg REGISTER_STATUS] \
  1716.         [IntlMsg LIC_STATUS] \
  1717.         ]
  1718.     set mainList [VtDrawnList $form.mainList \
  1719.             -labelFormatList $formatList \
  1720.             -labelList $labelList \
  1721.             -formatList $formatList \
  1722.             -CHARM_formatList $CHARM_formatList \
  1723.             -rows 12 \
  1724.             -columns $columns \
  1725.             -leftSide FORM \
  1726.             -rightSide FORM \
  1727.             -bottomSide NONE \
  1728.             -selection MULTIPLE \
  1729.             -shortHelpString [IntlMsg MAINLIST_SH] \
  1730.             -shortHelpCallback SaShortHelpCB \
  1731.             -callback LicenseMainListCB \
  1732.             -defaultCallback LicenseMainListDoubleCB \
  1733.             -autoLock {LicenseMainListDoubleCB} \
  1734.             ]
  1735.     if {[VtInfo -charm]} {
  1736.         set label [format "  %-44s%-15s%-11s%-8s" \
  1737.             [lindex $labelList 0] \
  1738.             [lindex $labelList 1] \
  1739.             [lindex $labelList 2] \
  1740.             [lindex $labelList 3] \
  1741.             ]
  1742.         set header [ VxGetVar $appvals(vtMain) header ]
  1743.         VtSetValues $header -label $label
  1744.     }
  1745.     return $mainList
  1746. }; # BuildMainList
  1747. proc LicenseMainListCB {cbs} {
  1748.     UiMainListCB $cbs
  1749. }; # LicenseMainListCB
  1750. proc LicenseMainListDoubleCB {cbs} {
  1751.     UiMainListDoubleCB $cbs
  1752. }; # LicenseMainListDoubleCB
  1753. proc LicenseAuthorized { host } {
  1754.     global appvals
  1755.     if { [id effective userid] != 0} {
  1756.         set cmd "/sbin/tfadmin"
  1757.         set argsA "-t brand"
  1758.         set argsB "-t cpfile"
  1759.         if { ![ErrorCatch errStack 0  \
  1760.             {RunCmd $host $cmd $argsA [IntlErrId CHECK_OWNER_UNABLE]} retA] && \
  1761.              ![ErrorCatch errStack 0  \
  1762.             {RunCmd $host $cmd $argsB [IntlErrId CHECK_OWNER_UNABLE]} retB] } {
  1763.                 set appvals(owner) 1
  1764.                 return 1
  1765.         }
  1766.         return 0
  1767.     } else {
  1768.         set appvals(owner) 0
  1769.         return 1
  1770.     }
  1771. }; # LicenseAuthorized
  1772. proc LicenseInit {} {
  1773.     global appvals indexes productNames
  1774.     set appvals(title)         [IntlMsg TITLE]
  1775.     set appvals(object)     [IntlMsg OBJECT]    
  1776.     set appvals(objectmn)    [IntlMsg OBJECT_MN]    
  1777.     set appvals(itemname)    [IntlMsg ITEMS]    
  1778.     set appvals(timeLimit)     2145859200
  1779.     set appvals(nodeLockFile)    /var/netls/nodelock
  1780.     set appvals(brandPath)     /usr/sbin/brand
  1781.     set appvals(nameListIndex)        0
  1782.     set appvals(serNumListIndex)     1
  1783.     set appvals(registerListIndex)     2
  1784.     set appvals(statusListIndex)    3
  1785.     set appvals(ViewAllBtnState)    1
  1786.     set appvals(ExpiredBtnState)    0
  1787.     set appvals(NotRegtBtnState)    0
  1788.     set indexes(LICENSE_ID)             0
  1789.     set indexes(LICENSE_VERSION)        1
  1790.     set indexes(SERIAL_NUMBER)          2
  1791.     set indexes(ANOTATION)              3
  1792.     set indexes(START_DATE)             4
  1793.     set indexes(END_DATE)               5
  1794.     set indexes(NAME)                   6
  1795.     set indexes(VERSION)                7
  1796.     set indexes(DESCRIPTION)            8
  1797.     set indexes(DEFAULT_THIRD_LINE)     9
  1798.     set indexes(ALTERNATE_IDS)          10
  1799.     set productNames(MPX)           "SCO:MPX"
  1800.     set productNames(MPX_ENT)       "SCO:Unix:MPX"
  1801.     set productNames(RAID)          "SCO:RAID"
  1802.     set productNames(RAID_ENT)      "SCO:Unix:RAID"
  1803. }; # LicenseInit
  1804. set appvals(version) 1.0
  1805. set appvals(script) [file tail [info script]]    ;# argv[0]: UNIX command name 
  1806. set appvals(client) $appvals(script)        ;# widget strings, preferences
  1807. set appvals(localhost) {}            ;# where we are running 
  1808. set appvals(managedhost) {}            ;# which host to manage 
  1809. set appvals(who)     1;
  1810. proc Exit {{code 0}} {
  1811.     exit $code
  1812. }
  1813. proc Usage {} {
  1814.     global appvals
  1815.     if $appvals(openhost) {
  1816.         set usage "Usage: $appvals(script) \[host\]"
  1817.     } else {
  1818.         set usage "Usage: $appvals(script)"
  1819.     }
  1820.     puts stderr $usage
  1821. }
  1822. proc ParseCommandLine {} {
  1823.     global argv argc opterr optind appvals
  1824.     set optString    ""
  1825.     set argc [llength $argv]
  1826.     set opterr 0
  1827.     while {[set opt [getopt $argc $argv $optString]] != -1} {
  1828.         switch $opt {
  1829.             {?} {
  1830.                 Usage; Exit 1
  1831.             }
  1832.         }
  1833.     }
  1834.     set optCount [expr "$argc - $optind"]
  1835.     if {$appvals(openhost)} {
  1836.         if {$optCount} {
  1837.             set appvals(managedhost) [lindex $argv $optind]
  1838.             incr optCount -1
  1839.         }
  1840.     } 
  1841.     if {$optCount > 0} {
  1842.         Usage; Exit 1
  1843.     }
  1844. }
  1845. proc Main {} {
  1846.     global appvals
  1847.     set appvals(localhost)    [SaHostGetLocalName]
  1848.     set appvals(managedhost) $appvals(localhost)
  1849.     ParseCommandLine
  1850.     LicenseInit
  1851.     UiStart
  1852.     SaStatusBarSet [VxGetVar $appvals(vtMain) statusBar] [IntlMsg INIT] 
  1853.     set authorized [LicenseAuthorized $appvals(managedhost)]
  1854.     if {!$authorized} {
  1855.         SaDisplayNoAuths $appvals(vtMain).noAuths $appvals(title) \
  1856.             UiCloseCB $appvals(managedhost)
  1857.         VtUnLock
  1858.         VtMainLoop
  1859.         return
  1860.     }
  1861.     UiRefreshCB
  1862.     UiSetAppFocus
  1863.     UiSensitizeFunctions
  1864.     SaStatusBarClear [VxGetVar $appvals(vtMain) statusBar]
  1865.     VtUnLock
  1866.     VtMainLoop
  1867. }
  1868. proc CloseWithUi {} {
  1869. }
  1870. proc CloseAfterUi {} {
  1871.     Exit
  1872. }
  1873. proc Refresh { } {
  1874.     global appvals
  1875.     set data {}
  1876.     if { ![ErrorCatch errStack 0 {BrowserGetData} ret] } {
  1877.         set data $ret
  1878.     } else {
  1879.         UiDisplayErrorStacks BrowserData  $errStack ErrExitCB
  1880.         return
  1881.     }
  1882.     UiMainListSetItems $data
  1883. }
  1884. ErrorTopLevelCatch {Main} $appvals(script)
  1885.