1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2001-2009 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
27 from base import device, utils, models, wifi, LedmWifi
28 from base.codes import *
29 from ui_utils import *
32 from PyQt4.QtCore import *
33 from PyQt4.QtGui import *
36 from wifisetupdialog_base import Ui_Dialog
40 PAGE_INTRO = 0 # Ask user to plugin temp USB connection
41 PAGE_DEVICES = 1 # Select a probed USB device
42 PAGE_NETWORK = 2 # Select a discovered SSID
43 PAGE_CONFIGURE_WIFI = 3 # Configure USB device on network
44 PAGE_EXIT = 4 # Tell user if successful, unplug USB onnection
51 SUCCESS_NOT_CONNECTED = 0
59 class DeviceTableWidgetItem(QTableWidgetItem):
60 def __init__(self, text, device_uri):
61 QTableWidgetItem.__init__(self, text, QTableWidgetItem.UserType)
62 self.device_uri = device_uri
65 class WifiSetupDialog(QDialog, Ui_Dialog):
66 def __init__(self, parent, device_uri=None, standalone=True):
67 QDialog.__init__(self, parent)
70 self.device_uri = device_uri
75 self.show_extended = False
78 self.max_page = PAGE_EXIT
79 self.location_cache = {} # { 'bssid' : <location>, ... }
81 self.success = SUCCESS_NOT_CONNECTED
84 self.standalone = standalone
86 self.adapterName = 'Wifi0'
89 #if self.device_uri is None:
90 # QTimer.singleShot(0, self.showIntroPage)
92 # QTimer.singleShot(0, self.showNetworkPage)
94 QTimer.singleShot(0, self.showIntroPage)
102 self.setWindowIcon(QIcon(load_pixmap('hp_logo', '128x128')))
104 # connect signals/slots
105 self.connect(self.CancelButton, SIGNAL("clicked()"), self.CancelButton_clicked)
106 self.connect(self.BackButton, SIGNAL("clicked()"), self.BackButton_clicked)
107 self.connect(self.NextButton, SIGNAL("clicked()"), self.NextButton_clicked)
110 self.initDevicesPage()
111 self.initNetworkPage()
112 self.initConfigWifiPage()
119 def initIntroPage(self):
120 self.Picture.setPixmap(load_pixmap("usb_connection", "other"))
121 self.InfoIcon.setPixmap(load_pixmap("info", "16x16"))
124 self.MainTitleLabel.setText(self.__tr("""This utility allows you configure your wireless capable printer using a temporary USB connection. You will be prompted to disconnect the USB cable once wireless network setup is complete.
126 <p><i>Note: This configuration utility does not setup (install) your printer on this computer. Use hp-setup to setup your printer after it has been configured on the network by this utility.</i></p>
127 <p><i>Note: Only select wireless capable printers are supported by this utility.</i></p>"""))
129 self.MainTitleLabel.setText(self.__tr("""This utility allows you configure your wireless capable printer using a temporary USB connection. You will be prompted to disconnect the USB cable once wireless network setup is complete.
131 <p><i>Note: Printer setup (installation) will continue after your printer is configured on the network.</i></p>
132 <p><i>Note: Only select wireless capable printers are supported by this utility.</i></p>"""))
135 def showIntroPage(self):
136 self.BackButton.setEnabled(False)
137 self.NextButton.setEnabled(True)
139 self.displayPage(PAGE_INTRO)
146 def initDevicesPage(self):
147 self.connect(self.RefreshButton, SIGNAL("clicked()"), self.RefreshButton_clicked)
150 def showDevicesPage(self):
151 self.BackButton.setEnabled(True)
152 self.setNextButton(BUTTON_NEXT)
157 log.info("Searching on USB bus...")
158 filter_dict = {'wifi-config' : (operator.gt, WIFI_CONFIG_NONE)}
160 self.devices = device.probeDevices([self.bus], 0, 0, filter_dict, self.search)
164 self.clearDevicesTable()
167 self.NextButton.setEnabled(True)
168 self.DevicesFoundIcon.setPixmap(load_pixmap('info', '16x16'))
170 if len(self.devices) == 1:
171 self.DevicesFoundLabel.setText(self.__tr("<b>1 wireless capable device found.</b> Click <i>Next</i> to continue."))
173 self.DevicesFoundLabel.setText(self.__tr("<b>%1 wireless capable devices found.</b> Select the device to install and click <i>Next</i> to continue.").arg(len(self.devices)))
175 self.loadDevicesTable()
178 self.NextButton.setEnabled(False)
179 self.DevicesFoundIcon.setPixmap(load_pixmap('error', '16x16'))
180 log.error("No devices found on bus: %s" % self.bus)
181 self.DevicesFoundLabel.setText(self.__tr("<b>No wireless capable devices found.</b><br>Plug in your printer with a USB cable and click <i>Refresh</i> to search again."))
183 self.displayPage(PAGE_DEVICES)
186 def loadDevicesTable(self):
187 self.DevicesTableWidget.setSortingEnabled(False)
188 self.DevicesTableWidget.setRowCount(len(self.devices))
190 headers = [self.__tr('Model'), self.__tr('Device URI')]
193 self.DevicesTableWidget.setColumnCount(len(headers))
194 self.DevicesTableWidget.setHorizontalHeaderLabels(headers)
195 flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled
197 for row, d in enumerate(self.devices):
198 back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(d)
199 model_ui = models.normalizeModelUIName(model)
201 i = DeviceTableWidgetItem(QString(model_ui), d)
203 self.DevicesTableWidget.setItem(row, 0, i)
205 i = QTableWidgetItem(QString(d))
207 self.DevicesTableWidget.setItem(row, device_uri_col, i)
209 self.DevicesTableWidget.resizeColumnsToContents()
210 self.DevicesTableWidget.setSortingEnabled(True)
211 self.DevicesTableWidget.sortItems(0)
212 self.DevicesTableWidget.selectRow(0)
215 def clearDevicesTable(self):
216 self.DevicesTableWidget.clear()
217 self.DevicesTableWidget.setRowCount(0)
218 self.DevicesTableWidget.setColumnCount(0)
221 def RefreshButton_clicked(self):
222 self.clearDevicesTable()
224 QTimer.singleShot(0, self.showDevicesPage)
231 def initNetworkPage(self):
232 self.NetworksTableWidget.setIconSize(QSize(34, 20))
233 self.ShowExtendedCheckBox.setChecked(False)
234 self.connect(self.ShowExtendedCheckBox, SIGNAL("clicked(bool)"), self.ShowExtendedCheckBox_clicked)
235 self.connect(self.SearchPushButton, SIGNAL("clicked()"), self.SearchPushButton_clicked)
236 self.connect(self.UndirectedRadioButton, SIGNAL("clicked(bool)"), self.UndirectedRadioButton_clicked)
237 self.connect(self.DirectedRadioButton, SIGNAL("clicked(bool)"), self.DirectedRadioButton_clicked)
238 self.connect(self.NetworksTableWidget, SIGNAL("itemSelectionChanged()"), self.NetworksTableWidget_itemSelectionChanged)
241 def showNetworkPage(self):
244 self.dev = device.Device(self.device_uri)
246 FailureUI(self, self.__tr("<b>Error opening device:</b><p>%1</p><p>(%2)</p>").arg(self.device_uri).arg(QString(e[0])))
248 if self.dev is not None:
254 self.networks.clear()
255 self.num_networks = 0
258 self.adaptor_id, self.adapterName, state, presence = self.wifiObj.getWifiAdaptorID(self.dev)
263 log.debug("Adaptor ID: %s" % self.adaptor_id)
264 log.debug("Adaptor name: %s" % self.adapterName)
265 log.debug("Adaptor state: %s" % state)
266 log.debug("Adaptor presence: %s" % presence)
268 if self.adaptor_id == -1:
269 FailureUI(self, self.__tr("<b>Unable to locate wireless hardware on device.</b>"))
270 if self.dev is not None:
275 log.debug("Turning on wireless radio...")
277 self.wifiObj.setAdaptorPower(self.dev, self.adapterName, self.adaptor_id)
283 self.setNextButton(BUTTON_NEXT)
284 self.displayPage(PAGE_NETWORK)
287 def performScan(self):
291 self.ssid = unicode(self.SSIDLineEdit.text())
292 if self.directed and self.ssid:
294 self.networks = self.wifiObj.performScan(self.dev, self.adapterName, self.ssid)
300 self.networks = self.wifiObj.performScan(self.dev, self.adapterName)
308 self.num_networks = self.networks['numberofscanentries']
309 self.clearNetworksTable()
311 if self.num_networks:
312 self.NextButton.setEnabled(True)
313 self.NetworksFoundIcon.setPixmap(load_pixmap('info', '16x16'))
315 if self.num_networks == 1:
316 self.NetworksFoundLabel.setText(self.__tr("<b>1 wireless network found. </b> If the wireless network you would like to connect to is not listed, try entering a wireless network name and/or press <i>Search</i> to search again."))
318 self.NetworksFoundLabel.setText(self.__tr("<b>%1 wireless networks found.</b> If the wireless network you would like to connect to is not listed, try entering a wireless network name and/or press <i>Search</i> to search again.").arg(self.num_networks))
320 self.loadNetworksTable()
323 self.NextButton.setEnabled(False)
324 self.NetworksFoundIcon.setPixmap(load_pixmap('error', '16x16'))
325 log.warning("No wireless networks found.")
326 self.NetworksFoundLabel.setText(self.__tr("<b>No wireless networks found.</b><br>Enter a wireless network name and/or press <i>Search</i> to search again."))
329 def ShowExtendedCheckBox_clicked(self, b):
330 self.show_extended = b
331 self.loadNetworksTable()
334 def SearchPushButton_clicked(self):
336 self.loadNetworksTable()
339 def UndirectedRadioButton_clicked(self, b):
340 self.directed = not b
341 self.SSIDLineEdit.setEnabled(not b)
344 def DirectedRadioButton_clicked(self, b):
346 self.SSIDLineEdit.setEnabled(b)
349 def loadNetworksTable(self):
350 self.n, self.network = 0, u''
351 if self.num_networks:
354 if self.show_extended:
355 for n in xrange(self.num_networks):
356 bssid = self.networks['bssid-%d' % n]
357 ss = self.networks['signalstrength-%d' % n]
359 self.location_cache[bssid]
361 location = wifi.getLocation(bssid, ss)
362 lat = self.networks['latitude-%d' % n] = location.get('latitude', 'Unknown')
363 lng = self.networks['longitude-%d' % n] = location.get('longitude', 'Unknown')
364 address = self.networks['address-%d' % n] = location.get('address', 'Unknown')
365 self.location_cache[bssid] = (lat, lng, address)
367 self.networks['latitude-%d' % n], self.networks['longitude-%d' % n], self.networks['address-%d' % n] = \
368 self.location_cache[bssid]
370 self.NetworksTableWidget.setSortingEnabled(False)
371 self.NetworksTableWidget.setRowCount(self.num_networks)
373 headers = [self.__tr('Network Name (SSID)'), self.__tr('Signal Strength'),
374 self.__tr("Security"), self.__tr("Mode")]
376 if self.show_extended:
377 headers.extend([self.__tr('Channel'),
378 self.__tr("Address (BSSID)"), self.__tr("Location"),
379 self.__tr("Lat/Long")])
381 self.NetworksTableWidget.setColumnCount(len(headers))
382 self.NetworksTableWidget.setHorizontalHeaderLabels(headers)
383 enabled_flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled
385 for n in xrange(self.num_networks):
386 name = self.networks['ssid-%d' % n]
388 if name == '(unknown)':
391 flags = enabled_flags
393 ss = self.networks['signalstrength-%d' % n]
394 sec = self.networks['encryptiontype-%d' % n]
395 mode = self.networks['communicationmode-%d' % n]
397 log.debug("%d: Name=%s, strength=%s, security=%s, mode=%s" % #, channel=%d bssid=%s" %
398 (n, name, ss, sec, mode))
400 if self.show_extended:
401 chn = self.networks['channel-%d' % n]
402 dbm = self.networks['dbm-%d' % n]
403 bssid = self.networks['bssid-%d' % n]
404 address = self.networks['address-%d' % n]
405 lat = self.networks['latitude-%d' % n]
406 lng = self.networks['longitude-%d' % n]
408 log.debug("%d: channel=%d bssid=%s dbm=%s lat=%s long=%s address=%s" %
409 (n, chn, bssid, dbm, lat, lng, address))
411 i = QTableWidgetItem(QString(name))
412 if flags is not None: i.setFlags(flags)
413 i.setData(Qt.UserRole, QVariant(n))
414 self.NetworksTableWidget.setItem(n, 0, i)
416 pixmap = load_pixmap('signal%d' % ss, 'other')
417 if self.show_extended:
418 i = QTableWidgetItem(QIcon(pixmap), self.__tr("%1/5 (%2 dBm)").arg(ss).arg(dbm))
420 i = QTableWidgetItem(QIcon(pixmap), self.__tr("%1/5").arg(ss))
421 if flags is not None: i.setFlags(flags)
422 self.NetworksTableWidget.setItem(n, 1, i)
424 i = QTableWidgetItem(QString(sec))
425 if flags is not None: i.setFlags(flags)
426 self.NetworksTableWidget.setItem(n, 2, i)
428 i = QTableWidgetItem(QString(mode))
429 if flags is not None: i.setFlags(flags)
430 self.NetworksTableWidget.setItem(n, 3, i)
432 if self.show_extended:
433 i = QTableWidgetItem(QString(str(chn)))
434 if flags is not None: i.setFlags(flags)
435 self.NetworksTableWidget.setItem(n, 4, i)
437 i = QTableWidgetItem(QString(bssid))
438 if flags is not None: i.setFlags(flags)
439 self.NetworksTableWidget.setItem(n, 5, i)
441 i = QTableWidgetItem(QString(address))
442 if flags is not None: i.setFlags(flags)
443 self.NetworksTableWidget.setItem(n, 6, i)
445 i = QTableWidgetItem(QString("%1/%2").arg(lat).arg(lng))
446 if flags is not None: i.setFlags(flags)
447 self.NetworksTableWidget.setItem(n, 7, i)
450 self.NetworksTableWidget.resizeColumnsToContents()
451 self.NetworksTableWidget.setSortingEnabled(True)
452 self.NetworksTableWidget.sortItems(1, Qt.DescendingOrder)
453 self.NetworksTableWidget.selectRow(0)
454 self.NetworksTableWidget.emit(SIGNAL("itemSelectionChanged()"))
458 self.NextButton.setEnabled(True)
461 self.NextButton.setEnabled(False)
464 def NetworksTableWidget_itemSelectionChanged(self):
465 row = self.NetworksTableWidget.currentRow()
466 item = self.NetworksTableWidget.item(row, 0)
467 n, ok = item.data(Qt.UserRole).toInt()
469 sec = self.networks['encryptiontype-%d' % n]
470 if sec.lower() == 'none':
471 self.setNextButton(BUTTON_CONNECT)
473 self.setNextButton(BUTTON_NEXT)
476 def clearNetworksTable(self):
477 self.DevicesTableWidget.clear()
478 self.DevicesTableWidget.setRowCount(0)
479 self.DevicesTableWidget.setColumnCount(0)
482 def RefreshButton2_clicked(self):
483 self.clearNetworksTable()
485 QTimer.singleShot(0, self.showNetworkPage)
492 def initConfigWifiPage(self):
493 self.connect(self.ShowKeyCheckBox, SIGNAL("toggled(bool)"), self.ShowKeyCheckBox_toggled)
496 def showConfigWifiPage(self):
497 self.setNextButton(BUTTON_CONNECT)
498 self.SSIDLabel.setText(self.network)
500 font.setPointSize(12)
501 self.SSIDLabel.setFont(font)
502 self.KeyLineEdit.setText(QString())
503 self.ShowKeyCheckBox.setChecked(False)
504 self.StrengthIcon.setPixmap(load_pixmap('signal%d' % self.ss, 'other'))
505 self.ConfigureIcon.setPixmap(load_pixmap('info', '16x16'))
506 self.KeysIcon.setPixmap(load_pixmap('keys', '32x32'))
508 if 'wpa' in self.security.lower():
509 self.WPARadioButton.setChecked(True)
511 elif 'wep' in self.security.lower():
512 self.WEPRadioButton.setChecked(True)
514 self.KeyLineEdit.setFocus()
515 self.KeyLineEdit.setEchoMode(QLineEdit.Password)
516 self.displayPage(PAGE_CONFIGURE_WIFI)
519 def ShowKeyCheckBox_toggled(self, b):
521 self.KeyLineEdit.setEchoMode(QLineEdit.Normal)
523 self.KeyLineEdit.setEchoMode(QLineEdit.Password)
530 def initExitPage(self):
531 self.connect(self.PageSpinBox, SIGNAL("valueChanged(int)"), self.PageSpinBox_valueChanged)
532 self.RefreshTimer = QTimer(self)
533 self.connect(self.RefreshTimer, SIGNAL('timeout()'), self.RefreshTimer_timeout)
536 self.PageSpinBox.setMinimum(1)
539 def showExitPage(self):
540 self.setNextButton(BUTTON_FINISH)
541 self.NextButton.setEnabled(False)
542 self.CancelButton.setEnabled(True)
543 self.SSIDLabel_2.setText(QString(self.network))
546 self.success = SUCCESS_NOT_CONNECTED
551 self.ip,_,addressmode, subnetmask, gateway, pridns, sec_dns= self.wifiObj.getIPConfiguration(self.dev, self.adapterName)
552 vsa_codes = self.wifiObj.getVSACodes(self.dev, self.adapterName)
553 ss_max, ss_min, ss_val, ss_dbm = self.wifiObj.getSignalStrength(self.dev, self.adapterName,self.network, self.adaptor_id)
554 self.hn = self.wifiObj.getHostname(self.dev)
562 if addressmode.lower() == 'dhcp':
563 self.success = SUCCESS_CONNECTED
565 elif addressmode.lower() == 'autoip':
566 self.success = SUCCESS_AUTO_IP
568 if self.ip == '0.0.0.0':
569 self.success = SUCCESS_NOT_CONNECTED
573 if self.success == SUCCESS_NOT_CONNECTED:
574 self.pages.append((self.__tr("<b>Your printer has not been connected to the wireless network.</b> A valid connection to a wireless network can take up to 2 minutes. This screen will automatically refresh every %1 seconds.<p>If your printer fails to connect within a reasonable time, there may be a problem with your configuration.").arg(REFRESH_INTERVAL), load_pixmap('error', '16x16')))
575 self.RefreshTimer.start(REFRESH_INTERVAL * 1000)
577 elif self.success == SUCCESS_AUTO_IP:
578 self.pages.append((self.__tr("Your printer has been connected to the wireless network, but it has been assigned an address which may not be usable."), load_pixmap('warning', '16x16')))
579 self.RefreshTimer.start(REFRESH_INTERVAL * 1000)
581 else: # SUCCESS_CONNECTED
583 self.pages.append((self.__tr("Your printer has been successfully configured on the wireless network. You may now unplug the USB cable. To setup the printer, now run <pre>hp-setup.</pre>"), load_pixmap('info', '16x16')))
585 self.pages.append((self.__tr("Your printer has been successfully configured on the wireless network. You may now unplug the USB cable."), load_pixmap('info', '16x16')))
586 self.CancelButton.setEnabled(False)
587 self.BackButton.setEnabled(False)
588 self.RefreshTimer.stop()
590 if addressmode is None:
591 self.AddressModeLabel.setText(self.__tr("Unknown"))
593 self.AddressModeLabel.setText(QString(addressmode))
596 self.HostnameLabel.setText(self.__tr("Unknown"))
598 self.HostnameLabel.setText(QString(self.hn))
600 self.IPAddressLabel.setText(QString(self.ip))
601 self.GatewayLabel.setText(QString(gateway))
602 self.DNSLabel.setText(QString(pridns))
603 self.NextButton.setEnabled(True)
605 self.SignalStrengthLabel.setText(QString("%1/%2 (%3 dBm)").arg(ss_val).arg(ss_max).arg(ss_dbm))
606 self.SignalStrengthIcon.setPixmap(load_pixmap('signal%d' % ss_val, 'other'))
608 for c, s in vsa_codes:
610 if ss.startswith("info"):
611 pixmap = load_pixmap('info', '16x16')
613 elif ss.startswith("warn"):
614 pixmap = load_pixmap('warning', '16x16')
616 elif ss.startswith("crit"):
617 pixmap = load_pixmap('error', '16x16')
620 pixmap = load_pixmap('info', '16x16')
622 self.pages.append((device.queryString("vsa_%s" % str(c).zfill(3)), pixmap))
624 num_pages = len(self.pages)
625 self.PageSpinBox.setMaximum(num_pages)
626 self.PageSpinBox.setEnabled(num_pages>1)
627 self.PageSpinBox.setValue(1)
628 self.PageLabel.setEnabled(num_pages>1)
629 self.PageLabel2.setEnabled(num_pages>1)
630 self.PageLabel.setText(self.__tr("of %1").arg(num_pages))
632 self.ExitLabel.setText(self.pages[self.page_index][0])
633 self.ExitIcon.setPixmap(self.pages[self.page_index][1])
634 self.displayPage(PAGE_EXIT)
637 def PageSpinBox_valueChanged(self, i):
638 self.page_index = i-1
639 self.ExitLabel.setText(self.pages[self.page_index][0])
640 self.ExitIcon.setPixmap(self.pages[self.page_index][1])
643 def RefreshTimer_timeout(self):
651 def associate(self, key=u''):
655 alg, mode, secretid = self.wifiObj.getCryptoSuite(self.dev, self.adapterName)
660 log.debug("Crypto algorithm: %s" % alg)
661 log.debug("Crypto mode: %s" % mode)
668 ret = self.wifiObj.associate(self.dev, self.adapterName, self.network, self.mode, self.security, key)
680 def NextButton_clicked(self):
681 p = self.StackedWidget.currentIndex()
683 self.showDevicesPage()
685 elif p == PAGE_DEVICES:
686 row = self.DevicesTableWidget.currentRow()
688 self.device_uri = self.DevicesTableWidget.item(row, 0).device_uri
689 self.mq = device.queryModelByURI(self.device_uri)
691 self.getWifiObject(self.mq['wifi-config'])
692 back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri)
693 self.model = models.normalizeModelName(model).lower()
695 self.showNetworkPage()
697 elif p == PAGE_NETWORK:
698 self.security = 'None'
699 self.mode = 'Infrastructure'
701 row = self.NetworksTableWidget.currentRow()
703 i = self.NetworksTableWidget.item(row, 0)
705 self.network = unicode(i.text())
706 log.debug("Selected network SSID: %s" % self.network)
707 self.n, ok = i.data(Qt.UserRole).toInt()
709 self.security = self.networks['encryptiontype-%d' % self.n]
710 log.debug("Security: %s" % self.security)
712 self.mode = self.networks['communicationmode-%d' % self.n]
713 log.debug("Mode: %s" % self.mode)
715 self.ss = self.networks['signalstrength-%d' % self.n]
716 log.debug("Signal strength: %s" % self.ss)
718 if self.security.lower() != 'none':
719 self.showConfigWifiPage()
721 # Skip config page if no security to setup
723 self.showAssociateProgressDialog()
726 elif p == PAGE_CONFIGURE_WIFI:
727 key = unicode(self.KeyLineEdit.text())
729 self.showAssociateProgressDialog()
733 if self.dev is not None:
739 log.error("Invalid page!") # shouldn't happen!
742 def showAssociateProgressDialog(self):
743 AssociateProgressDialog = QProgressDialog(self.__tr("Waiting for printer to connect to the wireless network..."), self.__tr("Cancel"), 0, ASSOCIATE_DELAY, self)
744 AssociateProgressDialog.setWindowTitle(self.__tr("HP Device Manager - Please wait..."))
745 AssociateProgressDialog.setWindowModality(Qt.WindowModal)
746 AssociateProgressDialog.setMinimumDuration(0)
747 AssociateProgressDialog.forceShow()
749 for x in range(ASSOCIATE_DELAY):
750 AssociateProgressDialog.setValue(x)
754 if AssociateProgressDialog.wasCanceled():
758 AssociateProgressDialog.setValue(ASSOCIATE_DELAY)
759 AssociateProgressDialog.close()
762 if self.dev is not None:
768 def BackButton_clicked(self):
769 p = self.StackedWidget.currentIndex()
770 if p == PAGE_DEVICES:
774 elif p == PAGE_NETWORK:
775 self.showDevicesPage()
777 elif p == PAGE_CONFIGURE_WIFI:
778 self.showNetworkPage()
781 self.RefreshTimer.stop()
782 if self.security.lower() != 'none':
783 self.showConfigWifiPage()
785 self.showNetworkPage()
788 log.error("Invalid page!") # shouldn't happen!
791 def CancelButton_clicked(self):
792 if self.dev is not None:
798 def displayPage(self, page):
799 self.StackedWidget.setCurrentIndex(page)
800 self.updateStepText(page)
803 def setNextButton(self, typ=BUTTON_FINISH):
804 if typ == BUTTON_NEXT:
805 self.NextButton.setText(self.__tr("Next >"))
807 elif typ == BUTTON_FINISH:
808 self.NextButton.setText(self.__tr("Finish"))
810 elif typ == BUTTON_CONNECT:
811 self.NextButton.setText(self.__tr("Connect"))
814 def updateStepText(self, p):
815 self.StepText.setText(self.__tr("Step %1 of %2").arg(p+1).arg(self.max_page+1))
818 def showIOError(self, e):
819 FailureUI(self, self.__tr("<b>An I/O error occurred.</b><p>Please check the USB connection to your printer and try again.</p>(%1)").arg(QString(e[0])))
821 if self.dev is not None:
827 def __tr(self,s,c = None):
828 return qApp.translate("WifiSetupDialog",s,c)
830 # The Wifi object here is not actual object, Dynamically relevant modules are selected based on
831 # wifi-config value in the models file.
832 def getWifiObject(self,wifiConfVal):
833 if wifiConfVal == WIFI_CONFIG_LEDM:
834 self.wifiObj = LedmWifi