Esempio n. 1
0
    def setupFax(self):
        QApplication.setOverrideCursor(QApplication.waitCursor)
        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
                device.parseDeviceURI(self.device_uri)
        norm_model = models.normalizeModelName(model).lower()
        fax_ppd,fax_ppd_name, nick = cups.getFaxPPDFile(self.mq, norm_model)
        # Fax ppd not found
        if not fax_ppd:
            QApplication.restoreOverrideCursor()
            log.error("Fax PPD file not found.")

            if QMessageBox.warning(self, self.__tr("Unable to find HP fax PPD file."),
                self.__tr("The PPD file (%1.ppd) needed to setup the fax queue was not found.").arg(fax_ppd_name),
                self.__tr("Browse to file..."), # button 0
                self.__tr("Quit") # button 1
                ) == 0: # Browse

                while True:
                    ppd_dir = sys_conf.get('dirs', 'ppd')
                    fax_ppd = unicode(QFileDialog.getOpenFileName(ppd_dir,
                        "HP Fax PPD Files (*.ppd *.ppd.gz);;All Files (*)", self,
                        "open file dialog", "Choose the fax PPD file"))

                    if not fax_ppd: # user hit cancel
                        return

                    if os.path.exists(fax_ppd):
                        n = cups.getPPDDescription(fax_ppd)
                        if n == nick:
                            break
                        else:
                            self.FailureUI(self.__tr("<b>Incorrect fax PPD file.</b><p>The fax PPD file must have a nickname of '%1', not '%1'.").arg(nick).arg(n))
                    else:
                        self.FailureUI(self.__tr("<b>File not found.</b><p>hp-setup cannot find the file %1").arg(fax_ppd))

            else: # Quit
                return

        cups.setPasswordPrompt("You do not have permission to add a fax device.")
        if not os.path.exists(fax_ppd):
            status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                self.fax_uri, self.fax_location, '', fax_ppd,  self.fax_desc)
        else:
            status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                self.fax_uri, self.fax_location, fax_ppd, '', self.fax_desc)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])

        log.debug(self.installed_fax_devices)

        if self.fax_uri not in self.installed_fax_devices or \
            self.fax_name not in self.installed_fax_devices[self.fax_uri]:

            self.FailureUI(self.__tr("<b>Fax queue setup failed.</b><p>Please restart CUPS and try again."))
        else:
            # sending Event to add this device in hp-systray
            utils.sendEvent(EVENT_CUPS_QUEUES_CHANGED,self.fax_uri, self.fax_name)

        QApplication.restoreOverrideCursor()
Esempio n. 2
0
    def setupPrinter(self):
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            cups.setPasswordPrompt("You do not have permission to add a printer.")
            if not os.path.exists(self.print_ppd[0]): # assume foomatic: or some such
                status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri,
                    self.print_location, '', self.print_ppd[0], self.print_desc)
            else:
                status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri,
                    self.print_location, self.print_ppd[0], '', self.print_desc)

            log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
            self.installed_print_devices = device.getSupportedCUPSDevices(['hp'])

            log.debug(self.installed_print_devices)

            if self.device_uri not in self.installed_print_devices or \
                self.printer_name not in self.installed_print_devices[self.device_uri]:

                QApplication.restoreOverrideCursor()
                if os.geteuid!=0 and utils.addgroup()!=[]:
                    FailureUI(self, self.__tr("<b>Printer queue setup failed. Could not connect to CUPS Server</b><p>Is user added to %s group(s)" %utils.list_to_string(utils.addgroup())))
            else:
                # TODO:
                #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.device_uri)
                pass

        finally:
            QApplication.restoreOverrideCursor()
Esempio n. 3
0
    def setDefaultFaxName(self):
        self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])
        log.debug(self.installed_fax_devices)

        self.fax_uri = self.device_uri.replace('hp:', 'hpfax:')

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.fax_uri)
        default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')

        fax_name = default_model + "_fax"
        installed_fax_names = device.getSupportedCUPSPrinterNames(['hpfax'])

        # Check for duplicate names
        if (self.fax_uri in self.installed_fax_devices and fax_name in self.installed_fax_devices[self.fax_uri]) \
           or (fax_name in installed_fax_names):
        #if fax_name in self.installed_queues or fax_name == self.printer_name:
                i = 2
                while True:
                    t = fax_name + "_%d" % i
                    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]):
                        fax_name += "_%d" % i
                        break
                    i += 1

        self.fax_name_ok = True
        self.faxNameLineEdit.setText(fax_name)
        self.faxNameLineEdit.setPaletteBackgroundColor(self.bg)
        self.defaultFaxNamePushButton.setEnabled(False)
        self.fax_name = fax_name
Esempio n. 4
0
    def setDefaultPrinterName(self):
        self.installed_print_devices = device.getSupportedCUPSDevices(['hp'])
        #self.installed_print_devices = device.getSupportedCUPSDevices('*')
        log.debug(self.installed_print_devices)

        self.installed_queues = [p.name for p in cups.getPrinters()]

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri)
        default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')

        printer_name = default_model

        installed_printer_names = device.getSupportedCUPSPrinterNames(['hp'])
        # Check for duplicate names
        if (self.device_uri in self.installed_print_devices and printer_name in self.installed_print_devices[self.device_uri]) \
           or (printer_name in installed_printer_names):
                i = 2
                while True:
                    t = printer_name + "_%d" % i
                    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]):
                        printer_name += "_%d" % i
                        break
                    i += 1

        self.printer_name_ok = True
        self.printerNameLineEdit.setText(printer_name)
        log.debug(printer_name)
        self.printerNameLineEdit.setPaletteBackgroundColor(self.bg)
        self.defaultPrinterNamePushButton.setEnabled(False)
        self.printer_name = printer_name
    def setDefaultPrinterName(self):
        self.installed_print_devices = device.getSupportedCUPSDevices(['hp'])
        #self.installed_print_devices = device.getSupportedCUPSDevices('*')
        log.debug(self.installed_print_devices)

        self.installed_queues = [p.name for p in cups.getPrinters()]

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri)
        default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')

        printer_name = default_model

        # Check for duplicate names
        if self.device_uri in self.installed_print_devices and \
            printer_name in self.installed_print_devices[self.device_uri]:
                i = 2
                while True:
                    t = printer_name + "_%d" % i
                    if t not in self.installed_print_devices[self.device_uri]:
                        printer_name += "_%d" % i
                        break
                    i += 1

        self.printer_name_ok = True
        self.printerNameLineEdit.setText(printer_name)
        log.debug(printer_name)
        self.printerNameLineEdit.setPaletteBackgroundColor(self.bg)
        self.defaultPrinterNamePushButton.setEnabled(False)
        self.printer_name = printer_name
    def setupPrinter(self):
        QApplication.setOverrideCursor(QApplication.waitCursor)

        cups.setPasswordPrompt("You do not have permission to add a printer.")
        #if self.ppd_file.startswith("foomatic:"):
        if not os.path.exists(self.ppd_file): # assume foomatic: or some such
            status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri,
                self.location, '', self.ppd_file, self.desc)
        else:
            status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri,
                self.location, self.ppd_file, '', self.desc)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        self.installed_print_devices = device.getSupportedCUPSDevices(['hp'])

        log.debug(self.installed_print_devices)

        if self.device_uri not in self.installed_print_devices or \
            self.printer_name not in self.installed_print_devices[self.device_uri]:

            self.FailureUI(self.__tr("<b>Printer queue setup failed.</b><p>Please restart CUPS and try again."))
        else:
            # TODO:
            #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.device_uri)
            pass

        QApplication.restoreOverrideCursor()
    def setDefaultFaxName(self):
        self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])
        log.debug(self.installed_fax_devices)

        self.fax_uri = self.device_uri.replace('hp:', 'hpfax:')

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.fax_uri)
        default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')

        fax_name = default_model + "_fax"

        # Check for duplicate names
        if self.fax_uri in self.installed_fax_devices and \
            fax_name in self.installed_fax_devices[self.fax_uri]:
        #if fax_name in self.installed_queues or fax_name == self.printer_name:
                i = 2
                while True:
                    t = fax_name + "_%d" % i
                    if t not in self.installed_fax_devices[self.fax_uri]:
                        fax_name += "_%d" % i
                        break
                    i += 1

        self.fax_name_ok = True
        self.faxNameLineEdit.setText(fax_name)
        self.faxNameLineEdit.setPaletteBackgroundColor(self.bg)
        self.defaultFaxNamePushButton.setEnabled(False)
        self.fax_name = fax_name
Esempio n. 8
0
    def setDefaultPrinterName(self):
        self.installed_print_devices = device.getSupportedCUPSDevices(['hp'])
        log.debug(self.installed_print_devices)

        self.installed_queues = [p.name for p in cups.getPrinters()]

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri)
        default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')

        printer_name = default_model
        installed_printer_names = device.getSupportedCUPSPrinterNames(['hp'])
        # Check for duplicate names
        if (self.device_uri in self.installed_print_devices and printer_name in self.installed_print_devices[self.device_uri]) \
           or (printer_name in installed_printer_names):
                i = 2
                while True:
                    t = printer_name + "_%d" % i
                    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]):
                        printer_name += "_%d" % i
                        break
                    i += 1

        self.printer_name_ok = True
        self.PrinterNameLineEdit.setText(printer_name)
        log.debug(printer_name)
        self.printer_name = printer_name
Esempio n. 9
0
    def setupFax(self):
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            cups.setPasswordPrompt("You do not have permission to add a fax device.")
            if not os.path.exists(self.fax_ppd):
                status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                    self.fax_uri, self.fax_location, '', self.fax_ppd,  self.fax_desc)
            else:
                status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                    self.fax_uri, self.fax_location, self.fax_ppd, '', self.fax_desc)

            log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
            self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])

            log.debug(self.installed_fax_devices)

            if self.fax_uri not in self.installed_fax_devices or \
                self.fax_name not in self.installed_fax_devices[self.fax_uri]:

                QApplication.restoreOverrideCursor()
                FailureUI(self, self.__tr("<b>Fax queue setup failed.</b><p>Please restart CUPS and try again."))
            else:
                pass
                # TODO:
                #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.fax_uri)

        finally:
            QApplication.restoreOverrideCursor()
Esempio n. 10
0
    def setupPrinter(self):
        QApplication.setOverrideCursor(QApplication.waitCursor)

        cups.setPasswordPrompt("You do not have permission to add a printer.")
        #if self.ppd_file.startswith("foomatic:"):
        if not os.path.exists(self.ppd_file): # assume foomatic: or some such
            status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri,
                self.location, '', self.ppd_file, self.desc)
        else:
            status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri,
                self.location, self.ppd_file, '', self.desc)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        self.installed_print_devices = device.getSupportedCUPSDevices(['hp'])

        log.debug(self.installed_print_devices)

        if self.device_uri not in self.installed_print_devices or \
            self.printer_name not in self.installed_print_devices[self.device_uri]:

            self.FailureUI(self.__tr("<b>Printer queue setup failed.</b><p>Please restart CUPS and try again."))
        else:
            # sending Event to add this device in hp-systray
            utils.sendEvent(EVENT_CUPS_QUEUES_CHANGED,self.device_uri, self.printer_name)

        QApplication.restoreOverrideCursor()
Esempio n. 11
0
    def setDefaultFaxName(self):
        self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])
        log.debug(self.installed_fax_devices)

        self.fax_uri = self.device_uri.replace('hp:', 'hpfax:')

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.fax_uri)
        default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')

        fax_name = default_model + "_fax"
        installed_fax_names = device.getSupportedCUPSPrinterNames(['hpfax'])
        # Check for duplicate names
        if (self.fax_uri in self.installed_fax_devices and fax_name in self.installed_fax_devices[self.fax_uri]) \
           or (fax_name in installed_fax_names):
                i = 2
                while True:
                    t = fax_name + "_%d" % i
                    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]):
                        fax_name += "_%d" % i
                        break
                    i += 1

        self.fax_name_ok = True
        self.FaxNameLineEdit.setText(fax_name)
        self.fax_name = fax_name
Esempio n. 12
0
    def setupPrinter(self):
        status = cups.IPP_BAD_REQUEST
        QApplication.setOverrideCursor(QApplication.waitCursor)

        #if self.ppd_file.startswith("foomatic:"):
        if not os.path.exists(self.ppd_file):  # assume foomatic: or some such
            add_prnt_args = (self.printer_name.encode('utf8'), self.device_uri,
                             self.location, '', self.ppd_file, self.desc)
        else:
            add_prnt_args = (self.printer_name.encode('utf8'), self.device_uri,
                             self.location, self.ppd_file, '', self.desc)

        status, status_str = cups.cups_operation(cups.addPrinter, GUI_MODE,
                                                 'qt3', self, *add_prnt_args)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        log.debug(device.getSupportedCUPSDevices(['hp']))

        if status != cups.IPP_OK:
            self.FailureUI(
                self.__tr("<b>Printer queue setup failed.</b><p>Error : %s " %
                          status_str))
        else:
            # sending Event to add this device in hp-systray
            utils.sendEvent(EVENT_CUPS_QUEUES_ADDED, self.device_uri,
                            self.printer_name)

        QApplication.restoreOverrideCursor()
        return status
Esempio n. 13
0
    def setDefaultFaxName(self):
        self.installed_fax_devices = device.getSupportedCUPSDevices(["hpfax"])
        log.debug(self.installed_fax_devices)

        self.fax_uri = self.device_uri.replace("hp:", "hpfax:")

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.fax_uri)
        default_model = utils.xstrip(model.replace("series", "").replace("Series", ""), "_")

        fax_name = default_model + "_fax"
        installed_fax_names = device.getSupportedCUPSPrinterNames(["hpfax"])

        # Check for duplicate names
        if (self.fax_uri in self.installed_fax_devices and fax_name in self.installed_fax_devices[self.fax_uri]) or (
            fax_name in installed_fax_names
        ):
            # if fax_name in self.installed_queues or fax_name == self.printer_name:
            i = 2
            while True:
                t = fax_name + "_%d" % i
                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]
                ):
                    fax_name += "_%d" % i
                    break
                i += 1

        self.fax_name_ok = True
        self.faxNameLineEdit.setText(fax_name)
        self.faxNameLineEdit.setPaletteBackgroundColor(self.bg)
        self.defaultFaxNamePushButton.setEnabled(False)
        self.fax_name = fax_name
Esempio n. 14
0
    def __init__(self, args, read_pipe):
        QApplication.__init__(self, args)

        self.menu = None
        self.read_pipe = read_pipe
        self.fmt = "80s80sI32sI80sf"
        self.fmt_size = struct.calcsize(self.fmt)
        self.timer_active = False
        self.active_icon = False
        self.user_settings = UserSettings()
        self.user_settings.load()
        self.user_settings.debug()

        self.tray_icon = QSystemTrayIcon()

        pm = load_pixmap("hp_logo", "32x32")
        self.prop_icon = QIcon(pm)

        a = load_pixmap('active', '16x16')
        painter = QPainter(pm)
        painter.drawPixmap(32, 0, a)
        painter.end()

        self.prop_active_icon = QIcon(pm)

        self.tray_icon.setIcon(self.prop_icon)

        self.session_bus = SessionBus()
        self.service = None

        for d in device.getSupportedCUPSDevices(back_end_filter=['hp', 'hpfax']):
            self.addDevice(d)

        self.tray_icon.setToolTip(self.__tr("HPLIP Status Service"))
        QObject.connect(self.tray_icon, SIGNAL("messageClicked()"), self.messageClicked)
        notifier = QSocketNotifier(self.read_pipe, QSocketNotifier.Read)
        QObject.connect(notifier, SIGNAL("activated(int)"), self.notifierActivated)
        QObject.connect(self.tray_icon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.trayActivated)
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        self.tray_icon.show()

        if self.user_settings.systray_visible == SYSTRAY_VISIBLE_SHOW_ALWAYS:
            self.tray_icon.setVisible(True)
        else:
            QTimer.singleShot(HIDE_INACTIVE_DELAY, self.timeoutHideWhenInactive) # show icon for awhile @ startup

        self.tray_icon.setIcon(self.prop_active_icon)
        self.active_icon = True

        if "--ignore-update-firsttime" not in args:
            self.handle_hplip_updation()

        QTimer.singleShot(SET_MENU_DELAY, self.initDone)

        self.update_timer = QTimer()
        self.update_timer.connect(self.update_timer,SIGNAL("timeout()"),self.handle_hplip_updation)
        self.update_timer.start(UPGRADE_CHECK_DELAY)
Esempio n. 15
0
    def __init__(self, args, read_pipe):
        QApplication.__init__(self, args)

        self.menu = None
        self.read_pipe = read_pipe
        self.fmt = "80s80sI32sI80sf"
        self.fmt_size = struct.calcsize(self.fmt)
        self.timer_active = False
        self.active_icon = False
        self.user_settings = UserSettings()
        self.user_settings.load()
        self.user_settings.debug()

        self.tray_icon = QSystemTrayIcon()

        pm = load_pixmap("hp_logo", "32x32")
        self.prop_icon = QIcon(pm)

        a = load_pixmap('active', '16x16')
        painter = QPainter(pm)
        painter.drawPixmap(32, 0, a)
        painter.end()

        self.prop_active_icon = QIcon(pm)

        self.tray_icon.setIcon(self.prop_icon)

        self.session_bus = SessionBus()
        self.service = None

        for d in device.getSupportedCUPSDevices(back_end_filter=['hp', 'hpfax']):
            self.addDevice(d)

        self.tray_icon.setToolTip(self.__tr("HPLIP Status Service"))
        QObject.connect(self.tray_icon, SIGNAL("messageClicked()"), self.messageClicked)
        notifier = QSocketNotifier(self.read_pipe, QSocketNotifier.Read)
        QObject.connect(notifier, SIGNAL("activated(int)"), self.notifierActivated)
        QObject.connect(self.tray_icon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.trayActivated)
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        self.tray_icon.show()

        if self.user_settings.systray_visible == SYSTRAY_VISIBLE_SHOW_ALWAYS:
            self.tray_icon.setVisible(True)
        else:
            QTimer.singleShot(HIDE_INACTIVE_DELAY, self.timeoutHideWhenInactive) # show icon for awhile @ startup

        self.tray_icon.setIcon(self.prop_active_icon)
        self.active_icon = True

        if "--ignore-update-firsttime" not in args:
            self.handle_hplip_updation()

        QTimer.singleShot(SET_MENU_DELAY, self.initDone)

        self.update_timer = QTimer()
        self.update_timer.connect(self.update_timer,SIGNAL("timeout()"),self.handle_hplip_updation)
        self.update_timer.start(UPGRADE_CHECK_DELAY)
Esempio n. 16
0
    def setupFax(self):
        status = cups.IPP_BAD_REQUEST
        QApplication.setOverrideCursor(QApplication.waitCursor)
        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
                device.parseDeviceURI(self.device_uri)
        norm_model = models.normalizeModelName(model).lower()
        fax_ppd,fax_ppd_name, nick = cups.getFaxPPDFile(self.mq, norm_model)
        # Fax ppd not found
        if not fax_ppd:
            QApplication.restoreOverrideCursor()
            log.error("Fax PPD file not found.")

            if QMessageBox.warning(self, self.__tr("Unable to find HP fax PPD file."),
                self.__tr("The PPD file (%1.ppd) needed to setup the fax queue was not found.").arg(fax_ppd_name),
                self.__tr("Browse to file..."), # button 0
                self.__tr("Quit") # button 1
                ) == 0: # Browse

                while True:
                    ppd_dir = sys_conf.get('dirs', 'ppd')
                    fax_ppd = to_unicode(QFileDialog.getOpenFileName(ppd_dir,
                        "HP Fax PPD Files (*.ppd *.ppd.gz);;All Files (*)", self,
                        "open file dialog", "Choose the fax PPD file"))

                    if not fax_ppd: # user hit cancel
                        return

                    if os.path.exists(fax_ppd):
                        n = cups.getPPDDescription(fax_ppd)
                        if n == nick:
                            break
                        else:
                            self.FailureUI(self.__tr("<b>Incorrect fax PPD file.</b><p>The fax PPD file must have a nickname of '%1', not '%1'.").arg(nick).arg(n))
                    else:
                        self.FailureUI(self.__tr("<b>File not found.</b><p>hp-setup cannot find the file %1").arg(fax_ppd))

            else: # Quit
                return

        if not os.path.exists(fax_ppd):
            status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                self.fax_uri, self.fax_location, '', fax_ppd,  self.fax_desc)
        else:
            status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                self.fax_uri, self.fax_location, fax_ppd, '', self.fax_desc)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        log.debug(device.getSupportedCUPSDevices(['hpfax']))

        if status != cups.IPP_OK:
            self.FailureUI(self.__tr("<b>Fax queue setup failed.</b><p>Error : %s "%status_str))
        else:
            # sending Event to add this device in hp-systray
            utils.sendEvent(EVENT_CUPS_QUEUES_ADDED,self.fax_uri, self.fax_name)

        QApplication.restoreOverrideCursor()
        return status
Esempio n. 17
0
    def actionPushButton_clicked(self):
        if self.path:  # path
            if not self.path.startswith('http://'):
                self.path = 'file://' + self.path

        else:
            log.info("Checking for network connection...")
            ok = utils.check_network_connection()

            if not ok:
                log.error("Network connection not detected.")
                self.FailureUI(self.__tr("Network connection not detected."))
                self.close()
                return

        log.info("Downloading plug-in from: %s" % self.path)

        status, self.path, error_str = self.pluginObj.download(
            self.path, self.plugin_download_callback)

        if status != ERROR_SUCCESS:

            self.pluginObj.deleteInstallationFiles(self.path)
            self.FailureUI(error_str)
            self.close()
            return

        if not self.pluginObj.run_plugin(self.path, GUI_MODE):
            self.pluginObj.deleteInstallationFiles(self.path)
            self.FailureUI(self.__tr("Plug-in install failed."))
            self.close()
            return

        cups_devices = device.getSupportedCUPSDevices(['hp'])  #, 'hpfax'])

        for dev in cups_devices:
            mq = device.queryModelByURI(dev)

            if mq.get('fw-download', False):

                # Download firmware if needed
                log.info(
                    log.bold("\nDownloading firmware to device %s..." % dev))
                try:
                    d = device.Device(dev)
                except Error:
                    log.error("Error opening device.")
                    continue

                if d.downloadFirmware():
                    log.info("Firmware download successful.\n")

                d.close()

        self.pluginObj.deleteInstallationFiles(self.path)
        self.SuccessUI("Plug-in install successful")
        self.close()
Esempio n. 18
0
    def actionPushButton_clicked(self):
        if self.path: # path
            if not self.path.startswith('http://'):
                self.path = 'file://' + self.path

        else:
            log.info("Checking for network connection...")
            ok = utils.check_network_connection()

            if not ok:
                log.error("Network connection not detected.")
                self.FailureUI(self.__tr("Network connection not detected."))
                self.close()
                return

        log.info("Downloading plug-in from: %s" % self.path)

        status, self.path, error_str = self.pluginObj.download(self.path, self.plugin_download_callback)

        if status != ERROR_SUCCESS:

            self.pluginObj.deleteInstallationFiles(self.path)
            self.FailureUI(error_str)
            self.close()
            return

        if not self.pluginObj.run_plugin(self.path, GUI_MODE):
            self.pluginObj.deleteInstallationFiles(self.path)
            self.FailureUI(self.__tr("Plug-in install failed."))
            self.close()
            return

        cups_devices = device.getSupportedCUPSDevices(['hp']) #, 'hpfax'])

        for dev in cups_devices:
            mq = device.queryModelByURI(dev)

            if mq.get('fw-download', False):

                # Download firmware if needed
                log.info(log.bold("\nDownloading firmware to device %s..." % dev))
                try:
                    d = device.Device(dev)
                except Error:
                    log.error("Error opening device.")
                    continue

                if d.downloadFirmware():
                    log.info("Firmware download successful.\n")

                d.close()


        self.pluginObj.deleteInstallationFiles(self.path)
        self.SuccessUI("Plug-in install successful")
        self.close()
Esempio n. 19
0
    def setDevices(self):
        if self.typ == DEVICEURICOMBOBOX_TYPE_PRINTER_ONLY:
            be_filter = ['hp']

        elif self.typ == DEVICEURICOMBOBOX_TYPE_FAX_ONLY:
            be_filter = ['hpfax']
            self.NameLabel.setText(self.__tr("Fax Device:"))

        else: # DEVICEURICOMBOBOX_TYPE_PRINTER_AND_FAX
            be_filter = ['hp', 'hpfax']

        self.devices = device.getSupportedCUPSDevices(be_filter, self.filter)
        return len(self.devices)
Esempio n. 20
0
    def setDevices(self):
        if self.typ == DEVICEURICOMBOBOX_TYPE_PRINTER_ONLY:
            be_filter = ['hp']

        elif self.typ == DEVICEURICOMBOBOX_TYPE_FAX_ONLY:
            be_filter = ['hpfax']
            self.NameLabel.setText(self.__tr("Fax Device:"))

        else: # DEVICEURICOMBOBOX_TYPE_PRINTER_AND_FAX
            be_filter = ['hp', 'hpfax']

        self.devices = device.getSupportedCUPSDevices(be_filter, self.filter)
        return len(self.devices)
Esempio n. 21
0
    def setDefaultPrinterName(self):
        self.installed_print_devices = device.getSupportedCUPSDevices(['hp'])
        #self.installed_print_devices = device.getSupportedCUPSDevices('*')
        log.debug(self.installed_print_devices)

        self.installed_queues = [p.name for p in cups.getPrinters()]

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(
            self.device_uri)
        default_model = utils.xstrip(
            model.replace('series', '').replace('Series', ''), '_')

        printer_name = default_model

        installed_printer_names = device.getSupportedCUPSPrinterNames(['hp'])
        # Check for duplicate names
        if (self.device_uri in self.installed_print_devices and printer_name in self.installed_print_devices[self.device_uri]) \
           or (printer_name in installed_printer_names):
            warn_text = self.__tr(
                "<b>One or more print queues already exist for this device: %s</b>.<br> <b>Would you like to install another print queue for this device ?</b>"
                % ', '.join([
                    printer.encode('utf-8')
                    for printer in installed_printer_names
                    if printer_name in printer
                ]))
            if (QMessageBox.warning(self, self.caption(), warn_text,
                                    QMessageBox.Yes, QMessageBox.No,
                                    QMessageBox.NoButton) == QMessageBox.Yes):

                i = 2
                while True:
                    t = printer_name + "_%d" % i
                    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]):
                        printer_name += "_%d" % i
                        break
                    i += 1
            else:
                self.close()

        self.printer_name_ok = True
        self.printerNameLineEdit.setText(printer_name)
        log.debug(printer_name)
        self.printerNameLineEdit.setPaletteBackgroundColor(self.bg)
        self.defaultPrinterNamePushButton.setEnabled(False)
        self.printer_name = printer_name
Esempio n. 22
0
    def setDefaultPrinterName(self):
        self.installed_print_devices = device.getSupportedCUPSDevices(["hp"])
        # self.installed_print_devices = device.getSupportedCUPSDevices('*')
        log.debug(self.installed_print_devices)

        self.installed_queues = [p.name for p in cups.getPrinters()]

        back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri)
        default_model = utils.xstrip(model.replace("series", "").replace("Series", ""), "_")

        printer_name = default_model

        installed_printer_names = device.getSupportedCUPSPrinterNames(["hp"])
        # Check for duplicate names
        if (
            self.device_uri in self.installed_print_devices
            and printer_name in self.installed_print_devices[self.device_uri]
        ) or (printer_name in installed_printer_names):
            warn_text = self.__tr(
                "<b>One or more print queues already exist for this device: %s</b>.<br> <b>Would you like to install another print queue for this device ?</b>"
                % ", ".join([printer.encode("utf-8") for printer in installed_printer_names if printer_name in printer])
            )
            if (
                QMessageBox.warning(
                    self, self.caption(), warn_text, QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton
                )
                == QMessageBox.Yes
            ):

                i = 2
                while True:
                    t = printer_name + "_%d" % i
                    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]
                    ):
                        printer_name += "_%d" % i
                        break
                    i += 1
            else:
                self.close()

        self.printer_name_ok = True
        self.printerNameLineEdit.setText(printer_name)
        log.debug(printer_name)
        self.printerNameLineEdit.setPaletteBackgroundColor(self.bg)
        self.defaultPrinterNamePushButton.setEnabled(False)
        self.printer_name = printer_name
Esempio n. 23
0
    def setupPrinter(self):
        status = cups.IPP_BAD_REQUEST
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            if not os.path.exists(self.print_ppd[0]): # assume foomatic: or some such
                add_prnt_args = (self.printer_name.encode('utf8'), self.device_uri, self.print_location, '', self.print_ppd[0], self.print_desc)
            else:
                add_prnt_args = (self.printer_name.encode('utf8'), self.device_uri, self.print_location, self.print_ppd[0], '', self.print_desc)

            status, status_str = cups.cups_operation(cups.addPrinter, GUI_MODE, 'qt4', self, *add_prnt_args)
            log.debug(device.getSupportedCUPSDevices(['hp']))

            if status != cups.IPP_OK:
                QApplication.restoreOverrideCursor()
                FailureUI(self, self.__tr("<b>Printer queue setup failed.</b> <p>Error : %s"%status_str))
            else:
                # sending Event to add this device in hp-systray
                utils.sendEvent(EVENT_CUPS_QUEUES_ADDED,self.device_uri, self.printer_name)

        finally:
            QApplication.restoreOverrideCursor()
        return status
Esempio n. 24
0
    def setupPrinter(self):
        status = cups.IPP_BAD_REQUEST
        QApplication.setOverrideCursor(QApplication.waitCursor)

        # if self.ppd_file.startswith("foomatic:"):
        if not os.path.exists(self.ppd_file):  # assume foomatic: or some such
            add_prnt_args = (self.printer_name, self.device_uri, self.location, "", self.ppd_file, self.desc)
        else:
            add_prnt_args = (self.printer_name, self.device_uri, self.location, self.ppd_file, "", self.desc)

        status, status_str = cups.cups_operation(cups.addPrinter, GUI_MODE, "qt3", self, *add_prnt_args)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        log.debug(device.getSupportedCUPSDevices(["hp"]))

        if status != cups.IPP_OK:
            self.FailureUI(self.__tr("<b>Printer queue setup failed.</b><p>Error : %s " % status_str))
        else:
            # sending Event to add this device in hp-systray
            utils.sendEvent(EVENT_CUPS_QUEUES_ADDED, self.device_uri, self.printer_name)

        QApplication.restoreOverrideCursor()
        return status
Esempio n. 25
0
    def setupFax(self):
        status = cups.IPP_BAD_REQUEST
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            if not os.path.exists(self.fax_ppd):
                status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                    self.fax_uri, self.fax_location, '', self.fax_ppd,  self.fax_desc)
            else:
                status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                    self.fax_uri, self.fax_location, self.fax_ppd, '', self.fax_desc)

            log.debug(device.getSupportedCUPSDevices(['hpfax']))

            if status != cups.IPP_OK:
                QApplication.restoreOverrideCursor()
                FailureUI(self, self.__tr("<b>Fax queue setup failed.</b><p>Error : %s"%status_str))
            else:
                 # sending Event to add this device in hp-systray
                utils.sendEvent(EVENT_CUPS_QUEUES_ADDED,self.fax_uri, self.fax_name)
                
        finally:
            QApplication.restoreOverrideCursor()

        return status
Esempio n. 26
0
    def notifierActivated(self, s):
        m = ''
        while True:
            try:
                r, w, e = select.select([self.read_pipe], [], [self.read_pipe], 1.0)
            except select.error:
                log.debug("Error in select()")
                break

            if e:
                log.error("Pipe error: %s" % e)
                break

            if r:
                #m = ''.join([m, os.read(self.read_pipe, self.fmt_size)])
                m = os.read(self.read_pipe, self.fmt_size)
                while len(m) >= self.fmt_size:
                    event = device.Event(*[x.rstrip(b'\x00').decode('utf-8') if isinstance(x, bytes) else x for x in struct.unpack(self.fmt, m[:self.fmt_size])])
                    m = m[self.fmt_size:]                   

                    if event.event_code == EVENT_ERROR_NO_PROBED_DEVICES_FOUND:
                        newmsg = "HPLIP cannot detect devices in your network. This may be due to existing firewall settings blocking the required ports like (5353/udp). When you are in a trusted network environment, you may open the ports for network services like mdns and slp in the firewall. For detailed steps follow the link.\n\n http://hplipopensource.com/node/375"
                        FailureUI(None, newmsg, "")
                        continue
                    
                    if event.event_code == EVENT_CUPS_QUEUES_REMOVED or event.event_code == EVENT_CUPS_QUEUES_ADDED:
                        self.resetDevice()
                        for d in device.getSupportedCUPSDevices(back_end_filter=['hp', 'hpfax']):
                            self.addDevice(d)
                            
                        self.setMenu()

                    if event.event_code == EVENT_USER_CONFIGURATION_CHANGED:
                        log.debug("Re-reading configuration (EVENT_USER_CONFIGURATION_CHANGED)")
                        self.user_settings.load()
                        self.user_settings.debug()

                    elif event.event_code == EVENT_SYSTEMTRAY_EXIT:
                        self.quit()
                        return

                    if self.user_settings.systray_visible in \
                        (SYSTRAY_VISIBLE_SHOW_ALWAYS, SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE):
                        
                        log.debug("Showing...")
                        self.tray_icon.setVisible(True)

                        if event.event_code == EVENT_DEVICE_UPDATE_ACTIVE:
                            if not self.active_icon:
                                self.tray_icon.setIcon(self.prop_active_icon)
                                self.active_icon = True
                            continue

                        elif event.event_code == EVENT_DEVICE_UPDATE_INACTIVE:
                            if self.active_icon:
                                self.tray_icon.setIcon(self.prop_icon)
                                self.active_icon = False
                            continue

                        elif event.event_code == EVENT_DEVICE_UPDATE_BLIP:
                            if not self.active_icon:
                                self.tray_icon.setIcon(self.prop_active_icon)
                                self.active_icon = True
                                QTimer.singleShot(BLIP_DELAY, self.blipTimeout)
                            continue

                    if self.user_settings.systray_visible in (SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE, SYSTRAY_VISIBLE_HIDE_ALWAYS):
                        log.debug("Waiting to hide...")
                        QTimer.singleShot(HIDE_INACTIVE_DELAY, self.timeoutHideWhenInactive)

                    if event.event_code <= EVENT_MAX_USER_EVENT or \
                        event.event_code == EVENT_CUPS_QUEUES_REMOVED or event.event_code == EVENT_CUPS_QUEUES_ADDED:

                        if event.event_code != EVENT_CUPS_QUEUES_REMOVED:
                            self.addDevice(event.device_uri)
                            self.setMenu()

                        if self.tray_icon.supportsMessages():

                            log.debug("Tray icon message:")
                            event.debug()

                            error_state = STATUS_TO_ERROR_STATE_MAP.get(event.event_code, ERROR_STATE_CLEAR)
                            desc = device.queryString(event.event_code)

                            show_message = False
                            if self.user_settings.systray_messages == SYSTRAY_MESSAGES_SHOW_ALL: # OK, Busy
                                show_message = True

                            elif self.user_settings.systray_messages in (SYSTRAY_MESSAGES_SHOW_ERRORS_AND_WARNINGS, SYSTRAY_MESSAGES_SHOW_ERRORS_ONLY):
                                if error_state == ERROR_STATE_ERROR:
                                    show_message = True

                                elif self.user_settings.systray_messages == SYSTRAY_MESSAGES_SHOW_ERRORS_AND_WARNINGS and \
                                    error_state in (ERROR_STATE_WARNING, ERROR_STATE_LOW_SUPPLIES, ERROR_STATE_LOW_PAPER):

                                    show_message = True

                            if event.printer_name:
                                d = QString(event.printer_name)
                            else:
                                back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
                                                device.parseDeviceURI(event.device_uri)

                                if bus == 'usb':
                                    idd = serial
                                elif bus == 'net':
                                    idd = host
                                elif bus == 'par':
                                    idd = dev_file
                                else:
                                    idd = 'unknown'

                                self.model = models.normalizeModelUIName(model)

                                if back_end == 'hp':
                                    d = self.__tr("%s Printer (%s)"%(model,idd))

                                elif back_end == 'hpaio':
                                    d = self.__tr("%s Scanner (%s)"%(model,idd))

                                elif back_end == 'hpfax':
                                    d = self.__tr("%s Fax (%s)"%(model,idd))

                                else:
                                    d = self.__tr("%s (%s)"%(model,idd))

                            if show_message:
                                if have_pynotify and pynotify.init("hplip"): # Use libnotify/pynotify
                                    icon, urgency = ERROR_STATE_TO_ICON_AND_URGENCY_PYNOTIFY.get(error_state,
                                        (getPynotifyIcon('info'), pynotify.URGENCY_NORMAL))

                                    if event.job_id and event.title:
                                        msg = "%s\n%s: %s\n(%s/%s)" % (to_unicode(d), desc, event.title, event.username, event.job_id)
                                        log.debug("Notify: uri=%s desc=%s title=%s user=%s job_id=%d code=%d" %
                                                (event.device_uri, desc, event.title, event.username, event.job_id, event.event_code))
                                    else:
                                        msg = "%s\n%s (%s)" % (to_unicode(d), desc, event.event_code)
                                        log.debug("Notify: uri=%s desc=%s code=%d" % (event.device_uri, desc, event.event_code))

                                    n = pynotify.Notification("HPLIP Device Status", msg, icon)
                                    # CRID: 11833 Debian Traceback error notification exceeded
                                    n.set_hint('transient', True)
                                    n.set_urgency(urgency)

                                    if error_state == ERROR_STATE_ERROR:
                                        n.set_timeout(pynotify.EXPIRES_NEVER)
                                    else:
                                        n.set_timeout(TRAY_MESSAGE_DELAY)

                                    n.show()

                                else: # Use "standard" message bubbles
                                    icon = ERROR_STATE_TO_ICON.get(error_state, QSystemTrayIcon.Information)
                                    if event.job_id and event.title:
                                        log.debug("Bubble: uri=%s desc=%s title=%s user=%s job_id=%d code=%d" %
                                                (event.device_uri, desc, event.title, event.username, event.job_id, event.event_code))
                                        self.tray_icon.showMessage(self.__tr("HPLIP Device Status"),
                                            QString("%s\n%s: %s\n(%s/%s)"%(d,desc, event.title,event.username,event.job_id)),
                                            icon, TRAY_MESSAGE_DELAY)

                                    else:
                                        log.debug("Bubble: uri=%s desc=%s code=%d" % (event.device_uri, desc, event.event_code))
                                        self.tray_icon.showMessage(self.__tr("HPLIP Device Status"),
                                            QString("%s\n%s (%s)"%(d,desc,event.event_code)),
                                            icon, TRAY_MESSAGE_DELAY)

            else:
                break
Esempio n. 27
0
    def NextButton_clicked(self):
        if self.SkipRadioButton.isChecked():
            log.debug("Skipping plug-in installation.")
            self.close()
            return

        beginWaitCursor()
        try:

            if self.plugin_path is None: # download
                # read plugin.conf (local or on sf.net) to get plugin_path (http://)
                plugin_conf_url = self.core.get_plugin_conf_url()

                if plugin_conf_url.startswith('file://'):
                    pass
                else:
                    log.info("Checking for network connection...")
                    ok = self.core.check_network_connection()

                    if not ok:
                        log.error("Network connection not detected.")
                        endWaitCursor()
                        FailureUI(self, self.__tr("Network connection not detected."))
                        self.close()
                        return

                log.info("Downloading configuration file from: %s" % plugin_conf_url)
                self.plugin_path, size, checksum, timestamp, ok = self.core.get_plugin_info(plugin_conf_url,
                    self.plugin_download_callback)

                log.debug("path=%s, size=%d, checksum=%s, timestamp=%f, ok=%s" %
                        (self.plugin_path, size, checksum, timestamp, ok))

                if not self.plugin_path.startswith('http://') and not self.plugin_path.startswith('file://'):
                    self.plugin_path = 'file://' + self.plugin_path

            else: # path
                if not self.plugin_path.startswith('http://'):
                    self.plugin_path = 'file://' + self.plugin_path

                size, checksum, timestamp = 0, '', 0

            if self.plugin_path.startswith('file://'):
                pass
            else:
                log.info("Checking for network connection...")
                ok = self.core.check_network_connection()

                if not ok:
                    log.error("Network connection not detected.")
                    endWaitCursor()
                    FailureUI(self, self.__tr("Network connection not detected."))
                    self.close()
                    return

            log.info("Downloading plug-in from: %s" % self.plugin_path)

            status, ret = self.core.download_plugin(self.plugin_path, size, checksum, timestamp,
                self.plugin_download_callback)

            if status in (PLUGIN_INSTALL_ERROR_UNABLE_TO_RECV_KEYS, PLUGIN_INSTALL_ERROR_DIGITAL_SIG_NOT_FOUND):
                endWaitCursor()
                if QMessageBox.question(self, self.__tr("Digital signature download failed"),
                        self.__tr("<b>The download of the digital signature file failed.</b><p>Without this file, it is not possible to authenticate and validate the plug-in prior to installation.</p>Do you still want to install the plug-in?"),
                        QMessageBox.Yes | QMessageBox.No) != QMessageBox.Yes:

                    self.core.delete_plugin()
                    self.close()
                    return

            elif status != PLUGIN_INSTALL_ERROR_NONE:

                if status == PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND:
                    desc = self.__tr("<b>ERROR: Plug-in file not found (server returned 404 or similar error).</b><p>Error code: %1</p>").arg(str(ret))

                elif status == PLUGIN_INSTALL_ERROR_DIGITAL_SIG_BAD:
                    desc = self.__tr("<b>ERROR: Plug-in file does not match its digital signature.</b><p>File may have been corrupted or altered.</p><p>Error code: %1</p>").arg(str(ret))

                elif status == PLUGIN_INSTALL_ERROR_PLUGIN_FILE_CHECKSUM_ERROR:
                    desc = self.__tr("<b>ERROR: Plug-in file does not match its checksum. File may have been corrupted or altered.")

                elif status == PLUGIN_INSTALL_ERROR_NO_NETWORK:
                    desc = self.__tr("<b>ERROR: Unable to connect to network to download the plug-in.</b><p>Please check your network connection and try again.</p>")

                elif status == PLUGIN_INSTALL_ERROR_DIRECTORY_ERROR:
                    desc = self.__tr("<b>ERROR: Unable to create the plug-in directory.</b><p>Please check your permissions and try again.</p>")

                self.core.delete_plugin()
                endWaitCursor()
                FailureUI(self, desc)
                self.close()
                return

            if not self.core.run_plugin(GUI_MODE, self.plugin_install_callback):
                self.core.delete_plugin()
                endWaitCursor()
                FailureUI(self, self.__tr("Plug-in install failed."))
                self.close()
                return

            cups_devices = device.getSupportedCUPSDevices(['hp'])
            for dev in cups_devices:
                mq = device.queryModelByURI(dev)

                if mq.get('fw-download', False):
                    # Download firmware if needed
                    log.info(log.bold("\nDownloading firmware to device %s..." % dev))
                    try:
                        d = None
                        try:
                            d = device.Device(dev)
                        except Error:
                            log.error("Error opening device.")
                            endWaitCursor()
                            FailureUI(self, self.__tr("<b>Firmware download to device failed.</b><p>%1</p>").arg(dev))
                            continue

                        if d.downloadFirmware():
                            log.info("Firmware download successful.\n")
                        else:
                            endWaitCursor()
                            FailureUI(self, self.__tr("<b>Firmware download to device failed.</b><p>%1</p>").arg(dev))

                    finally:
                        if d is not None:
                            d.close()
        finally:
            endWaitCursor()

        self.core.delete_plugin()
        SuccessUI(self, self.__tr("<b>Plug-in installation successful.</b>"))
        self.result = True
        self.close()
Esempio n. 28
0
    def actionPushButton_clicked(self):
        core = core_install.CoreInstall()
        core.set_plugin_version() #self.version)

        if self.path is None: # download
            # read plugin.conf (local or on sf.net) to get plugin_path (http://)
            plugin_conf_url = core.get_plugin_conf_url()

            if plugin_conf_url.startswith('file://'):
                pass
            else:
                pass

                log.info("Checking for network connection...")
                ok = core.check_network_connection()

                if not ok:
                    log.error("Network connection not detected.")
                    self.FailureUI(self.__tr("Network connection not detected."))
                    self.close()
                    return


            log.info("Downloading configuration file from: %s" % plugin_conf_url)

            self.path, size, checksum, timestamp, ok = core.get_plugin_info(plugin_conf_url,
                self.plugin_download_callback)

            log.debug("path=%s, size=%d, checksum=%s, timestamp=%f, ok=%s" %
                    (self.path, size, checksum, timestamp, ok))

            if not self.path.startswith('http://') and not self.path.startswith('file://'):
                self.path = 'file://' + self.path


        else: # path
            if not self.path.startswith('http://'):
                self.path = 'file://' + self.path

            size, checksum, timestamp = 0, '', 0


        if self.path.startswith('file://'):
            pass
        else:

            log.info("Checking for network connection...")
            ok = core.check_network_connection()

            if not ok:
                log.error("Network connection not detected.")
                self.FailureUI(self.__tr("Network connection not detected."))
                self.close()
                return

        log.info("Downloading plug-in from: %s" % self.path)

        status, ret = core.download_plugin(self.path, size, checksum, timestamp,
            self.plugin_download_callback)

        if status != PLUGIN_INSTALL_ERROR_NONE:

            if status == PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND:
                desc = self.__tr("<b>ERROR: Plug-in file not found (server returned 404 or similar error).</b><p>Error code: %1</p>").arg(str(ret))

            elif status == PLUGIN_INSTALL_ERROR_DIGITAL_SIG_NOT_FOUND:
                desc = self.__tr("<b>ERROR: Plug-in digital signature file not found (server returned 404 or similar error).</b><p>Error code: %1</p>").arg(str(ret))

            elif status == PLUGIN_INSTALL_ERROR_DIGITAL_SIG_BAD:
                desc = self.__tr("<b>ERROR: Plug-in file does not match its digital signature.</b><p>File may have been corrupted or altered.</p><p>Error code: %1</p>").arg(str(ret))

            elif status == PLUGIN_INSTALL_ERROR_PLUGIN_FILE_CHECKSUM_ERROR:
                desc = self.__tr("<b>ERROR: Plug-in file does not match its checksum. File may have been corrupted or altered.")

            elif status == PLUGIN_INSTALL_ERROR_NO_NETWORK:
                desc = self.__tr("<b>ERROR: Unable to connect to network to download the plug-in.</b><p>Please check your network connection and try again.</p>")

            elif status == PLUGIN_INSTALL_ERROR_DIRECTORY_ERROR:
                desc = self.__tr("<b>ERROR: Unable to create the plug-in directory.</b><p>Please check your permissions and try again.</p>")

            elif status == PLUGIN_INSTALL_ERROR_UNABLE_TO_RECV_KEYS:
                desc = self.__tr("<b>ERROR: Unable to download the public HPLIP keys from the keyserver.</b><p>Error code: %1</p>").arg(str(ret))

            core.delete_plugin()
            self.FailureUI(desc)
            self.close()
            return

        local_plugin = ret

        if not core.run_plugin(GUI_MODE, self.plugin_install_callback):
            core.delete_plugin()
            self.FailureUI(self.__tr("Plug-in install failed."))
            self.close()
            return

        cups_devices = device.getSupportedCUPSDevices(['hp']) #, 'hpfax'])

        for dev in cups_devices:
            mq = device.queryModelByURI(dev)

            if mq.get('fw-download', False):

                # Download firmware if needed
                log.info(log.bold("\nDownloading firmware to device %s..." % dev))
                try:
                    d = device.Device(dev)
                except Error:
                    log.error("Error opening device.")
                    continue

                if d.downloadFirmware():
                    log.info("Firmware download successful.\n")

                d.close()


        core.delete_plugin()
        self.SuccessUI("Plug-in install successful.")
        self.close()
    def setupFax(self):
        QApplication.setOverrideCursor(QApplication.waitCursor)

        if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_MARVELL:
            fax_ppd_name = "HP-Fax3-hplip" # Fixed width (2528 pixels) and 300dpi rendering
            nick = "HP Fax 3"
        if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_SOAP or self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDMSOAP:
            fax_ppd_name = "HP-Fax2-hplip" # Fixed width (2528 pixels) and 300dpi rendering
            nick = "HP Fax 2"
        if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDM:
            fax_ppd_name = "HP-Fax4-hplip" # Fixed width (1728 pixels) and 200dpi rendering
            nick = "HP Fax 4"
        else:
            fax_ppd_name = "HP-Fax-hplip" # Standard
            nick = "HP Fax"

        ppds = []

        log.debug("Searching for fax file %s..." % fax_ppd_name)

        ppd_dir = sys_conf.get('dirs', 'ppd')
        for f in utils.walkFiles(ppd_dir, pattern="HP-Fax*.ppd*", abs_paths=True):
            ppds.append(f)

        for f in ppds:
            if f.find(fax_ppd_name) >= 0:
                fax_ppd = f
                log.debug("Found PDD file: %s" % fax_ppd)
                log.debug("Nickname: %s" % cups.getPPDDescription(fax_ppd))
                break
        else:
            QApplication.restoreOverrideCursor()
            log.error("Fax PPD file not found.")

            if QMessageBox.warning(self, self.__tr("Unable to find HP fax PPD file."),
                self.__tr("The PPD file (%1.ppd) needed to setup the fax queue was not found.").arg(fax_ppd_name),
                self.__tr("Browse to file..."), # button 0
                self.__tr("Quit") # button 1
                ) == 0: # Browse

                while True:
                    ppd_dir = sys_conf.get('dirs', 'ppd')
                    fax_ppd = unicode(QFileDialog.getOpenFileName(ppd_dir,
                        "HP Fax PPD Files (*.ppd *.ppd.gz);;All Files (*)", self,
                        "open file dialog", "Choose the fax PPD file"))

                    if not fax_ppd: # user hit cancel
                        return

                    if os.path.exists(fax_ppd):
                        n = cups.getPPDDescription(fax_ppd)
                        if n == nick:
                            break
                        else:
                            self.FailureUI(self.__tr("<b>Incorrect fax PPD file.</b><p>The fax PPD file must have a nickname of '%1', not '%1'.").arg(nick).arg(n))
                    else:
                        self.FailureUI(self.__tr("<b>File not found.</b><p>hp-setup cannot find the file %1").arg(fax_ppd))

            else: # Quit
                return

        cups.setPasswordPrompt("You do not have permission to add a fax device.")
        if not os.path.exists(fax_ppd):
            status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                self.fax_uri, self.fax_location, '', fax_ppd,  self.fax_desc)
        else:
            status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                self.fax_uri, self.fax_location, fax_ppd, '', self.fax_desc)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])

        log.debug(self.installed_fax_devices)

        if self.fax_uri not in self.installed_fax_devices or \
            self.fax_name not in self.installed_fax_devices[self.fax_uri]:

            self.FailureUI(self.__tr("<b>Fax queue setup failed.</b><p>Please restart CUPS and try again."))
        else:
            pass
            # TODO:
            #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.fax_uri)

        QApplication.restoreOverrideCursor()
    def actionPushButton_clicked(self):
        core = core_install.CoreInstall()
        core.set_plugin_version()  #self.version)

        if self.path is None:  # download
            # read plugin.conf (local or on sf.net) to get plugin_path (http://)
            plugin_conf_url = core.get_plugin_conf_url()

            if plugin_conf_url.startswith('file://'):
                pass
            else:
                pass

                log.info("Checking for network connection...")
                ok = core.check_network_connection()

                if not ok:
                    log.error("Network connection not detected.")
                    self.FailureUI(
                        self.__tr("Network connection not detected."))
                    self.close()
                    return

            log.info("Downloading configuration file from: %s" %
                     plugin_conf_url)

            self.path, size, checksum, timestamp, ok = core.get_plugin_info(
                plugin_conf_url, self.plugin_download_callback)

            log.debug("path=%s, size=%d, checksum=%s, timestamp=%f, ok=%s" %
                      (self.path, size, checksum, timestamp, ok))

            if not self.path.startswith(
                    'http://') and not self.path.startswith('file://'):
                self.path = 'file://' + self.path

        else:  # path
            if not self.path.startswith('http://'):
                self.path = 'file://' + self.path

            size, checksum, timestamp = 0, '', 0

        if self.path.startswith('file://'):
            pass
        else:

            log.info("Checking for network connection...")
            ok = core.check_network_connection()

            if not ok:
                log.error("Network connection not detected.")
                self.FailureUI(self.__tr("Network connection not detected."))
                self.close()
                return

        log.info("Downloading plug-in from: %s" % self.path)

        status, ret = core.download_plugin(self.path, size, checksum,
                                           timestamp,
                                           self.plugin_download_callback)

        if status != PLUGIN_INSTALL_ERROR_NONE:

            if status == PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND:
                desc = self.__tr(
                    "<b>ERROR: Plug-in file not found (server returned 404 or similar error).</b><p>Error code: %1</p>"
                ).arg(str(ret))

            elif status == PLUGIN_INSTALL_ERROR_DIGITAL_SIG_NOT_FOUND:
                desc = self.__tr(
                    "<b>ERROR: Plug-in digital signature file not found (server returned 404 or similar error).</b><p>Error code: %1</p>"
                ).arg(str(ret))

            elif status == PLUGIN_INSTALL_ERROR_DIGITAL_SIG_BAD:
                desc = self.__tr(
                    "<b>ERROR: Plug-in file does not match its digital signature.</b><p>File may have been corrupted or altered.</p><p>Error code: %1</p>"
                ).arg(str(ret))

            elif status == PLUGIN_INSTALL_ERROR_PLUGIN_FILE_CHECKSUM_ERROR:
                desc = self.__tr(
                    "<b>ERROR: Plug-in file does not match its checksum. File may have been corrupted or altered."
                )

            elif status == PLUGIN_INSTALL_ERROR_NO_NETWORK:
                desc = self.__tr(
                    "<b>ERROR: Unable to connect to network to download the plug-in.</b><p>Please check your network connection and try again.</p>"
                )

            elif status == PLUGIN_INSTALL_ERROR_DIRECTORY_ERROR:
                desc = self.__tr(
                    "<b>ERROR: Unable to create the plug-in directory.</b><p>Please check your permissions and try again.</p>"
                )

            elif status == PLUGIN_INSTALL_ERROR_UNABLE_TO_RECV_KEYS:
                desc = self.__tr(
                    "<b>ERROR: Unable to download the public HPLIP keys from the keyserver.</b><p>Error code: %1</p>"
                ).arg(str(ret))

            core.delete_plugin()
            self.FailureUI(desc)
            self.close()
            return

        local_plugin = ret

        if not core.run_plugin(GUI_MODE, self.plugin_install_callback):
            core.delete_plugin()
            self.FailureUI(self.__tr("Plug-in install failed."))
            self.close()
            return

        cups_devices = device.getSupportedCUPSDevices(['hp'])  #, 'hpfax'])

        for dev in cups_devices:
            mq = device.queryModelByURI(dev)

            if mq.get('fw-download', False):

                # Download firmware if needed
                log.info(
                    log.bold("\nDownloading firmware to device %s..." % dev))
                try:
                    d = device.Device(dev)
                except Error:
                    log.error("Error opening device.")
                    continue

                if d.downloadFirmware():
                    log.info("Firmware download successful.\n")

                d.close()

        core.delete_plugin()
        self.SuccessUI("Plug-in install successful.")
        self.close()
Esempio n. 31
0
    def NextButton_clicked(self):
        if self.SkipRadioButton.isChecked():
            log.debug("Skipping plug-in installation.")
            self.close()
            return

        beginWaitCursor()
        try:

            if self.plugin_path is None:  # download
                # read plugin.conf (local or on sf.net) to get plugin_path (http://)
                plugin_conf_url = self.core.get_plugin_conf_url()

                if plugin_conf_url.startswith('file://'):
                    pass
                else:
                    log.info("Checking for network connection...")
                    ok = self.core.check_network_connection()

                    if not ok:
                        log.error("Network connection not detected.")
                        endWaitCursor()
                        FailureUI(
                            self,
                            self.__tr("Network connection not detected."))
                        self.close()
                        return

                log.info("Downloading configuration file from: %s" %
                         plugin_conf_url)
                self.plugin_path, size, checksum, timestamp, ok = self.core.get_plugin_info(
                    plugin_conf_url, self.plugin_download_callback)

                log.debug(
                    "path=%s, size=%d, checksum=%s, timestamp=%f, ok=%s" %
                    (self.plugin_path, size, checksum, timestamp, ok))

                if not self.plugin_path.startswith(
                        'http://') and not self.plugin_path.startswith(
                            'file://'):
                    self.plugin_path = 'file://' + self.plugin_path

            else:  # path
                if not self.plugin_path.startswith('http://'):
                    self.plugin_path = 'file://' + self.plugin_path

                size, checksum, timestamp = 0, '', 0

            if self.plugin_path.startswith('file://'):
                pass
            else:
                log.info("Checking for network connection...")
                ok = self.core.check_network_connection()

                if not ok:
                    log.error("Network connection not detected.")
                    endWaitCursor()
                    FailureUI(self,
                              self.__tr("Network connection not detected."))
                    self.close()
                    return

            log.info("Downloading plug-in from: %s" % self.plugin_path)

            status, ret = self.core.download_plugin(
                self.plugin_path, size, checksum, timestamp,
                self.plugin_download_callback)

            if status in (PLUGIN_INSTALL_ERROR_UNABLE_TO_RECV_KEYS,
                          PLUGIN_INSTALL_ERROR_DIGITAL_SIG_NOT_FOUND):
                endWaitCursor()
                if QMessageBox.question(
                        self, self.__tr("Digital signature download failed"),
                        self.__tr(
                            "<b>The download of the digital signature file failed.</b><p>Without this file, it is not possible to authenticate and validate the plug-in prior to installation.</p>Do you still want to install the plug-in?"
                        ),
                        QMessageBox.Yes | QMessageBox.No) != QMessageBox.Yes:

                    self.core.delete_plugin()
                    self.close()
                    return

            elif status != PLUGIN_INSTALL_ERROR_NONE:

                if status == PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND:
                    desc = self.__tr(
                        "<b>ERROR: Plug-in file not found (server returned 404 or similar error).</b><p>Error code: %1</p>"
                    ).arg(str(ret))

                elif status == PLUGIN_INSTALL_ERROR_DIGITAL_SIG_BAD:
                    desc = self.__tr(
                        "<b>ERROR: Plug-in file does not match its digital signature.</b><p>File may have been corrupted or altered.</p><p>Error code: %1</p>"
                    ).arg(str(ret))

                elif status == PLUGIN_INSTALL_ERROR_PLUGIN_FILE_CHECKSUM_ERROR:
                    desc = self.__tr(
                        "<b>ERROR: Plug-in file does not match its checksum. File may have been corrupted or altered."
                    )

                elif status == PLUGIN_INSTALL_ERROR_NO_NETWORK:
                    desc = self.__tr(
                        "<b>ERROR: Unable to connect to network to download the plug-in.</b><p>Please check your network connection and try again.</p>"
                    )

                elif status == PLUGIN_INSTALL_ERROR_DIRECTORY_ERROR:
                    desc = self.__tr(
                        "<b>ERROR: Unable to create the plug-in directory.</b><p>Please check your permissions and try again.</p>"
                    )

                self.core.delete_plugin()
                endWaitCursor()
                FailureUI(self, desc)
                self.close()
                return

            if not self.core.run_plugin(GUI_MODE,
                                        self.plugin_install_callback):
                self.core.delete_plugin()
                endWaitCursor()
                FailureUI(self, self.__tr("Plug-in install failed."))
                self.close()
                return

            cups_devices = device.getSupportedCUPSDevices(['hp'])
            for dev in cups_devices:
                mq = device.queryModelByURI(dev)

                if mq.get('fw-download', False):
                    # Download firmware if needed
                    log.info(
                        log.bold("\nDownloading firmware to device %s..." %
                                 dev))
                    try:
                        d = None
                        try:
                            d = device.Device(dev)
                        except Error:
                            log.error("Error opening device.")
                            endWaitCursor()
                            FailureUI(
                                self,
                                self.__tr(
                                    "<b>Firmware download to device failed.</b><p>%1</p>"
                                ).arg(dev))
                            continue

                        if d.downloadFirmware():
                            log.info("Firmware download successful.\n")
                        else:
                            endWaitCursor()
                            FailureUI(
                                self,
                                self.__tr(
                                    "<b>Firmware download to device failed.</b><p>%1</p>"
                                ).arg(dev))

                    finally:
                        if d is not None:
                            d.close()
        finally:
            endWaitCursor()

        self.core.delete_plugin()
        SuccessUI(self, self.__tr("<b>Plug-in installation successful.</b>"))
        self.result = True
        self.close()
Esempio n. 32
0
    def setupFax(self):
        QApplication.setOverrideCursor(QApplication.waitCursor)

        if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_MARVELL:
            fax_ppd_name = "HP-Fax3-hplip"  # Fixed width (2528 pixels) and 300dpi rendering
            nick = "HP Fax 3"
        if self.mq.get('fax-type',
                       FAX_TYPE_NONE) == FAX_TYPE_SOAP or self.mq.get(
                           'fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDMSOAP:
            fax_ppd_name = "HP-Fax2-hplip"  # Fixed width (2528 pixels) and 300dpi rendering
            nick = "HP Fax 2"
        if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDM:
            fax_ppd_name = "HP-Fax4-hplip"  # Fixed width (1728 pixels) and 200dpi rendering
            nick = "HP Fax 4"
        else:
            fax_ppd_name = "HP-Fax-hplip"  # Standard
            nick = "HP Fax"

        ppds = []

        log.debug("Searching for fax file %s..." % fax_ppd_name)

        ppd_dir = sys_conf.get('dirs', 'ppd')
        for f in utils.walkFiles(ppd_dir,
                                 pattern="HP-Fax*.ppd*",
                                 abs_paths=True):
            ppds.append(f)

        for f in ppds:
            if f.find(fax_ppd_name) >= 0:
                fax_ppd = f
                log.debug("Found PDD file: %s" % fax_ppd)
                log.debug("Nickname: %s" % cups.getPPDDescription(fax_ppd))
                break
        else:
            QApplication.restoreOverrideCursor()
            log.error("Fax PPD file not found.")

            if QMessageBox.warning(
                    self,
                    self.__tr("Unable to find HP fax PPD file."),
                    self.__tr(
                        "The PPD file (%1.ppd) needed to setup the fax queue was not found."
                    ).arg(fax_ppd_name),
                    self.__tr("Browse to file..."),  # button 0
                    self.__tr("Quit")  # button 1
            ) == 0:  # Browse

                while True:
                    ppd_dir = sys_conf.get('dirs', 'ppd')
                    fax_ppd = unicode(
                        QFileDialog.getOpenFileName(
                            ppd_dir,
                            "HP Fax PPD Files (*.ppd *.ppd.gz);;All Files (*)",
                            self, "open file dialog",
                            "Choose the fax PPD file"))

                    if not fax_ppd:  # user hit cancel
                        return

                    if os.path.exists(fax_ppd):
                        n = cups.getPPDDescription(fax_ppd)
                        if n == nick:
                            break
                        else:
                            self.FailureUI(
                                self.__tr(
                                    "<b>Incorrect fax PPD file.</b><p>The fax PPD file must have a nickname of '%1', not '%1'."
                                ).arg(nick).arg(n))
                    else:
                        self.FailureUI(
                            self.__tr(
                                "<b>File not found.</b><p>hp-setup cannot find the file %1"
                            ).arg(fax_ppd))

            else:  # Quit
                return

        cups.setPasswordPrompt(
            "You do not have permission to add a fax device.")
        if not os.path.exists(fax_ppd):
            status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                                                 self.fax_uri,
                                                 self.fax_location, '',
                                                 fax_ppd, self.fax_desc)
        else:
            status, status_str = cups.addPrinter(self.fax_name.encode('utf8'),
                                                 self.fax_uri,
                                                 self.fax_location, fax_ppd,
                                                 '', self.fax_desc)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])

        log.debug(self.installed_fax_devices)

        if self.fax_uri not in self.installed_fax_devices or \
            self.fax_name not in self.installed_fax_devices[self.fax_uri]:

            self.FailureUI(
                self.__tr(
                    "<b>Fax queue setup failed.</b><p>Please restart CUPS and try again."
                ))
        else:
            pass
            # TODO:
            #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.fax_uri)

        QApplication.restoreOverrideCursor()
Esempio n. 33
0
    def notifierActivated(self, s):
        m = ''
        while True:
            try:
                r, w, e = select.select([self.read_pipe], [], [self.read_pipe], 1.0)
            except select.error:
                log.debug("Error in select()")
                break

            if e:
                log.error("Pipe error: %s" % e)
                break

            if r:
                m = ''.join([m, os.read(self.read_pipe, self.fmt_size)])
                while len(m) >= self.fmt_size:
                    event = device.Event(*struct.unpack(self.fmt, m[:self.fmt_size]))

                    m = m[self.fmt_size:]
                    
                    if event.event_code == EVENT_CUPS_QUEUES_CHANGED:
                        self.resetDevice()
                        for d in device.getSupportedCUPSDevices(back_end_filter=['hp', 'hpfax']):
                            self.addDevice(d)
                            
                        self.setMenu()

                    if event.event_code == EVENT_USER_CONFIGURATION_CHANGED:
                        log.debug("Re-reading configuration (EVENT_USER_CONFIGURATION_CHANGED)")
                        self.user_settings.load()
                        self.user_settings.debug()

                    elif event.event_code == EVENT_SYSTEMTRAY_EXIT:
                        self.quit()
                        return

                    if self.user_settings.systray_visible in \
                        (SYSTRAY_VISIBLE_SHOW_ALWAYS, SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE):

                        log.debug("Showing...")
                        self.tray_icon.setVisible(True)

                        if event.event_code == EVENT_DEVICE_UPDATE_ACTIVE:
                            if not self.active_icon:
                                self.tray_icon.setIcon(self.prop_active_icon)
                                self.active_icon = True
                            continue

                        elif event.event_code == EVENT_DEVICE_UPDATE_INACTIVE:
                            if self.active_icon:
                                self.tray_icon.setIcon(self.prop_icon)
                                self.active_icon = False
                            continue

                        elif event.event_code == EVENT_DEVICE_UPDATE_BLIP:
                            if not self.active_icon:
                                self.tray_icon.setIcon(self.prop_active_icon)
                                self.active_icon = True
                                QTimer.singleShot(BLIP_DELAY, self.blipTimeout)
                            continue

                    if self.user_settings.systray_visible in (SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE, SYSTRAY_VISIBLE_HIDE_ALWAYS):
                        log.debug("Waiting to hide...")
                        QTimer.singleShot(HIDE_INACTIVE_DELAY, self.timeoutHideWhenInactive)

                    if event.event_code <= EVENT_MAX_USER_EVENT:
                        self.addDevice(event.device_uri)
                        self.setMenu()

                        if self.tray_icon.supportsMessages():

                            log.debug("Tray icon message:")
                            event.debug()

                            error_state = STATUS_TO_ERROR_STATE_MAP.get(event.event_code, ERROR_STATE_CLEAR)
                            desc = device.queryString(event.event_code)

                            show_message = False
                            if self.user_settings.systray_messages == SYSTRAY_MESSAGES_SHOW_ALL: # OK, Busy
                                show_message = True

                            elif self.user_settings.systray_messages in (SYSTRAY_MESSAGES_SHOW_ERRORS_AND_WARNINGS, SYSTRAY_MESSAGES_SHOW_ERRORS_ONLY):
                                if error_state == ERROR_STATE_ERROR:
                                    show_message = True

                                elif self.user_settings.systray_messages == SYSTRAY_MESSAGES_SHOW_ERRORS_AND_WARNINGS and \
                                    error_state in (ERROR_STATE_WARNING, ERROR_STATE_LOW_SUPPLIES, ERROR_STATE_LOW_PAPER):

                                    show_message = True

                            if event.printer_name:
                                d = QString(event.printer_name)
                            else:
                                back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
                                                device.parseDeviceURI(event.device_uri)

                                if bus == 'usb':
                                    idd = serial
                                elif bus == 'net':
                                    idd = host
                                elif bus == 'par':
                                    idd = dev_file
                                else:
                                    idd = 'unknown'

                                self.model = models.normalizeModelUIName(model)

                                if back_end == 'hp':
                                    d = self.__tr("%1 Printer (%2)").arg(model).arg(idd)

                                elif back_end == 'hpaio':
                                    d = self.__tr("%1 Scanner (%2)").arg(model).arg(idd)

                                elif back_end == 'hpfax':
                                    d = self.__tr("%1 Fax (%2)").arg(model).arg(idd)

                                else:
                                    d = self.__tr("%1 (%2)").arg(model).arg(idd)

                            if show_message:
                                if have_pynotify and pynotify.init("hplip"): # Use libnotify/pynotify
                                    icon, urgency = ERROR_STATE_TO_ICON_AND_URGENCY_PYNOTIFY.get(error_state,
                                        (getPynotifyIcon('info'), pynotify.URGENCY_NORMAL))

                                    if event.job_id and event.title:
                                        msg = "%s\n%s: %s\n(%s/%s)" % (unicode(d), desc, event.title, event.username, event.job_id)
                                        log.debug("Notify: uri=%s desc=%s title=%s user=%s job_id=%d code=%d" %
                                                (event.device_uri, desc, event.title, event.username, event.job_id, event.event_code))
                                    else:
                                        msg = "%s\n%s (%s)" % (unicode(d), desc, event.event_code)
                                        log.debug("Notify: uri=%s desc=%s code=%d" % (event.device_uri, desc, event.event_code))

                                    n = pynotify.Notification("HPLIP Device Status", msg, icon)
                                    n.set_urgency(urgency)

                                    if error_state == ERROR_STATE_ERROR:
                                        n.set_timeout(pynotify.EXPIRES_NEVER)
                                    else:
                                        n.set_timeout(TRAY_MESSAGE_DELAY)

                                    n.show()

                                else: # Use "standard" message bubbles
                                    icon = ERROR_STATE_TO_ICON.get(error_state, QSystemTrayIcon.Information)
                                    if event.job_id and event.title:
                                        log.debug("Bubble: uri=%s desc=%s title=%s user=%s job_id=%d code=%d" %
                                                (event.device_uri, desc, event.title, event.username, event.job_id, event.event_code))
                                        self.tray_icon.showMessage(self.__tr("HPLIP Device Status"),
                                            QString("%1\n%2: %3\n(%4/%5)").\
                                            arg(d).\
                                            arg(desc).arg(event.title).\
                                            arg(event.username).arg(event.job_id),
                                            icon, TRAY_MESSAGE_DELAY)

                                    else:
                                        log.debug("Bubble: uri=%s desc=%s code=%d" % (event.device_uri, desc, event.event_code))
                                        self.tray_icon.showMessage(self.__tr("HPLIP Device Status"),
                                            QString("%1\n%2 (%3)").arg(d).\
                                            arg(desc).arg(event.event_code),
                                            icon, TRAY_MESSAGE_DELAY)

            else:
                break
Esempio n. 34
0
    def NextButton_clicked(self):
        if self.SkipRadioButton.isChecked():
            log.debug("Skipping plug-in installation.")
            self.close()
            return

        beginWaitCursor()
        try:

            if self.plugin_path: # User specified Path
                if not self.plugin_path.startswith('http://'):
                    self.plugin_path = 'file://' + self.plugin_path

            else:
                log.info("Checking for network connection...")
                ok = utils.check_network_connection()

                if not ok:
                    log.error("Network connection not detected.")
                    endWaitCursor()
                    FailureUI(self, self.__tr("Network connection not detected."))
                    self.close()
                    return

            log.info("Downloading plug-in from: %s" % self.plugin_path)

            status, download_plugin_file = self.pluginObj.download(self.plugin_path,self.plugin_download_callback)

            if status in (pluginhandler.PLUGIN_INSTALL_ERROR_UNABLE_TO_RECV_KEYS, pluginhandler.PLUGIN_INSTALL_ERROR_DIGITAL_SIGN_NOT_FOUND):
                endWaitCursor()
                if QMessageBox.question(self, self.__tr("Digital signature download failed"),
                        self.__tr("<b>The download of the digital signature file failed.</b><p>Without this file, it is not possible to authenticate and validate the plug-in prior to installation.</p>Do you still want to install the plug-in?"),
                        QMessageBox.Yes | QMessageBox.No) != QMessageBox.Yes:

                    self.pluginObj.deleteInstallationFiles(download_plugin_file)
                    self.close()
                    return

            elif status != pluginhandler.PLUGIN_INSTALL_ERROR_NONE:

                if status == pluginhandler.PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND:
                    desc = self.__tr("<b>ERROR: Plug-in file not found (server returned 404 or similar error)")

                elif status == pluginhandler.PLUGIN_INSTALL_ERROR_DIGITAL_SIGN_BAD:
                    desc = self.__tr("<b>ERROR: Plug-in file does not match its digital signature.</b><p>File may have been corrupted or altered.")

                elif status == pluginhandler.PLUGIN_INSTALL_ERROR_PLUGIN_FILE_CHECKSUM_ERROR:
                    desc = self.__tr("<b>ERROR: Plug-in file does not match its checksum. File may have been corrupted or altered.")

                elif status == pluginhandler.PLUGIN_INSTALL_ERROR_NO_NETWORK:
                    desc = self.__tr("<b>ERROR: Unable to connect to network to download the plug-in.</b><p>Please check your network connection and try again.</p>")

                elif status == pluginhandler.PLUGIN_INSTALL_ERROR_DIRECTORY_ERROR:
                    desc = self.__tr("<b>ERROR: Unable to create the plug-in directory.</b><p>Please check your permissions and try again.</p>")

                self.pluginObj.deleteInstallationFiles(download_plugin_file)
                endWaitCursor()
                FailureUI(self, desc)
                self.close()
                return

            if not self.pluginObj.run_plugin(download_plugin_file, GUI_MODE):
                self.pluginObj.deleteInstallationFiles(download_plugin_file)
                endWaitCursor()
                FailureUI(self, self.__tr("Plug-in install failed."))
                self.close()
                return

            cups_devices = device.getSupportedCUPSDevices(['hp'])
            for dev in cups_devices:
                mq = device.queryModelByURI(dev)

                if mq.get('fw-download', False):
                    # Download firmware if needed
                    log.info(log.bold("\nDownloading firmware to device %s..." % dev))
                    try:
                        d = None
                        try:
                            d = device.Device(dev)
                        except Error:
                            log.error("Error opening device.")
                            endWaitCursor()
                            FailureUI(self, self.__tr("<b>Firmware download to device failed.</b><p>%1</p>").arg(dev))
                            continue

                        if d.downloadFirmware():
                            log.info("Firmware download successful.\n")
                        else:
                            endWaitCursor()
                            FailureUI(self, self.__tr("<b>Firmware download to device failed.</b><p>%1</p>").arg(dev))

                    finally:
                        if d is not None:
                            d.close()
        finally:
            endWaitCursor()

        self.pluginObj.deleteInstallationFiles(download_plugin_file)
        SuccessUI(self, self.__tr("<b>Plug-in installation successful</b>"))
        self.result = True
        self.close()
Esempio n. 35
0
    def notifierActivated(self, s):
        m = ''
        while True:
            try:
                r, w, e = select.select([self.read_pipe], [], [self.read_pipe], 1.0)
            except select.error:
                log.debug("Error in select()")
                break

            if e:
                log.error("Pipe error: %s" % e)
                break

            if r:
                #m = ''.join([m, os.read(self.read_pipe, self.fmt_size)])
                m = os.read(self.read_pipe, self.fmt_size)
                while len(m) >= self.fmt_size:
                    event = device.Event(*[x.rstrip(b'\x00').decode('utf-8') if isinstance(x, bytes) else x for x in struct.unpack(self.fmt, m[:self.fmt_size])])
                    m = m[self.fmt_size:]

                    if event.event_code == EVENT_CUPS_QUEUES_REMOVED or event.event_code == EVENT_CUPS_QUEUES_ADDED:
                        self.resetDevice()
                        for d in device.getSupportedCUPSDevices(back_end_filter=['hp', 'hpfax']):
                            self.addDevice(d)

                        self.setMenu()

                    if event.event_code == EVENT_USER_CONFIGURATION_CHANGED:
                        log.debug("Re-reading configuration (EVENT_USER_CONFIGURATION_CHANGED)")
                        self.user_settings.load()
                        self.user_settings.debug()

                    elif event.event_code == EVENT_SYSTEMTRAY_EXIT:
                        self.quit()
                        return

                    if self.user_settings.systray_visible in \
                        (SYSTRAY_VISIBLE_SHOW_ALWAYS, SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE):

                        log.debug("Showing...")
                        self.tray_icon.setVisible(True)

                        if event.event_code == EVENT_DEVICE_UPDATE_ACTIVE:
                            if not self.active_icon:
                                self.tray_icon.setIcon(self.prop_active_icon)
                                self.active_icon = True
                            continue

                        elif event.event_code == EVENT_DEVICE_UPDATE_INACTIVE:
                            if self.active_icon:
                                self.tray_icon.setIcon(self.prop_icon)
                                self.active_icon = False
                            continue

                        elif event.event_code == EVENT_DEVICE_UPDATE_BLIP:
                            if not self.active_icon:
                                self.tray_icon.setIcon(self.prop_active_icon)
                                self.active_icon = True
                                QTimer.singleShot(BLIP_DELAY, self.blipTimeout)
                            continue

                    if self.user_settings.systray_visible in (SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE, SYSTRAY_VISIBLE_HIDE_ALWAYS):
                        log.debug("Waiting to hide...")
                        QTimer.singleShot(HIDE_INACTIVE_DELAY, self.timeoutHideWhenInactive)

                    if event.event_code <= EVENT_MAX_USER_EVENT or \
                        event.event_code == EVENT_CUPS_QUEUES_REMOVED or event.event_code == EVENT_CUPS_QUEUES_ADDED:

                        if event.event_code != EVENT_CUPS_QUEUES_REMOVED:
                            self.addDevice(event.device_uri)
                            self.setMenu()

                        if self.tray_icon.supportsMessages():

                            log.debug("Tray icon message:")
                            event.debug()

                            error_state = STATUS_TO_ERROR_STATE_MAP.get(event.event_code, ERROR_STATE_CLEAR)
                            desc = device.queryString(event.event_code)

                            show_message = False
                            if self.user_settings.systray_messages == SYSTRAY_MESSAGES_SHOW_ALL: # OK, Busy
                                show_message = True

                            elif self.user_settings.systray_messages in (SYSTRAY_MESSAGES_SHOW_ERRORS_AND_WARNINGS, SYSTRAY_MESSAGES_SHOW_ERRORS_ONLY):
                                if error_state == ERROR_STATE_ERROR:
                                    show_message = True

                                elif self.user_settings.systray_messages == SYSTRAY_MESSAGES_SHOW_ERRORS_AND_WARNINGS and \
                                    error_state in (ERROR_STATE_WARNING, ERROR_STATE_LOW_SUPPLIES, ERROR_STATE_LOW_PAPER):

                                    show_message = True

                            if event.printer_name:
                                d = event.printer_name
                            else:
                                back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
                                                device.parseDeviceURI(event.device_uri)

                                if bus == 'usb':
                                    idd = serial
                                elif bus == 'net':
                                    idd = host
                                elif bus == 'par':
                                    idd = dev_file
                                else:
                                    idd = 'unknown'

                                self.model = models.normalizeModelUIName(model)

                                if back_end == 'hp':
                                    d = self.__tr("%s Printer (%s)"%(model,idd))

                                elif back_end == 'hpaio':
                                    d = self.__tr("%s Scanner (%s)"%(model,idd))

                                elif back_end == 'hpfax':
                                    d = self.__tr("%s Fax (%s)"%(model,idd))

                                else:
                                    d = self.__tr("%s (%s)"%(model,idd))

                            if show_message:
                                if have_pynotify and pynotify.init("hplip"): # Use libnotify/pynotify
                                    icon, urgency = ERROR_STATE_TO_ICON_AND_URGENCY_PYNOTIFY.get(error_state,
                                        (getPynotifyIcon('info'), pynotify.URGENCY_NORMAL))

                                    if event.job_id and event.title:
                                        msg = "%s\n%s: %s\n(%s/%s)" % (to_unicode(d), desc, event.title, event.username, event.job_id)
                                        log.debug("Notify: uri=%s desc=%s title=%s user=%s job_id=%d code=%d" %
                                                (event.device_uri, desc, event.title, event.username, event.job_id, event.event_code))
                                    else:
                                        msg = "%s\n%s (%s)" % (to_unicode(d), desc, event.event_code)
                                        log.debug("Notify: uri=%s desc=%s code=%d" % (event.device_uri, desc, event.event_code))

                                    n = pynotify.Notification("HPLIP Device Status", msg, icon)
                                    # CRID: 11833 Debian Traceback error notification exceeded
                                    n.set_hint('transient', True)
                                    n.set_urgency(urgency)

                                    if error_state == ERROR_STATE_ERROR:
                                        n.set_timeout(pynotify.EXPIRES_NEVER)
                                    else:
                                        n.set_timeout(TRAY_MESSAGE_DELAY)

                                    n.show()

                                else: # Use "standard" message bubbles
                                    icon = ERROR_STATE_TO_ICON.get(error_state, QSystemTrayIcon.Information)
                                    if event.job_id and event.title:
                                        log.debug("Bubble: uri=%s desc=%s title=%s user=%s job_id=%d code=%d" %
                                                (event.device_uri, desc, event.title, event.username, event.job_id, event.event_code))
                                        self.tray_icon.showMessage(self.__tr("HPLIP Device Status"),
                                                                   "%s\n%s: %s\n(%s/%s)"%(d,desc, event.title,event.username,event.job_id),
                                                                   icon, TRAY_MESSAGE_DELAY)

                                    else:
                                        log.debug("Bubble: uri=%s desc=%s code=%d" % (event.device_uri, desc, event.event_code))
                                        self.tray_icon.showMessage(self.__tr("HPLIP Device Status"),
                                                                   "%s\n%s (%s)"%(d,desc,event.event_code),
                                                                   icon, TRAY_MESSAGE_DELAY)

            else:
                break
Esempio n. 36
0
            elif status == core_install.PLUGIN_INSTALL_ERROR_NO_NETWORK:
                desc = "Unable to connect to network to download the plug-in. Please check your network connection and try again."

            elif status == core_install.PLUGIN_INSTALL_ERROR_DIRECTORY_ERROR:
                desc = "Unable to create the plug-in directory. Please check your permissions and try again."

            core.delete_plugin()
            log.error(desc)
            sys.exit(1)


        tui.header("INSTALLING PLUG-IN")

        core.run_plugin(mode, plugin_install_callback)

        cups_devices = device.getSupportedCUPSDevices(['hp']) #, 'hpfax'])
        #print cups_devices

        title = False

        for dev in cups_devices:
            mq = device.queryModelByURI(dev)

            if mq.get('fw-download', 0):

                if not title:
                    tui.header("DOWNLOADING FIRMWARE")
                    title = True

                # Download firmware if needed
                log.info(log.bold("\nDownloading firmware to device %s..." % dev))
Esempio n. 37
0
                cont, ans = tui.enter_yes_no(
                    "Do you still want to install the plug-in?", 'n')

                if not cont or not ans:
                    pluginObj.deleteInstallationFiles(plugin_path)
                    clean_exit(0)
            else:
                pluginObj.deleteInstallationFiles(plugin_path)
                clean_exit(1)

        tui.header("INSTALLING PLUG-IN")

        pluginObj.run_plugin(plugin_path, mode)
        pluginObj.deleteInstallationFiles(plugin_path)

        cups_devices = device.getSupportedCUPSDevices(['hp'])  #, 'hpfax'])
        #print cups_devices

        title = False

        for dev in cups_devices:
            mq = device.queryModelByURI(dev)

            if mq.get('fw-download', 0):

                if not title:
                    tui.header("DOWNLOADING FIRMWARE")
                    title = True

                # Download firmware if needed
                log.info(
Esempio n. 38
0
    def NextButton_clicked(self):
        if self.SkipRadioButton.isChecked():
            log.debug("Skipping plug-in installation.")
            self.close()
            return

        beginWaitCursor()
        try:

            if self.plugin_path: # User specified Path
                if not self.plugin_path.startswith('http://'):
                    self.plugin_path = 'file://' + self.plugin_path

            else:
                log.info("Checking for network connection...")
                ok = utils.check_network_connection()

                if not ok:
                    log.error("Network connection not detected.")
                    endWaitCursor()
                    FailureUI(self, self.__tr("Network connection not detected."))
                    self.close()
                    return

            log.info("Downloading plug-in from: %s" % self.plugin_path)

            status, download_plugin_file, error_str = self.pluginObj.download(self.plugin_path,self.plugin_download_callback)

            if status in (ERROR_UNABLE_TO_RECV_KEYS, ERROR_DIGITAL_SIGN_NOT_FOUND):
                endWaitCursor()
                if QMessageBox.question(self, " ",
                        self.__tr("<b>%s</b><p>Without this, it is not possible to authenticate and validate the plug-in prior to installation.</p>Do you still want to install the plug-in?" %error_str),
                        QMessageBox.Yes | QMessageBox.No) != QMessageBox.Yes:

                    self.pluginObj.deleteInstallationFiles(download_plugin_file)
                    self.close()
                    return

            elif status != ERROR_SUCCESS:
                self.pluginObj.deleteInstallationFiles(download_plugin_file)
                endWaitCursor()
                FailureUI(self, error_str)
                self.close()
                return

            if not self.pluginObj.run_plugin(download_plugin_file, GUI_MODE):
                self.pluginObj.deleteInstallationFiles(download_plugin_file)
                endWaitCursor()
                FailureUI(self, self.__tr("Plug-in install failed."))
                self.close()
                return

            cups_devices = device.getSupportedCUPSDevices(['hp'])
            for dev in cups_devices:
                mq = device.queryModelByURI(dev)

                if mq.get('fw-download', False):
                    # Download firmware if needed
                    log.info(log.bold("\nDownloading firmware to device %s..." % dev))
                    try:
                        d = None
                        try:
                            d = device.Device(dev)
                        except Error:
                            log.error("Error opening device.")
                            endWaitCursor()
                            FailureUI(self, self.__tr("<b>Firmware download to device failed.</b><p>%1</p>").arg(dev))
                            continue

                        if d.downloadFirmware():
                            log.info("Firmware download successful.\n")
                        else:
                            endWaitCursor()
                            FailureUI(self, self.__tr("<b>Firmware download to device failed.</b><p>%1</p>").arg(dev))

                    finally:
                        if d is not None:
                            d.close()
        finally:
            endWaitCursor()

        self.pluginObj.deleteInstallationFiles(download_plugin_file)
        SuccessUI(self, self.__tr("<b>Plug-in installation successful</b>"))
        self.result = True
        self.close()
Esempio n. 39
0
    def NextButton_clicked(self):
        if self.SkipRadioButton.isChecked():
            log.debug("Skipping plug-in installation.")
            self.close()
            return

        beginWaitCursor()
        try:

            if self.plugin_path: # User specified Path
                if not self.plugin_path.startswith('http://'):
                    self.plugin_path = 'file://' + self.plugin_path

            else:
                log.info("Checking for network connection...")
                ok = utils.check_network_connection()

                if not ok:
                    log.error("Network connection not detected.")
                    endWaitCursor()
                    FailureUI(self, self.__tr("Network connection not detected."))
                    self.close()
                    return

            log.info("Downloading plug-in from: %s" % self.plugin_path)

            status, download_plugin_file, error_str = self.pluginObj.download(self.plugin_path,self.plugin_download_callback)

            if status in (ERROR_UNABLE_TO_RECV_KEYS, ERROR_DIGITAL_SIGN_NOT_FOUND):
                endWaitCursor()

                if QMessageBox.question(self, " ",
                        self.__tr("<b>%s</b><p>Without this, it is not possible to authenticate and validate the plug-in prior to installation.</p>Do you still want to install the plug-in?" %error_str),
                                        QMessageBox.Yes | QMessageBox.No, QMessageBox.No) != QMessageBox.Yes:

                    self.pluginObj.deleteInstallationFiles(download_plugin_file)
                    self.close()
                    return

            elif status != ERROR_SUCCESS:
                self.pluginObj.deleteInstallationFiles(download_plugin_file)
                endWaitCursor()
                FailureUI(self, error_str)
                self.close()
                return

            if not self.pluginObj.run_plugin(download_plugin_file, GUI_MODE):
                self.pluginObj.deleteInstallationFiles(download_plugin_file)
                endWaitCursor()
                FailureUI(self, self.__tr("Plug-in install failed."))
                self.close()
                return

            cups_devices = device.getSupportedCUPSDevices(['hp'])
            for dev in cups_devices:
                mq = device.queryModelByURI(dev)

                if mq.get('fw-download', False):
                    # Download firmware if needed
                    log.info(log.bold("\nDownloading firmware to device %s..." % dev))
                    try:
                        d = None
                        try:
                            d = device.Device(dev)
                        except Error:
                            log.error("Error opening device.")
                            endWaitCursor()
                            FailureUI(self, self.__tr("<b>Firmware download to device failed.</b><p>%s</p>"%dev))
                            continue

                        if d.downloadFirmware():
                            log.info("Firmware download successful.\n")
                        else:
                            endWaitCursor()
                            FailureUI(self, self.__tr("<b>Firmware download to device failed.</b><p>%s</p>"%dev))

                    finally:
                        if d is not None:
                            d.close()
        finally:
            endWaitCursor()

        self.pluginObj.deleteInstallationFiles(download_plugin_file)
        SuccessUI(self, self.__tr("<b>Plug-in installation successful</b>"))
        self.result = True
        self.close()
Esempio n. 40
0
                    tui.header("PLUG-IN INSTALLATION")

                hp_plugin = utils.which('hp-plugin')
                if hp_plugin:
                    cmd = "hp-plugin -i"

                    if os_utils.execute(cmd) != 0:
                        log.error("Failed to install Plugin.")
                        log.error("The device you are trying to setup requires a binary plug-in. Some functionalities may not work as expected without plug-ins. Please run 'hp-plugin' as normal user to install plug-ins.Visit http://hplipopensource.com for more infomation.")
                        clean_exit(1)

        ppds = cups.getSystemPPDs()

        default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_')

        installed_print_devices = device.getSupportedCUPSDevices(['hp'])
        for d in list(installed_print_devices.keys()):
            for p in installed_print_devices[d]:
                log.debug("found print queue '%s'" % p)

        installed_fax_devices = device.getSupportedCUPSDevices(['hpfax'])
        for d in list(installed_fax_devices.keys()):
            for f in installed_fax_devices[d]:
                log.debug("found fax queue '%s'" % f)

        # ******************************* PRINT QUEUE SETUP
        if setup_print:

            tui.header("PRINT QUEUE SETUP")

            if not auto and print_uri in installed_print_devices:
Esempio n. 41
0
    def actionPushButton_clicked(self):
        if self.path: # path
            if not self.path.startswith('http://'):
                self.path = 'file://' + self.path

        else:
            log.info("Checking for network connection...")
            ok = utils.check_network_connection()

            if not ok:
                log.error("Network connection not detected.")
                self.FailureUI(self.__tr("Network connection not detected."))
                self.close()
                return

        log.info("Downloading plug-in from: %s" % self.path)

        status, self.path = self.pluginObj.download(self.path, self.plugin_download_callback)

        if status != pluginhandler.PLUGIN_INSTALL_ERROR_NONE:

            if status == pluginhandler.PLUGIN_INSTALL_ERROR_PLUGIN_FILE_NOT_FOUND:
                desc = self.__tr("<b>ERROR: Plug-in file not found (server returned 404 or similar error).")

            elif status == pluginhandler.PLUGIN_INSTALL_ERROR_DIGITAL_SIGN_NOT_FOUND:
                desc = self.__tr("<b>ERROR: Plug-in digital signature file not found (server returned 404 or similar error).")

            elif status == pluginhandler.PLUGIN_INSTALL_ERROR_DIGITAL_SIGN_BAD:
                desc = self.__tr("<b>ERROR: Plug-in file does not match its digital signature.</b><p>File may have been corrupted or altered.")

            elif status == pluginhandler.PLUGIN_INSTALL_ERROR_PLUGIN_FILE_CHECKSUM_ERROR:
                desc = self.__tr("<b>ERROR: Plug-in file does not match its checksum. File may have been corrupted or altered.")

            elif status == pluginhandler.PLUGIN_INSTALL_ERROR_NO_NETWORK:
                desc = self.__tr("<b>ERROR: Unable to connect to network to download the plug-in.</b><p>Please check your network connection and try again.</p>")

            elif status == pluginhandler.PLUGIN_INSTALL_ERROR_DIRECTORY_ERROR:
                desc = self.__tr("<b>ERROR: Unable to create the plug-in directory.</b><p>Please check your permissions and try again.</p>")

            elif status == pluginhandler.PLUGIN_INSTALL_ERROR_UNABLE_TO_RECV_KEYS:
                desc = self.__tr("<b>ERROR: Unable to download the public HPLIP keys from the keyserver.")

            self.pluginObj.deleteInstallationFiles(self.path)
            self.FailureUI(desc)
            self.close()
            return

        if not self.pluginObj.run_plugin(self.path, GUI_MODE):
            self.pluginObj.deleteInstallationFiles(self.path)
            self.FailureUI(self.__tr("Plug-in install failed."))
            self.close()
            return

        cups_devices = device.getSupportedCUPSDevices(['hp']) #, 'hpfax'])

        for dev in cups_devices:
            mq = device.queryModelByURI(dev)

            if mq.get('fw-download', False):

                # Download firmware if needed
                log.info(log.bold("\nDownloading firmware to device %s..." % dev))
                try:
                    d = device.Device(dev)
                except Error:
                    log.error("Error opening device.")
                    continue

                if d.downloadFirmware():
                    log.info("Firmware download successful.\n")

                d.close()


        self.pluginObj.deleteInstallationFiles(self.path)
        self.SuccessUI("Plug-in install successful")
        self.close()