3
# openipmi GUI handling for MC PEF parms
5
# Author: MontaVista Software, Inc.
6
# Corey Minyard <minyard@mvista.com>
9
# Copyright 2005 MontaVista Software Inc.
11
# This program is free software; you can redistribute it and/or
12
# modify it under the terms of the GNU Lesser General Public License
13
# as published by the Free Software Foundation; either version 2 of
14
# the License, or (at your option) any later version.
17
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
23
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
# You should have received a copy of the GNU Lesser General Public
29
# License along with this program; if not, write to the Free
30
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
42
def __init__(self, glist, pefc, parm, aidx, pname, ptype, origval):
49
self.origval = origval
50
self.currval = origval
53
def SetItem(self, idx):
57
def HandleMenu(self, event, idx, point):
58
if (self.ptype == "bool"):
59
menul = [ ("Toggle Value", self.togglevalue) ]
60
elif (self.ptype == "enum"):
66
rv = OpenIPMI.pefconfig_enum_val(self.parm, val, nval, sval)
68
menul.append( (sval[0] + " (" + str(val) + ")",
76
menul = [ ("Set Value", self.setvalue) ]
78
gui_popup.popup(self.glist, event, menul, point)
82
rv = self.pefc.set_val(self.parm, self.aidx, self.ptype, str(vals[0]))
84
self.glist.SetError("Invalid data value: "
85
+ OpenIPMI.get_error_string(rv))
87
self.currval = vals[0]
88
self.glist.SetColumn(self.idx, 1, vals[0])
91
def setvalue(self, event):
92
gui_setdialog.SetDialog("Set value for " + self.pname,
93
[ self.currval ], 1, self)
96
def setenum(self, val):
97
rv = self.pefc.set_val(self.parm, self.aidx, "integer", str(val))
99
self.glist.SetError("Could not set value to " + str(val) + ": "
100
+ OpenIPMI.get_error_string(rv))
105
OpenIPMI.pefconfig_enum_val(self.parm, val, nval, sval)
106
self.glib.SetColumn(self.idx, 1, sval[0])
109
def togglevalue(self, event):
110
if (self.currval == "true"):
115
rv = self.pefc.set_val(self.parm, self.aidx, self.ptype, newval)
117
self.glist.SetError("Could not toggle value: "
118
+ OpenIPMI.get_error_string(rv))
121
self.currval = newval
122
self.glist.SetColumn(self.idx, 1, newval)
127
class MCPefParm(gui_list.List):
128
def __init__(self, m, pef, pefc):
129
gui_list.List.__init__(self,
130
"PEFPARMS for " + m.name,
131
[ ("Name", 250), ("Value", 250) ])
141
rv = pefc.get_val(i, v)
143
vals = rv.split(" ", 2)
146
if (vals[1] == "integer"):
149
err = OpenIPMI.pefconfig_enum_val(i, 0, w, x)
150
if (err != OpenIPMI.enosys):
155
data = MCPEFData(self, pefc, i, lastv,
156
vals[0], vals[1], vals[2])
162
err = OpenIPMI.pefconfig_enum_idx(i, lastv, x)
164
title = vals[0] + "[" + str(lastv) + "]"
166
title = vals[0] + "[" + x[0] + "]"
169
if (vals[1] == "enum"):
172
OpenIPMI.pefconfig_enum_val(data.parm, int(vals[2]),
180
self.add_data(title, [ value ], data)
202
rv = self.pef.set_config(self.pefc)
204
self.errstr.SetError("Error setting config: "
205
+ OpenIPMI.get_error_string(rv))
208
# Don't forget to set self.pef to None when done so OnClose
209
# doesn't clear it again
218
def do_on_close(self):
219
# Do it here, not in cancel, to handle closing the window without
220
# clicking on "save" or "cancel"
222
self.pef.clear_lock(self.pefc)