3
# openipmi GUI handling for MC SOL 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, solc, 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.solconfig_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.solc.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.solc.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.solconfig_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.solc.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 MCSolParm(gui_list.List):
128
def __init__(self, m, sol, solc, channel):
129
gui_list.List.__init__(self,
130
"SOLPARMS for " + m.name + " channel "
132
[ ("Name", 250), ("Value", 250) ])
135
self.channel = channel
143
rv = solc.get_val(i, v)
145
vals = rv.split(" ", 2)
148
if (vals[1] == "integer"):
151
err = OpenIPMI.solconfig_enum_val(i, 0, w, x)
152
if (err != OpenIPMI.enosys):
157
data = MCLPData(self, solc, i, lastv,
158
vals[0], vals[1], vals[2])
164
err = OpenIPMI.solconfig_enum_idx(i, lastv, x)
166
title = vals[0] + "[" + str(lastv) + "]"
168
title = vals[0] + "[" + x[0] + "]"
171
if (vals[1] == "enum"):
174
OpenIPMI.solconfig_enum_val(data.parm, int(vals[2]),
182
self.add_data(title, [ value ], data)
204
rv = self.sol.set_config(self.solc)
206
self.errstr.SetError("Error setting config: "
207
+ OpenIPMI.get_error_string(rv))
210
# Don't forget to set self.sol to None when done so OnClose
211
# doesn't clear it again
220
def do_on_close(self):
221
# Do it here, not in cancel, to handle closing the window without
222
# clicking on "save" or "cancel"
224
self.sol.clear_lock(self.solc)