1
# -*- coding: utf-8 -*-
3
# (c) Copyright 2001-2011 Hewlett-Packard Development Company, L.P.
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
# Author: Sarbeswar Meher
27
from base import device, utils
29
from base.codes import *
30
from ui_utils import *
36
from firmwaredialog_base import FirmwareDialog_Base
38
class FirmwareDialog(QDialog, FirmwareDialog_Base):
39
def __init__(self, parent, device_uri):
40
QDialog.__init__(self, parent)
42
self.device_uri = device_uri
44
QTimer.singleShot(0, self.updateUi)
47
self.DeviceComboBox.setFilter({'fw-download' : (operator.gt, 0)})
48
self.DeviceComboBox.setParent(self)
49
self.connect(self.CancelButton, SIGNAL("clicked()"), self.close)
50
self.connect(self.DownloadFirmwareButton, SIGNAL("clicked()"), self.downloadFirmware)
53
self.setIcon(load_pixmap('hp_logo', '128x128'))
56
self.DeviceComboBox.setInitialDevice(self.device_uri)
60
self.DeviceComboBox.updateUi()
63
def DeviceUriComboBox_currentChanged(self, device_uri):
64
self.device_uri = device_uri
68
def DeviceUriComboBox_noDevices(self):
69
self.FailureUI(self.__tr("<b>No devices that support firmware download found.</b>"))
73
def downloadFirmware(self):
78
d = device.Device(self.device_uri)
88
if d.isIdleAndNoError():
89
ok = d.downloadFirmware()
102
def __tr(self,s,c = None):
103
return qApp.translate("FirmwareDialog",s,c)
105
def FailureUI(self, error_text):
107
QMessageBox.critical(self,
111
QMessageBox.NoButton,
112
QMessageBox.NoButton)
115
def CheckDeviceUI(self):
116
return self.FailureUI(self.__tr("<b>Unable to communicate with device or device is in an error state.</b><p>Please check device setup and try again.</p>"))