Пример #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()
Пример #2
0
    def otherPPDPushButton_clicked(self):
        ppd_dir = sys_conf.get('dirs', 'ppd')
        ppd_file = unicode(QFileDialog.getOpenFileName(ppd_dir, "PPD Files (*.ppd *.ppd.gz);;All Files (*)", self, "open file dialog", "Choose a PPD file"))

        if ppd_file and os.path.exists(ppd_file):
            self.updatePPDPage({ppd_file: cups.getPPDDescription(ppd_file)})
        else:
            self.updatePPDPage()
Пример #3
0
    def otherPPDPushButton_clicked(self):
        ppd_dir = sys_conf.get('dirs', 'ppd')
        ppd_file = unicode(QFileDialog.getOpenFileName(ppd_dir, "PPD Files (*.ppd *.ppd.gz);;All Files (*)", self, "open file dialog", "Choose a PPD file"))

        if ppd_file and os.path.exists(ppd_file):
            self.updatePPDPage({ppd_file: cups.getPPDDescription(ppd_file)})
        else:
            self.updatePPDPage()
Пример #4
0
    def OtherPPDButton_clicked(self, b):
        ppd_file = unicode(QFileDialog.getOpenFileName(self, self.__tr("Select PPD File"),
                                                       sys_conf.get('dirs', 'ppd'),
                                                       self.__tr("PPD Files (*.ppd *.ppd.gz);;All Files (*)")))

        if ppd_file and os.path.exists(ppd_file):
            self.print_ppd = (ppd_file, cups.getPPDDescription(ppd_file))
            self.updatePPD()
            self.setAddPrinterButton()
Пример #5
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
Пример #6
0
    def findFaxPPD(self):
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            log.debug("Searching for fax PPD for model %s" % self.model)

            if prop.hpcups_build:
                if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_MARVELL:
                    fax_ppd_name = "HP-Fax3-hpcups" # Fixed width (2528 pixels) and 300dpi rendering
                    nick = "HP Fax3 hpcups"
                elif 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-hpcups" # Fixed width (2528 pixels) and 300dpi rendering
                    nick = "HP Fax2 hpcups"
                elif self.mq.get('fax-type', FAX_TYPE_LEDM) == FAX_TYPE_LEDM:
                    fax_ppd_name = "HP-Fax4-hpcups"# Fixed width (2528 pixels) and 300dpi rendering
                    nick = "HP Fax4 hpcups"
                else:
                    fax_ppd_name = "HP-Fax-hpcups" # Standard
                    nick = "HP Fax hpcups"

            else: # hpijs
                if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_MARVELL:
                    fax_ppd_name = "HP-Fax3-hpijs" # Fixed width (2528 pixels) and 300dpi rendering
                    nick = "HP Fax3 hpijs"
                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-hpijs" # Fixed width (2528 pixels) and 300dpi rendering
                    nick = "HP Fax2 hpijs"
                if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDM:
                    fax_ppd_name = "HP-Fax4-hpijs" # Fixed width (2528 pixels) and 300dpi rendering
                    nick = "HP Fax4 hpijs"
                else:
                    fax_ppd_name = "HP-Fax-hpijs" # Standard
                    nick = "HP Fax hpijs"

            ppds = []

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

            for f in ppds:
                if f.find(fax_ppd_name) >= 0 and cups.getPPDDescription(f) == nick:
                    self.fax_ppd = f
                    self.fax_setup_ok = True
                    log.debug("Found fax PPD: %s" % f)
                    break
            else:
                self.fax_ppd = None
                self.fax_setup_ok = False
                FailureUI(self, self.__tr("<b>Unable to locate the HPLIP Fax PPD file:</b><p>%1.ppd.gz</p><p>Fax setup has been disabled.").arg(fax_ppd_name))
                self.fax_setup = False
                self.SetupFaxGroupBox.setChecked(False)
                self.SetupFaxGroupBox.setEnabled(False)

        finally:
            QApplication.restoreOverrideCursor()
Пример #7
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()
Пример #8
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()