234
234
norm_model = models.normalizeModelName(model).lower()
236
core = core_install.CoreInstall()
236
core = core_install.CoreInstall(core_install.MODE_CHECK)
237
237
core.set_plugin_version()
238
238
plugin = self.mq.get('plugin', PLUGIN_NONE)
239
239
plugin_reason = self.mq.get('plugin-reason', PLUGIN_REASON_NONE)
240
if plugin > PLUGIN_NONE and not core.check_for_plugin():
240
if plugin > PLUGIN_NONE and core.check_for_plugin() != PLUGIN_INSTALLED:
241
241
ok, sudo_ok = pkit.run_plugin_command(plugin == PLUGIN_REQUIRED, plugin_reason)
243
243
self.FailureUI(self.__tr("<b>Unable to find an appropriate su/sudo utility to run hp-plugin.</b><p>Install kdesu, gnomesu, or gksu.</p>"))
245
if not ok or not core.check_for_plugin():
245
if not ok or core.check_for_plugin() != PLUGIN_INSTALLED:
246
246
if plugin == PLUGIN_REQUIRED:
247
247
self.FailureUI(self.__tr("<b>The printer you are trying to setup requires a binary driver plug-in and it failed to install.</b><p>Please check your internet connection and try again.</p><p>Visit <u>http://hplipopensource.com</u> for more information.</p>"))
536
536
if ppds is None or not ppds:
537
537
ppds = cups.getSystemPPDs()
541
default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')
542
stripped_model = cups.stripModel2(models.normalizeModelName(model).lower())
544
self.ppd = cups.getPPDFile2(stripped_model, ppds)
539
self.ppd = cups.getPPDFile2(self.mq, model , ppds)
545
540
log.debug(self.ppd)
546
541
self.ppdListView.clear()
548
543
if self.ppd is not None:
549
#for ppd in self.ppd_dict:
550
544
PPDListViewItem(self.ppdListView, self.ppd[0], self.ppd[1])
552
# i = self.ppdListView.firstChild()
553
# self.ppdListView.setCurrentItem(i)
554
# self.ppdListView.setSelected(i, True)
555
# self.ppd_file = self.ppdListView.currentItem().ppd_file
556
546
self.ppd_file = self.ppd[0]
557
547
log.debug(self.ppd_file)
597
587
printer_name = default_model
589
installed_printer_names = device.getSupportedCUPSPrinterNames(['hp'])
599
590
# Check for duplicate names
600
if self.device_uri in self.installed_print_devices and \
601
printer_name in self.installed_print_devices[self.device_uri]:
591
if (self.device_uri in self.installed_print_devices and printer_name in self.installed_print_devices[self.device_uri]) \
592
or (printer_name in installed_printer_names):
604
595
t = printer_name + "_%d" % i
605
if t not in self.installed_print_devices[self.device_uri]:
596
if (t not in installed_printer_names) and (self.device_uri not in self.installed_print_devices or t not in self.installed_print_devices[self.device_uri]):
606
597
printer_name += "_%d" % i
703
694
default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')
705
696
fax_name = default_model + "_fax"
697
installed_fax_names = device.getSupportedCUPSPrinterNames(['hpfax'])
707
699
# Check for duplicate names
708
if self.fax_uri in self.installed_fax_devices and \
709
fax_name in self.installed_fax_devices[self.fax_uri]:
700
if (self.fax_uri in self.installed_fax_devices and fax_name in self.installed_fax_devices[self.fax_uri]) \
701
or (fax_name in installed_fax_names):
710
702
#if fax_name in self.installed_queues or fax_name == self.printer_name:
713
705
t = fax_name + "_%d" % i
714
if t not in self.installed_fax_devices[self.fax_uri]:
706
if (t not in installed_fax_names) and (self.fax_uri not in self.installed_fax_devices or t not in self.installed_fax_devices[self.fax_uri]):
715
707
fax_name += "_%d" % i
877
869
self.FailureUI(self.__tr("<b>Printer queue setup failed.</b><p>Please restart CUPS and try again."))
880
#service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.device_uri)
871
# sending Event to add this device in hp-systray
872
utils.sendEvent(EVENT_CUPS_QUEUES_CHANGED,self.device_uri, self.printer_name)
883
874
QApplication.restoreOverrideCursor()
885
876
def setupFax(self):
886
877
QApplication.setOverrideCursor(QApplication.waitCursor)
888
if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_MARVELL:
889
fax_ppd_name = "HP-Fax3-hplip" # Fixed width (2528 pixels) and 300dpi rendering
891
if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_SOAP or self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDMSOAP:
892
fax_ppd_name = "HP-Fax2-hplip" # Fixed width (2528 pixels) and 300dpi rendering
894
if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDM:
895
fax_ppd_name = "HP-Fax4-hplip" # Fixed width (1728 pixels) and 200dpi rendering
898
fax_ppd_name = "HP-Fax-hplip" # Standard
903
log.debug("Searching for fax file %s..." % fax_ppd_name)
905
ppd_dir = sys_conf.get('dirs', 'ppd')
906
for f in utils.walkFiles(ppd_dir, pattern="HP-Fax*.ppd*", abs_paths=True):
910
if f.find(fax_ppd_name) >= 0:
912
log.debug("Found PDD file: %s" % fax_ppd)
913
log.debug("Nickname: %s" % cups.getPPDDescription(fax_ppd))
878
back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
879
device.parseDeviceURI(self.device_uri)
880
norm_model = models.normalizeModelName(model).lower()
881
fax_ppd,fax_ppd_name, nick = cups.getFaxPPDFile(self.mq, norm_model)
916
884
QApplication.restoreOverrideCursor()
917
885
log.error("Fax PPD file not found.")
962
930
self.FailureUI(self.__tr("<b>Fax queue setup failed.</b><p>Please restart CUPS and try again."))
966
#service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.fax_uri)
932
# sending Event to add this device in hp-systray
933
utils.sendEvent(EVENT_CUPS_QUEUES_CHANGED,self.fax_uri, self.fax_name)
968
935
QApplication.restoreOverrideCursor()
1061
1028
self.connect(self.okPushButton,SIGNAL("clicked()"),self.accept)
1062
1029
self.connect(self.passwordLineEdit,SIGNAL("returnPressed()"),self.accept)
1031
def setDefaultUsername(self, defUser, allowUsernameEdit = True):
1032
self.usernameLineEdit.setText(defUser)
1033
if not allowUsernameEdit:
1034
self.usernameLineEdit.setReadOnly(True)
1035
self.usernameLineEdit.setPaletteBackgroundColor(QColor("lightgray"))
1063
1037
def getUsername(self):
1064
1038
return unicode(self.usernameLineEdit.text())
1077
1051
return qApp.translate("PasswordDialog",s,c)
1081
def showPasswordUI(prompt):
1054
def showPasswordUI(prompt, userName=None, allowUsernameEdit=True):
1083
1056
dlg = PasswordDialog(prompt, None)
1058
if userName != None:
1059
dlg.setDefaultUsername(userName, allowUsernameEdit)
1085
1061
if dlg.exec_loop() == QDialog.Accepted:
1086
1062
return (dlg.getUsername(), dlg.getPassword())