home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / hplip / ui / devmgr4.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  54.8 KB  |  1,495 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. from __future__ import generators
  5. import sys
  6. import time
  7. import os
  8. from base.g import *
  9. from base import device, status, msg, maint, utils, service, pml
  10. from prnt import cups
  11. from base.codes import *
  12. from qt import *
  13. from devmgr4_base import DevMgr4_base
  14. from alignform import AlignForm
  15. from aligntype6form1 import AlignType6Form1
  16. from aligntype6form2 import AlignType6Form2
  17. from paperedgealignform import PaperEdgeAlignForm
  18. from colorcalform import ColorCalForm
  19. from coloradjform import ColorAdjForm
  20. from colorcalform2 import ColorCalForm2
  21. from colorcal4form import ColorCal4Form
  22. from align10form import Align10Form
  23. from loadpaperform import LoadPaperForm
  24. from settingsdialog import SettingsDialog
  25. from nodevicesform import NoDevicesForm
  26. from aboutdlg import AboutDlg
  27. from cleaningform import CleaningForm
  28. from cleaningform2 import CleaningForm2
  29. from waitform import WaitForm
  30. from faxsettingsform import FaxSettingsForm
  31. from informationform import InformationForm
  32. from supportform import SupportForm
  33. MIN_AUTO_REFRESH_RATE = 1
  34. MAX_AUTO_REFRESH_RATE = 60
  35. DEF_AUTO_REFRESH_RATE = 1
  36.  
  37. class JobListViewItem(QListViewItem):
  38.     
  39.     def __init__(self, parent, printer, job_id, state, user, title):
  40.         QListViewItem.__init__(self, parent, printer, str(job_id), state, user, title)
  41.         self.job_id = job_id
  42.         self.printer = printer
  43.  
  44.  
  45.  
  46. class ScrollToolView(QScrollView):
  47.     
  48.     def __init__(self, parent = None, name = None, fl = 0):
  49.         QScrollView.__init__(self, parent, name, fl)
  50.         self.items = { }
  51.         self.setStaticBackground(True)
  52.         self.enableClipper(True)
  53.         self.viewport().setPaletteBackgroundColor(qApp.palette().color(QPalette.Active, QColorGroup.Base))
  54.         self.row_height = 120
  55.  
  56.     
  57.     def viewportResizeEvent(self, e):
  58.         for x in self.items:
  59.             self.items[x].resize(e.size().width(), self.row_height)
  60.         
  61.  
  62.     
  63.     def addItem(self, name, title, pix, text, button_text, button_func):
  64.         num_items = len(self.items)
  65.         LayoutWidget = QWidget(self.viewport(), 'layoutwidget')
  66.         LayoutWidget.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum))
  67.         LayoutWidget.setGeometry(QRect(0, 0, self.width(), self.row_height))
  68.         LayoutWidget.setPaletteBackgroundColor(qApp.palette().color(QPalette.Active, QColorGroup.Base))
  69.         self.addChild(LayoutWidget)
  70.         if num_items:
  71.             self.moveChild(LayoutWidget, 0, self.row_height * num_items)
  72.         
  73.         layout = QGridLayout(LayoutWidget, 1, 1, 10, 10, 'layout')
  74.         pushButton = QPushButton(LayoutWidget, 'pushButton')
  75.         pushButton.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed, 0, 0, pushButton.sizePolicy().hasHeightForWidth()))
  76.         self.connect(pushButton, SIGNAL('clicked()'), button_func)
  77.         layout.addWidget(pushButton, 2, 2)
  78.         textLabel = QLabel(LayoutWidget, 'textLabel')
  79.         layout.addWidget(textLabel, 1, 1)
  80.         pixmap = QLabel(LayoutWidget, 'pixmapLabel2')
  81.         pixmap.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0, pixmap.sizePolicy().hasHeightForWidth()))
  82.         pixmap.setMinimumSize(QSize(32, 32))
  83.         pixmap.setMaximumSize(QSize(32, 32))
  84.         pixmap.setPixmap(pix)
  85.         pixmap.setScaledContents(1)
  86.         layout.addWidget(pixmap, 1, 0)
  87.         textLabel2 = QLabel(LayoutWidget, 'textLabel2')
  88.         textLabel2.setAlignment(QLabel.WordBreak | QLabel.AlignTop)
  89.         textLabel2.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding))
  90.         layout.addWidget(textLabel2, 2, 1)
  91.         if num_items:
  92.             line = QFrame(LayoutWidget, 'line')
  93.             line.setFrameShadow(QFrame.Sunken)
  94.             line.setFrameShape(QFrame.HLine)
  95.             line.setPaletteBackgroundColor(qApp.palette().color(QPalette.Active, QColorGroup.Foreground))
  96.             layout.addMultiCellWidget(line, 0, 0, 0, 2)
  97.         
  98.         textLabel.setText(title)
  99.         textLabel2.setText(text)
  100.         pushButton.setText(button_text)
  101.         self.resizeContents(self.width(), num_items * self.row_height * 2)
  102.         LayoutWidget.show()
  103.         
  104.         try:
  105.             self.items[name]
  106.         except KeyError:
  107.             self.items[name] = LayoutWidget
  108.  
  109.         print 'ERROR: Duplicate button name:', name
  110.  
  111.     
  112.     def clear(self):
  113.         if len(self.items):
  114.             for x in self.items:
  115.                 self.removeChild(self.items[x])
  116.                 self.items[x].hide()
  117.             
  118.             self.items.clear()
  119.             self.resizeContents(self.width(), 0)
  120.         
  121.  
  122.  
  123.  
  124. class ScrollSuppliesView(QScrollView):
  125.     
  126.     def __init__(self, parent = None, name = None, fl = 0):
  127.         QScrollView.__init__(self, parent, name, fl)
  128.         self.items = { }
  129.         self.setStaticBackground(True)
  130.         self.enableClipper(True)
  131.         self.viewport().setPaletteBackgroundColor(qApp.palette().color(QPalette.Active, QColorGroup.Base))
  132.         self.pix_black = QPixmap(os.path.join(prop.image_dir, 'icon_black.png'))
  133.         self.pix_blue = QPixmap(os.path.join(prop.image_dir, 'icon_blue.png'))
  134.         self.pix_cyan = QPixmap(os.path.join(prop.image_dir, 'icon_cyan.png'))
  135.         self.pix_grey = QPixmap(os.path.join(prop.image_dir, 'icon_grey.png'))
  136.         self.pix_magenta = QPixmap(os.path.join(prop.image_dir, 'icon_magenta.png'))
  137.         self.pix_photo = QPixmap(os.path.join(prop.image_dir, 'icon_photo.png'))
  138.         self.pix_photo_cyan = QPixmap(os.path.join(prop.image_dir, 'icon_photo_cyan.png'))
  139.         self.pix_photo_magenta = QPixmap(os.path.join(prop.image_dir, 'icon_photo_magenta.png'))
  140.         self.pix_photo_yellow = QPixmap(os.path.join(prop.image_dir, 'icon_photo_yellow.png'))
  141.         self.pix_tricolor = QPixmap(os.path.join(prop.image_dir, 'icon_tricolor.png'))
  142.         self.pix_yellow = QPixmap(os.path.join(prop.image_dir, 'icon_yellow.png'))
  143.         self.pix_battery = QPixmap(os.path.join(prop.image_dir, 'icon_battery.png'))
  144.         self.pix_photo_cyan_and_photo_magenta = QPixmap(os.path.join(prop.image_dir, 'icon_photo_magenta_and_photo_cyan.png'))
  145.         self.pix_magenta_and_yellow = QPixmap(os.path.join(prop.image_dir, 'icon_magenta_and_yellow.png'))
  146.         self.pix_black_and_cyan = QPixmap(os.path.join(prop.image_dir, 'icon_black_and_cyan.png'))
  147.         self.pix_light_gray_and_photo_black = QPixmap(os.path.join(prop.image_dir, 'icon_light_grey_and_photo_black.png'))
  148.         self.pix_light_gray = QPixmap(os.path.join(prop.image_dir, 'icon_light_grey.png'))
  149.         self.pix_photo_gray = QPixmap(os.path.join(prop.image_dir, 'icon_photo_black.png'))
  150.         self.TYPE_TO_PIX_MAP = {
  151.             AGENT_TYPE_BLACK: self.pix_black,
  152.             AGENT_TYPE_CMY: self.pix_tricolor,
  153.             AGENT_TYPE_KCM: self.pix_photo,
  154.             AGENT_TYPE_GGK: self.pix_grey,
  155.             AGENT_TYPE_YELLOW: self.pix_yellow,
  156.             AGENT_TYPE_MAGENTA: self.pix_magenta,
  157.             AGENT_TYPE_CYAN: self.pix_cyan,
  158.             AGENT_TYPE_CYAN_LOW: self.pix_photo_cyan,
  159.             AGENT_TYPE_YELLOW_LOW: self.pix_photo_yellow,
  160.             AGENT_TYPE_MAGENTA_LOW: self.pix_photo_magenta,
  161.             AGENT_TYPE_BLUE: self.pix_blue,
  162.             AGENT_TYPE_KCMY_CM: self.pix_grey,
  163.             AGENT_TYPE_LC_LM: self.pix_photo_cyan_and_photo_magenta,
  164.             AGENT_TYPE_Y_M: self.pix_magenta_and_yellow,
  165.             AGENT_TYPE_C_K: self.pix_black_and_cyan,
  166.             AGENT_TYPE_LG_PK: self.pix_light_gray_and_photo_black,
  167.             AGENT_TYPE_LG: self.pix_light_gray,
  168.             AGENT_TYPE_G: self.pix_grey,
  169.             AGENT_TYPE_PG: self.pix_photo_gray }
  170.         self.row_height = 100
  171.  
  172.     
  173.     def viewportResizeEvent(self, e):
  174.         for x in self.items:
  175.             self.items[x].resize(e.size().width(), self.row_height)
  176.         
  177.  
  178.     
  179.     def getIcon(self, agent_kind, agent_type):
  180.         if agent_kind in (AGENT_KIND_SUPPLY, AGENT_KIND_HEAD, AGENT_KIND_HEAD_AND_SUPPLY, AGENT_KIND_TONER_CARTRIDGE):
  181.             return self.TYPE_TO_PIX_MAP[agent_type]
  182.         elif agent_kind == AGENT_KIND_INT_BATTERY:
  183.             return self.pix_battery
  184.         
  185.  
  186.     
  187.     def createBarGraph(self, percent, agent_type, w = 100, h = 18):
  188.         fw = (w / 100) * percent
  189.         px = QPixmap(w, h)
  190.         pp = QPainter(px)
  191.         pp.setBackgroundMode(Qt.OpaqueMode)
  192.         pp.setPen(Qt.black)
  193.         pp.setBackgroundColor(Qt.white)
  194.         b = QBrush(QColor(Qt.white))
  195.         pp.fillRect(0, 0, w, h, b)
  196.         if agent_type in (AGENT_TYPE_BLACK, AGENT_TYPE_UNSPECIFIED):
  197.             b = QBrush(QColor(Qt.black))
  198.             pp.fillRect(0, 0, fw, h, b)
  199.         elif agent_type == AGENT_TYPE_CMY:
  200.             h3 = h / 3
  201.             b = QBrush(QColor(Qt.cyan))
  202.             pp.fillRect(0, 0, fw, h3, b)
  203.             b = QBrush(QColor(Qt.magenta))
  204.             pp.fillRect(0, h3, fw, 2 * h3, b)
  205.             b = QBrush(QColor(Qt.yellow))
  206.             pp.fillRect(0, 2 * h3, fw, h, b)
  207.         elif agent_type == AGENT_TYPE_KCM:
  208.             h3 = h / 3
  209.             b = QBrush(QColor(Qt.cyan).light())
  210.             pp.fillRect(0, 0, fw, h3, b)
  211.             b = QBrush(QColor(Qt.magenta).light())
  212.             pp.fillRect(0, h3, fw, 2 * h3, b)
  213.             b = QBrush(QColor(Qt.yellow).light())
  214.             pp.fillRect(0, 2 * h3, fw, h, b)
  215.         elif agent_type == AGENT_TYPE_GGK:
  216.             b = QBrush(QColor(Qt.gray))
  217.             pp.fillRect(0, 0, fw, h, b)
  218.         elif agent_type == AGENT_TYPE_YELLOW:
  219.             b = QBrush(QColor(Qt.yellow))
  220.             pp.fillRect(0, 0, fw, h, b)
  221.         elif agent_type == AGENT_TYPE_MAGENTA:
  222.             b = QBrush(QColor(Qt.magenta))
  223.             pp.fillRect(0, 0, fw, h, b)
  224.         elif agent_type == AGENT_TYPE_CYAN:
  225.             b = QBrush(QColor(Qt.cyan))
  226.             pp.fillRect(0, 0, fw, h, b)
  227.         elif agent_type == AGENT_TYPE_CYAN_LOW:
  228.             b = QBrush(QColor(225, 246, 255))
  229.             pp.fillRect(0, 0, fw, h, b)
  230.         elif agent_type == AGENT_TYPE_YELLOW_LOW:
  231.             b = QBrush(QColor(255, 253, 225))
  232.             pp.fillRect(0, 0, fw, h, b)
  233.         elif agent_type == AGENT_TYPE_MAGENTA_LOW:
  234.             b = QBrush(QColor(255, 225, 240))
  235.             pp.fillRect(0, 0, fw, h, b)
  236.         elif agent_type == AGENT_TYPE_BLUE:
  237.             b = QBrush(QColor(0, 0, 255))
  238.             pp.fillRect(0, 0, fw, h, b)
  239.         elif agent_type == AGENT_TYPE_LG:
  240.             b = QBrush(QColor(192, 192, 192))
  241.             pp.fillRect(0, 0, fw, h, b)
  242.         elif agent_type == AGENT_TYPE_PG:
  243.             b = QBrush(QColor(128, 128, 128))
  244.             pp.fillRect(0, 0, fw, h, b)
  245.         
  246.         pp.drawRect(0, 0, w, h)
  247.         if percent > 75 and agent_type in (AGENT_TYPE_BLACK, AGENT_TYPE_UNSPECIFIED, AGENT_TYPE_BLUE):
  248.             pp.setPen(Qt.white)
  249.         
  250.         w1 = 3 * w / 4
  251.         h6 = h / 6
  252.         pp.drawLine(w1, 0, w1, h6)
  253.         pp.drawLine(w1, h, w1, h - h6)
  254.         if percent > 50 and agent_type in (AGENT_TYPE_BLACK, AGENT_TYPE_UNSPECIFIED, AGENT_TYPE_BLUE):
  255.             pp.setPen(Qt.white)
  256.         
  257.         w2 = w / 2
  258.         h4 = h / 4
  259.         pp.drawLine(w2, 0, w2, h4)
  260.         pp.drawLine(w2, h, w2, h - h4)
  261.         if percent > 25 and agent_type in (AGENT_TYPE_BLACK, AGENT_TYPE_UNSPECIFIED, AGENT_TYPE_BLUE):
  262.             pp.setPen(Qt.white)
  263.         
  264.         w4 = w / 4
  265.         pp.drawLine(w4, 0, w4, h6)
  266.         pp.drawLine(w4, h, w4, h - h6)
  267.         return px
  268.  
  269.     
  270.     def addItem(self, name, title_text, part_num_text, status_text, agent_kind, agent_type, percent):
  271.         num_items = len(self.items)
  272.         LayoutWidget = QWidget(self.viewport(), name)
  273.         LayoutWidget.setGeometry(QRect(0, 0, self.width(), self.row_height))
  274.         LayoutWidget.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum))
  275.         LayoutWidget.setPaletteBackgroundColor(qApp.palette().color(QPalette.Active, QColorGroup.Base))
  276.         self.addChild(LayoutWidget)
  277.         if num_items:
  278.             self.moveChild(LayoutWidget, 0, self.row_height * num_items)
  279.         
  280.         layout = QGridLayout(LayoutWidget, 1, 1, 10, 10, 'layout')
  281.         textStatus = QLabel(LayoutWidget, 'textStatus')
  282.         layout.addWidget(textStatus, 1, 2)
  283.         pixmapLevel = QLabel(LayoutWidget, 'pixmapLevel')
  284.         pixmapLevel.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0, pixmapLevel.sizePolicy().hasHeightForWidth()))
  285.         pixmapLevel.setMinimumSize(QSize(100, 20))
  286.         pixmapLevel.setMaximumSize(QSize(100, 20))
  287.         layout.addWidget(pixmapLevel, 2, 2)
  288.         textTitle = QLabel(LayoutWidget, 'textTitle')
  289.         layout.addWidget(textTitle, 1, 1)
  290.         textPartNo = QLabel(LayoutWidget, 'textPartNo')
  291.         layout.addWidget(textPartNo, 2, 1)
  292.         pixmapIcon = QLabel(LayoutWidget, 'pixmapIcon')
  293.         pixmapIcon.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0, pixmapIcon.sizePolicy().hasHeightForWidth()))
  294.         pixmapIcon.setMinimumSize(QSize(32, 32))
  295.         pixmapIcon.setMaximumSize(QSize(32, 32))
  296.         layout.addWidget(pixmapIcon, 1, 0)
  297.         if num_items:
  298.             line = QFrame(LayoutWidget, 'line')
  299.             line.setFrameShadow(QFrame.Sunken)
  300.             line.setFrameShape(QFrame.HLine)
  301.             line.setPaletteBackgroundColor(qApp.palette().color(QPalette.Active, QColorGroup.Foreground))
  302.             layout.addMultiCellWidget(line, 0, 0, 0, 2)
  303.         
  304.         textTitle.setText(title_text)
  305.         textPartNo.setText(part_num_text)
  306.         textStatus.setText(status_text)
  307.         if agent_kind in (AGENT_KIND_SUPPLY, AGENT_KIND_HEAD_AND_SUPPLY, AGENT_KIND_TONER_CARTRIDGE, AGENT_KIND_MAINT_KIT, AGENT_KIND_ADF_KIT, AGENT_KIND_INT_BATTERY, AGENT_KIND_DRUM_KIT):
  308.             pixmapLevel.setPixmap(self.createBarGraph(percent, agent_type))
  309.         
  310.         if agent_kind in (AGENT_KIND_SUPPLY, AGENT_KIND_HEAD, AGENT_KIND_HEAD_AND_SUPPLY, AGENT_KIND_TONER_CARTRIDGE, AGENT_KIND_INT_BATTERY):
  311.             pix = self.getIcon(agent_kind, agent_type)
  312.             if pix is not None:
  313.                 pixmapIcon.setPixmap(pix)
  314.             
  315.         
  316.         self.resizeContents(self.width(), num_items * self.row_height * 2)
  317.         LayoutWidget.show()
  318.         
  319.         try:
  320.             self.items[name]
  321.         except KeyError:
  322.             self.items[name] = LayoutWidget
  323.  
  324.  
  325.     
  326.     def clear(self):
  327.         if len(self.items):
  328.             for x in self.items:
  329.                 self.removeChild(self.items[x])
  330.                 self.items[x].hide()
  331.             
  332.             self.items.clear()
  333.             self.resizeContents(self.width(), 0)
  334.         
  335.  
  336.  
  337.  
  338. class IconViewItem(QIconViewItem):
  339.     
  340.     def __init__(self, parent, text, pixmap, device_uri, is_avail = True):
  341.         QIconViewItem.__init__(self, parent, text, pixmap)
  342.         self.device_uri = device_uri
  343.         self.is_avail = is_avail
  344.  
  345.  
  346.  
  347. class devmgr4(DevMgr4_base):
  348.     
  349.     def __init__(self, hpiod_sock, hpssd_sock, cleanup = None, initial_device_uri = None, parent = None, name = None, fl = 0):
  350.         DevMgr4_base.__init__(self, parent, name, fl)
  351.         icon = QPixmap(os.path.join(prop.image_dir, 'HPmenu.png'))
  352.         self.setIcon(icon)
  353.         log.debug('Initializing toolbox UI')
  354.         self.cleanup = cleanup
  355.         self.hpiod_sock = hpiod_sock
  356.         self.hpssd_sock = hpssd_sock
  357.         self.StatusHistoryList.setSorting(-1)
  358.         self.PrintJobList.setSorting(1)
  359.         self.DeviceList.setAutoArrange(False)
  360.         self.StatusHistoryList.setColumnWidth(0, 16)
  361.         self.StatusHistoryList.setColumnText(0, ' ')
  362.         self.StatusHistoryList.setColumnWidthMode(1, QListView.Maximum)
  363.         self.StatusHistoryList.setColumnWidthMode(2, QListView.Maximum)
  364.         self.StatusHistoryList.setColumnWidthMode(3, QListView.Maximum)
  365.         self.StatusHistoryList.setColumnWidthMode(4, QListView.Maximum)
  366.         self.StatusHistoryList.setColumnWidthMode(5, QListView.Maximum)
  367.         self.StatusHistoryList.setColumnWidthMode(6, QListView.Maximum)
  368.         self.PrintJobList.setColumnWidth(0, 150)
  369.         self.PrintJobList.setColumnWidthMode(0, QListView.Maximum)
  370.         self.PrintJobList.setColumnWidth(1, 60)
  371.         self.PrintJobList.setColumnWidthMode(1, QListView.Maximum)
  372.         self.PrintJobList.setColumnWidth(2, 80)
  373.         self.PrintJobList.setColumnWidthMode(2, QListView.Maximum)
  374.         self.PrintJobList.setColumnWidth(3, 100)
  375.         self.PrintJobList.setColumnWidthMode(3, QListView.Maximum)
  376.         self.PrintJobList.setColumnWidth(4, 200)
  377.         self.PrintJobList.setColumnWidthMode(4, QListView.Maximum)
  378.         self.initial_device_uri = initial_device_uri
  379.         self.warning_pix = QPixmap(os.path.join(prop.image_dir, 'warning.png'))
  380.         self.error_pix = QPixmap(os.path.join(prop.image_dir, 'error.png'))
  381.         self.ok_pix = QPixmap(os.path.join(prop.image_dir, 'ok.png'))
  382.         self.lowink_pix = QPixmap(os.path.join(prop.image_dir, 'inkdrop.png'))
  383.         self.lowtoner_pix = QPixmap(os.path.join(prop.image_dir, 'toner.png'))
  384.         self.busy_pix = QPixmap(os.path.join(prop.image_dir, 'busy.png'))
  385.         self.lowpaper_pix = QPixmap(os.path.join(prop.image_dir, 'paper.png'))
  386.         self.warning_pix_small = QPixmap(os.path.join(prop.image_dir, 'warning_small.png'))
  387.         self.error_pix_small = QPixmap(os.path.join(prop.image_dir, 'error_small.png'))
  388.         self.ok_pix_small = QPixmap(os.path.join(prop.image_dir, 'ok_small.png'))
  389.         self.lowink_pix_small = QPixmap(os.path.join(prop.image_dir, 'inkdrop_small.png'))
  390.         self.lowtoner_pix_small = QPixmap(os.path.join(prop.image_dir, 'toner_small.png'))
  391.         self.busy_pix_small = QPixmap(os.path.join(prop.image_dir, 'busy_small.png'))
  392.         self.lowpaper_pix_small = QPixmap(os.path.join(prop.image_dir, 'paper_small.png'))
  393.         self.blank_lcd = os.path.join(prop.image_dir, 'panel_lcd.xpm')
  394.         self.Panel.setPixmap(QPixmap(self.blank_lcd))
  395.         self.STATUS_HISTORY_ICONS = {
  396.             ERROR_STATE_CLEAR: (None, None),
  397.             ERROR_STATE_BUSY: (self.busy_pix_small, self.busy_pix_small),
  398.             ERROR_STATE_ERROR: (self.error_pix_small, self.error_pix_small),
  399.             ERROR_STATE_LOW_SUPPLIES: (self.lowink_pix_small, self.lowtoner_pix_small),
  400.             ERROR_STATE_OK: (self.ok_pix_small, self.ok_pix_small),
  401.             ERROR_STATE_WARNING: (self.warning_pix_small, self.warning_pix_small),
  402.             ERROR_STATE_LOW_PAPER: (self.lowpaper_pix_small, self.lowpaper_pix_small) }
  403.         self.STATUS_ICONS = {
  404.             ERROR_STATE_CLEAR: (None, None),
  405.             ERROR_STATE_BUSY: (self.busy_pix, self.busy_pix),
  406.             ERROR_STATE_ERROR: (self.error_pix, self.error_pix),
  407.             ERROR_STATE_LOW_SUPPLIES: (self.lowink_pix, self.lowtoner_pix),
  408.             ERROR_STATE_OK: (self.ok_pix, self.ok_pix),
  409.             ERROR_STATE_WARNING: (self.warning_pix, self.warning_pix),
  410.             ERROR_STATE_LOW_PAPER: (self.lowpaper_pix, self.lowpaper_pix) }
  411.         self.JOB_STATES = {
  412.             3: self._devmgr4__tr('Pending'),
  413.             4: self._devmgr4__tr('On hold'),
  414.             5: self._devmgr4__tr('Printing'),
  415.             6: self._devmgr4__tr('Stopped'),
  416.             7: self._devmgr4__tr('Canceled'),
  417.             8: self._devmgr4__tr('Aborted'),
  418.             9: self._devmgr4__tr('Completed') }
  419.         if not utils.to_bool(user_cfg.alerts.email_alerts):
  420.             pass
  421.         self.email_alerts = False
  422.         self.email_to_addresses = user_cfg.alerts.email_to_addresses
  423.         self.email_from_address = user_cfg.alerts.email_from_address
  424.         if not utils.to_bool(user_cfg.refresh.enable):
  425.             pass
  426.         self.auto_refresh = False
  427.         
  428.         try:
  429.             self.auto_refresh_rate = int(user_cfg.refresh.rate)
  430.         except ValueError:
  431.             self.auto_refresh_rate = DEF_AUTO_REFRESH_RATE
  432.  
  433.         
  434.         try:
  435.             self.auto_refresh_type = int(user_cfg.refresh.type)
  436.         except ValueError:
  437.             self.auto_refresh_type = 0
  438.  
  439.         (cmd_print, cmd_scan, cmd_pcard, cmd_copy, cmd_fax, cmd_fab) = utils.deviceDefaultFunctions()
  440.         if not user_cfg.commands.prnt:
  441.             pass
  442.         self.cmd_print = cmd_print
  443.         if not user_cfg.commands.scan:
  444.             pass
  445.         self.cmd_scan = cmd_scan
  446.         if not user_cfg.commands.pcard:
  447.             pass
  448.         self.cmd_pcard = cmd_pcard
  449.         if not user_cfg.commands.cpy:
  450.             pass
  451.         self.cmd_copy = cmd_copy
  452.         if not user_cfg.commands.fax:
  453.             pass
  454.         self.cmd_fax = cmd_fax
  455.         if not user_cfg.commands.fab:
  456.             pass
  457.         self.cmd_fab = cmd_fab
  458.         log.debug('HPLIP Version: %s' % sys_cfg.hplip.version)
  459.         log.debug('Print command: %s' % self.cmd_print)
  460.         log.debug('PCard command: %s' % self.cmd_pcard)
  461.         log.debug('Fax command: %s' % self.cmd_fax)
  462.         log.debug('FAB command: %s' % self.cmd_fab)
  463.         log.debug('Copy command: %s ' % self.cmd_copy)
  464.         log.debug('Scan command: %s' % self.cmd_scan)
  465.         log.debug('Email alerts: %s' % self.email_alerts)
  466.         log.debug('Email to address(es): %s' % self.email_to_addresses)
  467.         log.debug('Email from address: %s' % self.email_from_address)
  468.         log.debug('Auto refresh: %s' % self.auto_refresh)
  469.         log.debug('Auto refresh rate: %s' % self.auto_refresh_rate)
  470.         log.debug('Auto refresh type: %s' % self.auto_refresh_type)
  471.         if not self.auto_refresh:
  472.             self.autoRefresh.toggle()
  473.         
  474.         self.cur_device_uri = ''
  475.         self.devices = { }
  476.         self.device_vars = { }
  477.         self.num_devices = 0
  478.         self.cur_device = None
  479.         self.rescanning = False
  480.         self.ToolList = ScrollToolView(self.MaintTab, 'ToolView')
  481.         MaintTabLayout = QGridLayout(self.MaintTab, 1, 1, 11, 6, 'MaintTabLayout')
  482.         MaintTabLayout.addWidget(self.ToolList, 0, 0)
  483.         self.SuppliesList = ScrollSuppliesView(self.SuppliesTab, 'SuppliesView')
  484.         SuppliesTabLayout = QGridLayout(self.SuppliesTab, 1, 1, 11, 6, 'SuppliesTabLayout')
  485.         self.SuppliesList.setHScrollBarMode(QScrollView.AlwaysOff)
  486.         SuppliesTabLayout.addWidget(self.SuppliesList, 0, 0)
  487.         QTimer.singleShot(0, self.InitialUpdate)
  488.  
  489.     
  490.     def InitialUpdate(self):
  491.         self.RescanDevices()
  492.         self.refresh_timer = QTimer(self, 'RefreshTimer')
  493.         self.connect(self.refresh_timer, SIGNAL('timeout()'), self.TimedRefresh)
  494.         if self.auto_refresh_rate <= self.auto_refresh_rate:
  495.             pass
  496.         elif self.auto_refresh_rate <= MAX_AUTO_REFRESH_RATE:
  497.             self.refresh_timer.start(self.auto_refresh_rate * 60000)
  498.         
  499.  
  500.     
  501.     def TimedRefresh(self):
  502.         if self.auto_refresh:
  503.             log.debug('Refresh timer...')
  504.             self.CleanupChildren()
  505.             if self.auto_refresh_type == 0:
  506.                 self.UpdateDevice()
  507.             else:
  508.                 self.RescanDevices()
  509.         
  510.  
  511.     
  512.     def autoRefresh_toggled(self, a0):
  513.         self.auto_refresh = bool(a0)
  514.         self.SaveConfig()
  515.  
  516.     
  517.     def closeEvent(self, event):
  518.         self.Cleanup()
  519.         event.accept()
  520.  
  521.     
  522.     def RescanDevices(self):
  523.         self.deviceRefreshAll.setEnabled(False)
  524.         self.deviceRescanAction.setEnabled(False)
  525.         self.DeviceListRefresh()
  526.         self.deviceRescanAction.setEnabled(True)
  527.         self.deviceRefreshAll.setEnabled(True)
  528.  
  529.     
  530.     def Cleanup(self):
  531.         self.CleanupChildren()
  532.         if self.cleanup is not None:
  533.             self.cleanup()
  534.         
  535.  
  536.     
  537.     def CleanupChildren(self):
  538.         log.debug('Cleaning up child processes.')
  539.         
  540.         try:
  541.             os.waitpid(-1, os.WNOHANG)
  542.         except OSError:
  543.             pass
  544.  
  545.  
  546.     
  547.     def DeviceList_currentChanged(self, a0):
  548.         self.cur_device_uri = self.DeviceList.currentItem().device_uri
  549.         self.cur_device = self.devices[self.cur_device_uri]
  550.         self.UpdateDevice()
  551.  
  552.     
  553.     def DeviceList_rightButtonClicked(self, item, pos):
  554.         popup = QPopupMenu(self)
  555.         if item is not None:
  556.             if self.cur_device.error_state not in (ERROR_STATE_BUSY, ERROR_STATE_ERROR):
  557.                 popup.insertItem(self._devmgr4__tr('Print...'), self.PrintButton_clicked)
  558.                 if self.cur_device.scan_type:
  559.                     popup.insertItem(self._devmgr4__tr('Scan...'), self.ScanButton_clicked)
  560.                 
  561.                 if self.cur_device.pcard_type:
  562.                     popup.insertItem(self._devmgr4__tr('Access Photo Cards...'), self.PCardButton_clicked)
  563.                 
  564.                 if self.cur_device.fax_type:
  565.                     popup.insertItem(self._devmgr4__tr('Send Fax...'), self.SendFaxButton_clicked)
  566.                 
  567.                 if self.cur_device.copy_type:
  568.                     popup.insertItem(self._devmgr4__tr('Make Copies...'), self.MakeCopiesButton_clicked)
  569.                 
  570.                 popup.insertSeparator()
  571.             
  572.             if self.cur_device.device_settings_ui is not None:
  573.                 popup.insertItem(self._devmgr4__tr('Device Settings...'), self.deviceSettingsButton_clicked)
  574.             
  575.             popup.insertItem(self._devmgr4__tr('Refresh Device'), self.UpdateDevice)
  576.         
  577.         popup.insertItem(self._devmgr4__tr('Refresh All'), self.deviceRefreshAll_activated)
  578.         popup.popup(pos)
  579.  
  580.     
  581.     def UpdateDevice(self, check_state = True):
  582.         log.debug(utils.bold('Update: %s %s %s' % ('*' * 20, self.cur_device_uri, '*' * 20)))
  583.         self.setCaption('%s - HP Device Manager' % self.cur_device.model_ui)
  584.         if not self.rescanning:
  585.             self.statusBar().message(self.cur_device_uri)
  586.         
  587.         if not self.rescanning:
  588.             self.UpdateHistory()
  589.             self.UpdateTabs()
  590.         
  591.  
  592.     
  593.     def CreatePixmap(self):
  594.         d = self.cur_device
  595.         
  596.         try:
  597.             pix = QPixmap(os.path.join(prop.image_dir, d.icon))
  598.         except AttributeError:
  599.             pix = QPixmap(os.path.join(prop.image_dir, 'default_printer.png'))
  600.  
  601.         error_state = d.error_state
  602.         icon = QPixmap(pix.width(), pix.height())
  603.         p = QPainter(icon)
  604.         p.eraseRect(0, 0, icon.width(), icon.height())
  605.         p.drawPixmap(0, 0, pix)
  606.         
  607.         try:
  608.             tech_type = d.tech_type
  609.         except AttributeError:
  610.             tech_type = TECH_TYPE_NONE
  611.  
  612.         if error_state != ERROR_STATE_CLEAR:
  613.             if tech_type in (TECH_TYPE_COLOR_INK, TECH_TYPE_MONO_INK):
  614.                 status_icon = self.STATUS_HISTORY_ICONS[error_state][0]
  615.             else:
  616.                 status_icon = self.STATUS_HISTORY_ICONS[error_state][1]
  617.             if status_icon is not None:
  618.                 p.drawPixmap(0, 0, status_icon)
  619.             
  620.         
  621.         p.end()
  622.         return icon
  623.  
  624.     
  625.     def DeviceListRefresh(self):
  626.         log.debug('Rescanning device list...')
  627.         QApplication.setOverrideCursor(QApplication.waitCursor)
  628.         if not self.rescanning:
  629.             self.rescanning = True
  630.             self.DeviceList.clear()
  631.             self.devices.clear()
  632.             self.supported_devices = device.getSupportedCUPSDevices()
  633.             log.debug(self.supported_devices)
  634.             self.num_devices = len(self.supported_devices)
  635.             self.devices.clear()
  636.             self.device_num = 0
  637.             if self.num_devices > 0:
  638.                 self.pb = QProgressBar(self.statusBar(), 'ProgressBar')
  639.                 self.pb.setTotalSteps(self.num_devices)
  640.                 self.statusBar().addWidget(self.pb)
  641.                 self.pb.show()
  642.                 self.scan_timer = QTimer(self, 'ScanTimer')
  643.                 self.connect(self.scan_timer, SIGNAL('timeout()'), self.ContinueDeviceListRefresh)
  644.                 self._devmgr4__NextDevice = self._devmgr4__GetNextDevice()
  645.                 self.scan_timer.start(0)
  646.             else:
  647.                 dlg = NoDevicesForm(self)
  648.                 dlg.exec_loop()
  649.                 self.close()
  650.         
  651.  
  652.     
  653.     def __GetNextDevice(self):
  654.         for d in self.supported_devices:
  655.             yield (d, self.supported_devices[d])
  656.         
  657.  
  658.     
  659.     def ContinueDeviceListRefresh(self):
  660.         
  661.         try:
  662.             (self.cur_device_uri, cups_printer_list) = self._devmgr4__NextDevice.next()
  663.         except StopIteration:
  664.             self.scan_timer.stop()
  665.             self.disconnect(self.scan_timer, SIGNAL('timeout()'), self.ContinueDeviceListRefresh)
  666.             self.scan_timer = None
  667.             del self.scan_timer
  668.             self.pb.hide()
  669.             self.statusBar().removeWidget(self.pb)
  670.             self.DeviceList.adjustItems()
  671.             self.DeviceList.updateGeometry()
  672.             self.DeviceList.setCurrentItem(self.DeviceList.firstItem())
  673.             self.rescanning = False
  674.             QApplication.restoreOverrideCursor()
  675.             if self.num_devices:
  676.                 self.UpdateDevice()
  677.             else:
  678.                 self.deviceRescanAction.setEnabled(False)
  679.                 dlg = NoDevicesForm(self, '', True)
  680.                 dlg.show()
  681.         except:
  682.             self.num_devices
  683.  
  684.         self.pb.setProgress(self.device_num)
  685.         self.device_num += 1
  686.         log.debug(utils.bold('Refresh: %s %s %s' % ('*' * 20, self.cur_device_uri, '*' * 20)))
  687.         
  688.         try:
  689.             self.cur_device = device.Device(self.cur_device_uri, hpiod_sock = self.hpiod_sock, hpssd_sock = self.hpssd_sock, callback = self.callback)
  690.         except Error:
  691.             self
  692.             self
  693.             log.error('Unexpected error in Device class.')
  694.             log.exception()
  695.             return None
  696.         except:
  697.             self
  698.  
  699.         result_code = ERROR_DEVICE_NOT_FOUND
  700.         
  701.         try:
  702.             self.cur_device.open()
  703.             self.cur_device.error_state = ERROR_STATE_CLEAR
  704.         except Error:
  705.             self
  706.             e = self
  707.             log.warn(e.msg)
  708.         except:
  709.             self
  710.         
  711.  
  712.         if self.cur_device.device_state == DEVICE_STATE_NOT_FOUND:
  713.             self.cur_device.error_state = ERROR_STATE_ERROR
  714.         self.cur_device.close()
  715.         self.CheckForDeviceSettingsUI()
  716.         icon = self.CreatePixmap()
  717.         i = IconViewItem(self.DeviceList, self.cur_device.model_ui, icon, self.cur_device_uri)
  718.         self.devices[self.cur_device_uri] = self.cur_device
  719.         self.DeviceList.setCurrentItem(i)
  720.  
  721.     
  722.     def callback(self):
  723.         pass
  724.  
  725.     
  726.     def CheckForDeviceSettingsUI(self):
  727.         self.cur_device.device_settings_ui = None
  728.         name = '.'.join([
  729.             'plugins',
  730.             self.cur_device.model])
  731.         log.debug('Attempting to load plugin: %s' % name)
  732.         
  733.         try:
  734.             mod = __import__(name, globals(), locals(), [])
  735.         except ImportError:
  736.             log.debug('No plugin found.')
  737.             return None
  738.  
  739.         components = name.split('.')
  740.         for c in components[1:]:
  741.             mod = getattr(mod, c)
  742.         
  743.         log.debug('Loaded: %s' % repr(mod))
  744.         self.cur_device.device_settings_ui = mod.settingsUI
  745.  
  746.     
  747.     def ActivateDevice(self, device_uri):
  748.         log.debug(utils.bold('Activate: %s %s %s' % ('*' * 20, device_uri, '*' * 20)))
  749.         d = self.DeviceList.firstItem()
  750.         found = False
  751.         while d is not None:
  752.             if d.device_uri == device_uri:
  753.                 found = True
  754.                 self.DeviceList.setSelected(d, True)
  755.                 self.Tabs.setCurrentPage(0)
  756.                 break
  757.             
  758.             d = d.nextItem()
  759.         return found
  760.  
  761.     
  762.     def UpdatePrintJobsTab(self):
  763.         self.PrintJobList.clear()
  764.         num_jobs = 0
  765.         if self.cur_device.supported:
  766.             jobs = cups.getJobs()
  767.             for j in jobs:
  768.                 if j.dest in self.cur_device.cups_printers:
  769.                     JobListViewItem(self.PrintJobList, j.dest, j.id, self.JOB_STATES[j.state], j.user, j.title)
  770.                     num_jobs += 1
  771.                     continue
  772.             
  773.         
  774.         self.CancelPrintJobButton.setEnabled(num_jobs > 0)
  775.  
  776.     
  777.     def PrintJobList_currentChanged(self, item):
  778.         pass
  779.  
  780.     
  781.     def PrintJobList_selectionChanged(self, a0):
  782.         pass
  783.  
  784.     
  785.     def CancelPrintJobButton_clicked(self):
  786.         item = self.PrintJobList.currentItem()
  787.         if item is not None:
  788.             self.cur_device.cancelJob(item.job_id)
  789.         
  790.  
  791.     
  792.     def UpdateTabs(self):
  793.         self.UpdateFunctionsTab()
  794.         self.UpdateStatusTab()
  795.         self.UpdateSuppliesTab()
  796.         self.UpdateMaintTab()
  797.         self.UpdatePrintJobsTab()
  798.         self.UpdatePanelTab()
  799.  
  800.     
  801.     def UpdatePanelTab(self):
  802.         dq = self.cur_device.dq
  803.         if dq.get('panel', 0) == 1:
  804.             line1 = dq.get('panel-line1', '')
  805.             line2 = dq.get('panel-line2', '')
  806.         else:
  807.             line1 = self._devmgr4__tr('Front panel display')
  808.             line2 = self._devmgr4__tr('not available.')
  809.         pm = QPixmap(self.blank_lcd)
  810.         p = QPainter()
  811.         p.begin(pm)
  812.         p.setPen(QColor(0, 0, 0))
  813.         p.setFont(self.font())
  814.         (x, y_line1, y_line2) = (10, 17, 33)
  815.         p.drawText(x, y_line1, line1)
  816.         p.drawText(x, y_line2, line2)
  817.         p.end()
  818.         self.Panel.setPixmap(pm)
  819.  
  820.     
  821.     def UpdateFunctionsTab(self):
  822.         self.ToggleFunctionButtons(self.cur_device.device_state in (DEVICE_STATE_FOUND, DEVICE_STATE_JUST_FOUND))
  823.  
  824.     
  825.     def ToggleFunctionButtons(self, toggle):
  826.         if toggle:
  827.             self.PrintButton.setEnabled(True)
  828.             self.ScanButton.setEnabled(self.cur_device.scan_type)
  829.             self.PCardButton.setEnabled(self.cur_device.pcard_type)
  830.             self.SendFaxButton.setEnabled(self.cur_device.fax_type)
  831.             self.MakeCopiesButton.setEnabled(self.cur_device.copy_type)
  832.         else:
  833.             self.PrintButton.setEnabled(False)
  834.             self.ScanButton.setEnabled(False)
  835.             self.PCardButton.setEnabled(False)
  836.             self.SendFaxButton.setEnabled(False)
  837.             self.MakeCopiesButton.setEnabled(False)
  838.  
  839.     
  840.     def UpdateHistory(self):
  841.         
  842.         try:
  843.             self.cur_device.hist = self.cur_device.queryHistory()
  844.             self.cur_device.hist.reverse()
  845.         except Error:
  846.             log.error('History query failed.')
  847.             self.cur_device.last_event = None
  848.             self.cur_device.error_state = ERROR_STATE_ERROR
  849.             self.cur_device.status_code = STATUS_UNKNOWN
  850.  
  851.         
  852.         try:
  853.             self.cur_device.last_event = self.cur_device.hist[-1]
  854.         except IndexError:
  855.             self.cur_device.last_event = None
  856.             self.cur_device.error_state = ERROR_STATE_ERROR
  857.             self.cur_device.status_code = STATUS_UNKNOWN
  858.  
  859.  
  860.     
  861.     def UpdateStatusTab(self):
  862.         self.StatusHistoryList.clear()
  863.         d = self.cur_device
  864.         for x in d.hist:
  865.             job_id = x[9]
  866.             code = x[11]
  867.             if job_id == 0:
  868.                 i = QListViewItem(self.StatusHistoryList, '', time.strftime('%x', x[:9]), time.strftime('%H:%M:%S', x[:9]), '', '', str(code), x[12])
  869.             else:
  870.                 i = QListViewItem(self.StatusHistoryList, '', time.strftime('%x', x[:9]), time.strftime('%H:%M:%S', x[:9]), x[10], str(job_id), str(code), x[12])
  871.             error_state = STATUS_TO_ERROR_STATE_MAP.get(code, ERROR_STATE_CLEAR)
  872.             
  873.             try:
  874.                 tech_type = d.tech_type
  875.             except AttributeError:
  876.                 tech_type = TECH_TYPE_NONE
  877.  
  878.             if error_state != ERROR_STATE_CLEAR:
  879.                 if tech_type in (TECH_TYPE_COLOR_INK, TECH_TYPE_MONO_INK):
  880.                     status_pix = self.STATUS_HISTORY_ICONS[error_state][0]
  881.                 else:
  882.                     status_pix = self.STATUS_HISTORY_ICONS[error_state][1]
  883.                 if status_pix is not None:
  884.                     i.setPixmap(0, status_pix)
  885.                 
  886.             status_pix is not None
  887.         
  888.         if d.last_event is not None:
  889.             self.StatusText.setText(d.last_event[12])
  890.             self.StatusText2.setText(d.last_event[13])
  891.             error_state = STATUS_TO_ERROR_STATE_MAP.get(d.last_event[11], ERROR_STATE_CLEAR)
  892.             if error_state != ERROR_STATE_CLEAR:
  893.                 if tech_type in (TECH_TYPE_COLOR_INK, TECH_TYPE_MONO_INK):
  894.                     status_icon = self.STATUS_ICONS[error_state][0]
  895.                 else:
  896.                     status_icon = self.STATUS_ICONS[error_state][1]
  897.                 if status_icon is not None:
  898.                     self.StatusIcon.setPixmap(status_icon)
  899.                 else:
  900.                     self.StatusIcon.clear()
  901.             else:
  902.                 self.StatusIcon.clear()
  903.         
  904.  
  905.     
  906.     def UpdateSuppliesTab(self):
  907.         self.SuppliesList.clear()
  908.         if self.cur_device.supported and self.cur_device.status_type != STATUS_TYPE_NONE:
  909.             a = 1
  910.             while True:
  911.                 
  912.                 try:
  913.                     agent_type = int(self.cur_device.dq['agent%d-type' % a])
  914.                 except KeyError:
  915.                     break
  916.  
  917.                 agent_kind = int(self.cur_device.dq['agent%d-kind' % a])
  918.                 agent_health = int(self.cur_device.dq['agent%d-health' % a])
  919.                 agent_level = int(self.cur_device.dq['agent%d-level' % a])
  920.                 agent_sku = str(self.cur_device.dq['agent%d-sku' % a])
  921.                 agent_desc = self.cur_device.dq['agent%d-desc' % a]
  922.                 agent_health_desc = self.cur_device.dq['agent%d-health-desc' % a]
  923.                 self.SuppliesList.addItem('agent %d' % a, '<b>' + agent_desc + '</b>', agent_sku, agent_health_desc, agent_kind, agent_type, agent_level)
  924.                 a += 1
  925.         
  926.  
  927.     
  928.     def UpdateMaintTab(self):
  929.         self.ToolList.clear()
  930.         if self.cur_device.supported and self.cur_device.device_state in (DEVICE_STATE_FOUND, DEVICE_STATE_JUST_FOUND):
  931.             self.ToolList.addItem('cups', self._devmgr4__tr('<b>Configure Print Settings</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_cups.png')), self._devmgr4__tr('Use this interface to configure printer settings such as print quality, print mode, paper size, etc. (Note: This may not work on all operating systems)'), self._devmgr4__tr('Configure...'), self.ConfigurePrintSettings_clicked)
  932.             if self.cur_device.device_settings_ui is not None:
  933.                 self.ToolList.addItem('device_settings', self._devmgr4__tr('<b>Device Settings</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_settings.png')), self._devmgr4__tr('Your device has special device settings. You may alter these settings here.'), self._devmgr4__tr('Device Settings...'), self.deviceSettingsButton_clicked)
  934.                 self.setupDevice.setEnabled(True)
  935.             else:
  936.                 self.setupDevice.setEnabled(False)
  937.             if self.cur_device.fax_type:
  938.                 self.ToolList.addItem('fax_settings', self._devmgr4__tr('<b>Fax Setup</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_fax.png')), self._devmgr4__tr('Fax support must be setup before you can send faxes.'), self._devmgr4__tr('Setup Fax...'), self.faxSettingsButton_clicked)
  939.             
  940.             self.ToolList.addItem('testpage', self._devmgr4__tr('<b>Print Test Page</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_testpage.png')), self._devmgr4__tr('Print a test page to test the setup of your printer.'), self._devmgr4__tr('Print Test Page...'), self.PrintTestPageButton_clicked)
  941.             self.ToolList.addItem('info', self._devmgr4__tr('<b>View Device Information</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_info.png')), self._devmgr4__tr('This information is primarily useful for debugging and troubleshooting.'), self._devmgr4__tr('View Information...'), self.viewInformation)
  942.             if self.cur_device.pq_diag_type:
  943.                 self.ToolList.addItem('pqdiag', self._devmgr4__tr('<b>Print Quality Diagnostics</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_pq_diag.png')), self._devmgr4__tr('Your printer can print a test page to help diagnose print quality problems.'), self._devmgr4__tr('Print Diagnostic Page...'), self.pqDiag)
  944.             
  945.             if self.cur_device.clean_type:
  946.                 self.ToolList.addItem('clean', self._devmgr4__tr('<b>Clean Cartridges</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_clean.png')), self._devmgr4__tr('You only need to perform this action if you are having problems with poor printout quality due to clogged ink nozzles.'), self._devmgr4__tr('Clean Cartridges...'), self.CleanPensButton_clicked)
  947.             
  948.             if self.cur_device.align_type:
  949.                 self.ToolList.addItem('align', self._devmgr4__tr('<b>Align Cartridges</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_align.png')), self._devmgr4__tr('This will improve the quality of output when a new cartridge is installed.'), self._devmgr4__tr('Align Cartridges...'), self.AlignPensButton_clicked)
  950.             
  951.             if self.cur_device.color_cal_type:
  952.                 self.ToolList.addItem('colorcal', self._devmgr4__tr('<b>Perform Color Calibration</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_colorcal.png')), self._devmgr4__tr("Use this procedure to optimimize your printer's color output."), self._devmgr4__tr('Color Calibration...'), self.ColorCalibrationButton_clicked)
  953.             
  954.             if self.cur_device.linefeed_cal_type:
  955.                 self.ToolList.addItem('linefeed', self._devmgr4__tr('<b>Perform Line Feed Calibration</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_linefeed_cal.png')), self._devmgr4__tr('Use line feed calibration to optimize print quality (to remove gaps in the printed output).'), self._devmgr4__tr('Line Feed Calibration...'), self.linefeedCalibration)
  956.             
  957.             if self.cur_device.embedded_server_type and self.cur_device.bus == 'net':
  958.                 self.ToolList.addItem('ews', self._devmgr4__tr('<b>Access Embedded Web Page</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_ews.png')), self._devmgr4__tr("You can use your printer's embedded web server to configure, maintain, and monitor the device from a web browser. <i>This feature is only available if the device is connected via the network.</i>"), self._devmgr4__tr('Open in Browser...'), self.OpenEmbeddedBrowserButton_clicked)
  959.             
  960.         
  961.         self.ToolList.addItem('support', self._devmgr4__tr('<b>View Support Information</b>'), QPixmap(os.path.join(prop.image_dir, 'icon_support2.png')), self._devmgr4__tr('View available support resources.'), self._devmgr4__tr('View Support...'), self.viewSupport)
  962.  
  963.     
  964.     def viewSupportAction_activated(self):
  965.         self.viewSupport()
  966.  
  967.     
  968.     def ConfigurePrintSettings_clicked(self):
  969.         utils.openURL('http://localhost:631/printers')
  970.  
  971.     
  972.     def viewInformation(self):
  973.         InformationForm(self.cur_device, self).exec_loop()
  974.  
  975.     
  976.     def viewSupport(self):
  977.         SupportForm(self).exec_loop()
  978.  
  979.     
  980.     def pqDiag(self):
  981.         d = self.cur_device
  982.         ok = False
  983.         pq_diag = d.pq_diag_type
  984.         
  985.         try:
  986.             QApplication.setOverrideCursor(QApplication.waitCursor)
  987.             d.open()
  988.             if d.isIdleAndNoError():
  989.                 QApplication.restoreOverrideCursor()
  990.                 if pq_diag == 1:
  991.                     maint.printQualityDiagType1(d, self.LoadPaperUI)
  992.                 
  993.             else:
  994.                 self.CheckDeviceUI()
  995.         finally:
  996.             d.close()
  997.             QApplication.restoreOverrideCursor()
  998.  
  999.  
  1000.     
  1001.     def linefeedCalibration(self):
  1002.         d = self.cur_device
  1003.         ok = False
  1004.         linefeed_type = d.linefeed_cal_type
  1005.         
  1006.         try:
  1007.             QApplication.setOverrideCursor(QApplication.waitCursor)
  1008.             d.open()
  1009.             if d.isIdleAndNoError():
  1010.                 QApplication.restoreOverrideCursor()
  1011.                 if linefeed_type == 1:
  1012.                     maint.linefeedCalType1(d, self.LoadPaperUI)
  1013.                 
  1014.             else:
  1015.                 self.CheckDeviceUI()
  1016.         finally:
  1017.             d.close()
  1018.             QApplication.restoreOverrideCursor()
  1019.  
  1020.  
  1021.     
  1022.     def ConfigurePrintSettings_clicked(self):
  1023.         utils.openURL('http://localhost:631/printers')
  1024.  
  1025.     
  1026.     def viewInformation(self):
  1027.         InformationForm(self.cur_device, self).exec_loop()
  1028.  
  1029.     
  1030.     def viewSupport(self):
  1031.         SupportForm(self).exec_loop()
  1032.  
  1033.     
  1034.     def pqDiag(self):
  1035.         d = self.cur_device
  1036.         ok = False
  1037.         pq_diag = d.pq_diag_type
  1038.         
  1039.         try:
  1040.             QApplication.setOverrideCursor(QApplication.waitCursor)
  1041.             d.open()
  1042.             if d.isIdleAndNoError():
  1043.                 QApplication.restoreOverrideCursor()
  1044.                 if pq_diag == 1:
  1045.                     maint.printQualityDiagType1(d, self.LoadPaperUI)
  1046.                 
  1047.             else:
  1048.                 self.CheckDeviceUI()
  1049.         finally:
  1050.             d.close()
  1051.             QApplication.restoreOverrideCursor()
  1052.  
  1053.  
  1054.     
  1055.     def linefeedCalibration(self):
  1056.         d = self.cur_device
  1057.         ok = False
  1058.         linefeed_type = d.linefeed_cal_type
  1059.         
  1060.         try:
  1061.             QApplication.setOverrideCursor(QApplication.waitCursor)
  1062.             d.open()
  1063.             if d.isIdleAndNoError():
  1064.                 QApplication.restoreOverrideCursor()
  1065.                 if linefeed_type == 1:
  1066.                     maint.linefeedCalType1(d, self.LoadPaperUI)
  1067.                 
  1068.             else:
  1069.                 self.CheckDeviceUI()
  1070.         finally:
  1071.             d.close()
  1072.             QApplication.restoreOverrideCursor()
  1073.  
  1074.  
  1075.     
  1076.     def EventUI(self, event_code, event_type, error_string_short, error_string_long, retry_timeout, job_id, device_uri):
  1077.         log.debug('Event: code=%d type=%s string=%s timeout=%d id=%d uri=%s' % (event_code, event_type, error_string_short, retry_timeout, job_id, device_uri))
  1078.         if self.ActivateDevice(device_uri):
  1079.             self.cur_device.status_code = event_code
  1080.             self.UpdateDevice(False)
  1081.             self.Tabs.setCurrentPage(1)
  1082.         
  1083.  
  1084.     
  1085.     def settingsConfigure_activated(self, tab_to_show = 0):
  1086.         dlg = SettingsDialog(self.hpssd_sock, self)
  1087.         dlg.autoRefreshCheckBox.setChecked(self.auto_refresh)
  1088.         dlg.AutoRefreshRate.setValue(self.auto_refresh_rate)
  1089.         dlg.refreshScopeButtonGroup.setButton(self.auto_refresh_type)
  1090.         dlg.auto_refresh_type = self.auto_refresh_type
  1091.         dlg.EmailCheckBox.setChecked(self.email_alerts)
  1092.         dlg.EmailAddress.setText(self.email_to_addresses)
  1093.         dlg.senderLineEdit.setText(self.email_from_address)
  1094.         dlg.PrintCommand.setText(self.cmd_print)
  1095.         dlg.ScanCommand.setText(self.cmd_scan)
  1096.         dlg.AccessPCardCommand.setText(self.cmd_pcard)
  1097.         dlg.SendFaxCommand.setText(self.cmd_fax)
  1098.         dlg.MakeCopiesCommand.setText(self.cmd_copy)
  1099.         dlg.TabWidget.setCurrentPage(tab_to_show)
  1100.         if dlg.exec_loop() == QDialog.Accepted:
  1101.             self.cmd_print = str(dlg.PrintCommand.text())
  1102.             self.cmd_scan = str(dlg.ScanCommand.text())
  1103.             self.cmd_pcard = str(dlg.AccessPCardCommand.text())
  1104.             self.cmd_fax = str(dlg.SendFaxCommand.text())
  1105.             self.cmd_copy = str(dlg.MakeCopiesCommand.text())
  1106.             self.email_alerts = bool(dlg.EmailCheckBox.isChecked())
  1107.             self.email_to_addresses = str(dlg.EmailAddress.text())
  1108.             self.email_from_address = str(dlg.senderLineEdit.text())
  1109.             old_auto_refresh = self.auto_refresh
  1110.             self.auto_refresh = bool(dlg.autoRefreshCheckBox.isChecked())
  1111.             new_refresh_value = int(dlg.AutoRefreshRate.value())
  1112.             self.auto_refresh_type = dlg.auto_refresh_type
  1113.             if self.auto_refresh and new_refresh_value != self.auto_refresh_rate:
  1114.                 self.auto_refresh_rate = new_refresh_value
  1115.                 self.refresh_timer.changeInterval(self.auto_refresh_rate * 60000)
  1116.             
  1117.             if old_auto_refresh != self.auto_refresh:
  1118.                 self.autoRefresh.toggle()
  1119.             
  1120.             self.SetAlerts()
  1121.             self.SaveConfig()
  1122.         
  1123.  
  1124.     
  1125.     def SetAlerts(self):
  1126.         service.setAlerts(self.hpssd_sock, self.email_alerts, self.email_to_addresses, self.email_from_address)
  1127.  
  1128.     
  1129.     def SaveConfig(self):
  1130.         user_cfg.commands.prnt = self.cmd_print
  1131.         user_cfg.commands.pcard = self.cmd_pcard
  1132.         user_cfg.commands.fax = self.cmd_fax
  1133.         user_cfg.commands.scan = self.cmd_scan
  1134.         user_cfg.commands.cpy = self.cmd_copy
  1135.         user_cfg.alerts.email_to_addresses = self.email_to_addresses
  1136.         user_cfg.alerts.email_from_address = self.email_from_address
  1137.         user_cfg.alerts.email_alerts = self.email_alerts
  1138.         user_cfg.refresh.enable = self.auto_refresh
  1139.         user_cfg.refresh.rate = self.auto_refresh_rate
  1140.         user_cfg.refresh.type = self.auto_refresh_type
  1141.  
  1142.     
  1143.     def SuccessUI(self):
  1144.         QMessageBox.information(self, self.caption(), self._devmgr4__tr('<p><b>The operation completed successfully.</b>'), QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
  1145.  
  1146.     
  1147.     def FailureUI(self, error_text):
  1148.         QMessageBox.critical(self, self.caption(), error_text, QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
  1149.  
  1150.     
  1151.     def WarningUI(self, msg):
  1152.         QMessageBox.warning(self, self.caption(), msg, QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
  1153.  
  1154.     
  1155.     def CheckDeviceUI(self):
  1156.         self.FailureUI(self._devmgr4__tr('<b>Device is busy or in an error state.</b><p>Please check device and try again.'))
  1157.  
  1158.     
  1159.     def LoadPaperUI(self):
  1160.         if LoadPaperForm(self).exec_loop() == QDialog.Accepted:
  1161.             return True
  1162.         
  1163.         return False
  1164.  
  1165.     
  1166.     def AlignmentNumberUI(self, letter, hortvert, colors, line_count, choice_count):
  1167.         dlg = AlignForm(self, letter, hortvert, colors, line_count, choice_count)
  1168.         if dlg.exec_loop() == QDialog.Accepted:
  1169.             return (True, dlg.value)
  1170.         else:
  1171.             return (False, 0)
  1172.  
  1173.     
  1174.     def PaperEdgeUI(self, maximum):
  1175.         dlg = PaperEdgeAlignForm(self)
  1176.         if dlg.exec_loop() == QDialog.Accepted:
  1177.             return (True, dlg.value)
  1178.         else:
  1179.             return (False, 0)
  1180.  
  1181.     
  1182.     def BothPensRequiredUI(self):
  1183.         self.WarningUI(self._devmgr4__tr('<p><b>Both cartridges are required for alignment.</b><p>Please install both cartridges and try again.'))
  1184.  
  1185.     
  1186.     def InvalidPenUI(self):
  1187.         self.WarningUI(self._devmgr4__tr('<p><b>One or more cartiridges are missing from the printer.</b><p>Please install cartridge(s) and try again.'))
  1188.  
  1189.     
  1190.     def PhotoPenRequiredUI(self):
  1191.         self.WarningUI(self._devmgr4__tr('<p><b>Both the photo and color cartridges must be inserted into the printer to perform color calibration.</b><p>If you are planning on printing with the photo cartridge, please insert it and try again.'))
  1192.  
  1193.     
  1194.     def PhotoPenRequiredUI2(self):
  1195.         self.WarningUI(self._devmgr4__tr('<p><b>Both the photo (regular photo or photo blue) and color cartridges must be inserted into the printer to perform color calibration.</b><p>If you are planning on printing with the photo or photo blue cartridge, please insert it and try again.'))
  1196.  
  1197.     
  1198.     def AioUI1(self):
  1199.         dlg = AlignType6Form1(self)
  1200.         return dlg.exec_loop() == QDialog.Accepted
  1201.  
  1202.     
  1203.     def AioUI2(self):
  1204.         AlignType6Form2(self).exec_loop()
  1205.  
  1206.     
  1207.     def Align10UI(self, pattern):
  1208.         dlg = Align10Form(pattern, self)
  1209.         dlg.exec_loop()
  1210.         return dlg.getValues()
  1211.  
  1212.     
  1213.     def AlignPensButton_clicked(self):
  1214.         d = self.cur_device
  1215.         ok = False
  1216.         align_type = d.align_type
  1217.         log.debug(utils.bold('Align: %s %s (type=%d) %s' % ('*' * 20, self.cur_device_uri, align_type, '*' * 20)))
  1218.         
  1219.         try:
  1220.             QApplication.setOverrideCursor(QApplication.waitCursor)
  1221.             d.open()
  1222.             if d.isIdleAndNoError():
  1223.                 QApplication.restoreOverrideCursor()
  1224.                 if align_type == ALIGN_TYPE_AUTO:
  1225.                     ok = maint.AlignType1(d, self.LoadPaperUI)
  1226.                 elif align_type == ALIGN_TYPE_8XX:
  1227.                     ok = maint.AlignType2(d, self.LoadPaperUI, self.AlignmentNumberUI, self.BothPensRequiredUI)
  1228.                 elif align_type in (ALIGN_TYPE_9XX, ALIGN_TYPE_9XX_NO_EDGE_ALIGN):
  1229.                     ok = maint.AlignType3(d, self.LoadPaperUI, self.AlignmentNumberUI, self.PaperEdgeUI, align_type)
  1230.                 elif align_type in (ALIGN_TYPE_LIDIL_0_3_8, ALIGN_TYPE_LIDIL_0_4_3, ALIGN_TYPE_LIDIL_VIP):
  1231.                     ok = maint.AlignxBow(d, align_type, self.LoadPaperUI, self.AlignmentNumberUI, self.PaperEdgeUI, self.InvalidPenUI, self.ColorAdjUI)
  1232.                 elif align_type == ALIGN_TYPE_LIDIL_AIO:
  1233.                     ok = maint.AlignType6(d, self.AioUI1, self.AioUI2, self.LoadPaperUI)
  1234.                 elif align_type == ALIGN_TYPE_DESKJET_450:
  1235.                     ok = maint.AlignType8(d, self.LoadPaperUI, self.AlignmentNumberUI)
  1236.                 elif align_type == ALIGN_TYPE_LBOW:
  1237.                     ok = maint.AlignType10(d, self.LoadPaperUI, self.Align10UI)
  1238.                 
  1239.             else:
  1240.                 self.CheckDeviceUI()
  1241.         finally:
  1242.             d.close()
  1243.             QApplication.restoreOverrideCursor()
  1244.  
  1245.  
  1246.     
  1247.     def ColorAdjUI(self, line, maximum = 0):
  1248.         dlg = ColorAdjForm(self, line)
  1249.         if dlg.exec_loop() == QDialog.Accepted:
  1250.             return (True, dlg.value)
  1251.         else:
  1252.             return (False, 0)
  1253.  
  1254.     
  1255.     def ColorCalUI(self):
  1256.         dlg = ColorCalForm(self)
  1257.         if dlg.exec_loop() == QDialog.Accepted:
  1258.             return (True, dlg.value)
  1259.         else:
  1260.             return (False, 0)
  1261.  
  1262.     
  1263.     def ColorCalUI2(self):
  1264.         dlg = ColorCalForm2(self)
  1265.         if dlg.exec_loop() == QDialog.Accepted:
  1266.             return (True, dlg.value)
  1267.         else:
  1268.             return (False, 0)
  1269.  
  1270.     
  1271.     def ColorCalUI4(self):
  1272.         dlg = ColorCal4Form(self)
  1273.         if dlg.exec_loop() == QDialog.Accepted:
  1274.             return (True, dlg.values)
  1275.         else:
  1276.             return (False, None)
  1277.  
  1278.     
  1279.     def ColorCalibrationButton_clicked(self):
  1280.         d = self.cur_device
  1281.         color_cal_type = d.color_cal_type
  1282.         ok = False
  1283.         log.debug(utils.bold('Color-cal: %s %s (type=%d) %s' % ('*' * 20, self.cur_device_uri, color_cal_type, '*' * 20)))
  1284.         
  1285.         try:
  1286.             QApplication.setOverrideCursor(QApplication.waitCursor)
  1287.             d.open()
  1288.             if d.isIdleAndNoError():
  1289.                 QApplication.restoreOverrideCursor()
  1290.                 if color_cal_type == COLOR_CAL_TYPE_DESKJET_450:
  1291.                     ok = maint.colorCalType1(d, self.LoadPaperUI, self.ColorCalUI, self.PhotoPenRequiredUI)
  1292.                 elif color_cal_type == COLOR_CAL_TYPE_MALIBU_CRICK:
  1293.                     ok = maint.colorCalType2(d, self.LoadPaperUI, self.ColorCalUI2, self.InvalidPenUI)
  1294.                 elif color_cal_type == COLOR_CAL_TYPE_STRINGRAY_LONGBOW_TORNADO:
  1295.                     ok = maint.colorCalType3(d, self.LoadPaperUI, self.ColorAdjUI, self.PhotoPenRequiredUI2)
  1296.                 elif color_cal_type == COLOR_CAL_TYPE_CONNERY:
  1297.                     ok = maint.colorCalType4(d, self.LoadPaperUI, self.ColorCalUI4, self.WaitUI)
  1298.                 elif color_cal_type == COLOR_CAL_TYPE_COUSTEAU:
  1299.                     ok = maint.colorCalType5(d, self.LoadPaperUI)
  1300.                 
  1301.             else:
  1302.                 self.CheckDeviceUI()
  1303.         finally:
  1304.             d.close()
  1305.             QApplication.restoreOverrideCursor()
  1306.  
  1307.  
  1308.     
  1309.     def PrintTestPageButton_clicked(self):
  1310.         d = self.cur_device
  1311.         printer_name = d.cups_printers[0]
  1312.         if len(d.cups_printers) > 1:
  1313.             ChoosePrinterDlg2 = ChoosePrinterDlg2
  1314.             import chooseprinterdlg
  1315.             dlg = ChoosePrinterDlg2(d.cups_printers)
  1316.             if dlg.exec_loop() == QDialog.Accepted:
  1317.                 printer_name = dlg.printer_name
  1318.             
  1319.         
  1320.         
  1321.         try:
  1322.             QApplication.setOverrideCursor(QApplication.waitCursor)
  1323.             d.open()
  1324.             if d.isIdleAndNoError():
  1325.                 QApplication.restoreOverrideCursor()
  1326.                 d.close()
  1327.                 if self.LoadPaperUI():
  1328.                     d.printTestPage(printer_name)
  1329.                     QMessageBox.information(self, self.caption(), self._devmgr4__tr('<p><b>A test page should be printing on your printer.</b><p>If the page fails to print, please visit http://hplip.sourceforge.net for troubleshooting and support.'), QMessageBox.Ok, QMessageBox.NoButton, QMessageBox.NoButton)
  1330.                 
  1331.             else:
  1332.                 d.close()
  1333.                 self.CheckDeviceUI()
  1334.         finally:
  1335.             QApplication.restoreOverrideCursor()
  1336.  
  1337.  
  1338.     
  1339.     def CleanUI1(self):
  1340.         return CleaningForm(self, 1).exec_loop() == QDialog.Accepted
  1341.  
  1342.     
  1343.     def CleanUI2(self):
  1344.         return CleaningForm(self, 2).exec_loop() == QDialog.Accepted
  1345.  
  1346.     
  1347.     def CleanUI3(self):
  1348.         CleaningForm2(self).exec_loop()
  1349.         return True
  1350.  
  1351.     
  1352.     def WaitUI(self, seconds):
  1353.         WaitForm(seconds, None, self).exec_loop()
  1354.  
  1355.     
  1356.     def CleanPensButton_clicked(self):
  1357.         d = self.cur_device
  1358.         clean_type = d.clean_type
  1359.         log.debug(utils.bold('Clean: %s %s (type=%d) %s' % ('*' * 20, self.cur_device_uri, clean_type, '*' * 20)))
  1360.         
  1361.         try:
  1362.             QApplication.setOverrideCursor(QApplication.waitCursor)
  1363.             d.open()
  1364.             if d.isIdleAndNoError():
  1365.                 QApplication.restoreOverrideCursor()
  1366.                 if clean_type == CLEAN_TYPE_PCL:
  1367.                     maint.cleaning(d, clean_type, maint.cleanType1, maint.primeType1, maint.wipeAndSpitType1, self.LoadPaperUI, self.CleanUI1, self.CleanUI2, self.CleanUI3, self.WaitUI)
  1368.                 elif clean_type == CLEAN_TYPE_LIDIL:
  1369.                     maint.cleaning(d, clean_type, maint.cleanType2, maint.primeType2, maint.wipeAndSpitType2, self.LoadPaperUI, self.CleanUI1, self.CleanUI2, self.CleanUI3, self.WaitUI)
  1370.                 elif clean_type == CLEAN_TYPE_PCL_WITH_PRINTOUT:
  1371.                     maint.cleaning(d, clean_type, maint.cleanType1, maint.primeType1, maint.wipeAndSpitType1, self.LoadPaperUI, self.CleanUI1, self.CleanUI2, self.CleanUI3, self.WaitUI)
  1372.                 
  1373.             else:
  1374.                 self.CheckDeviceUI()
  1375.         finally:
  1376.             d.close()
  1377.             QApplication.restoreOverrideCursor()
  1378.  
  1379.  
  1380.     
  1381.     def deviceRescanAction_activated(self):
  1382.         self.deviceRescanAction.setEnabled(False)
  1383.         self.UpdateDevice()
  1384.         self.deviceRescanAction.setEnabled(True)
  1385.  
  1386.     
  1387.     def deviceRefreshAll_activated(self):
  1388.         self.RescanDevices()
  1389.  
  1390.     
  1391.     def DeviceList_clicked(self, a0):
  1392.         pass
  1393.  
  1394.     
  1395.     def OpenEmbeddedBrowserButton_clicked(self):
  1396.         utils.openURL('http://%s' % self.cur_device.host)
  1397.  
  1398.     
  1399.     def PrintButton_clicked(self):
  1400.         self.RunCommand(self.cmd_print)
  1401.  
  1402.     
  1403.     def ScanButton_clicked(self):
  1404.         self.RunCommand(self.cmd_scan)
  1405.  
  1406.     
  1407.     def PCardButton_clicked(self):
  1408.         if self.cur_device.pcard_type == PCARD_TYPE_MLC:
  1409.             self.RunCommand(self.cmd_pcard)
  1410.         elif self.cur_device.pcard_type == PCARD_TYPE_USB_MASS_STORAGE:
  1411.             self.FailureUI(self._devmgr4__tr("<p><b>The photocard on your printer are only available by mounting them as drives using USB mass storage.</b>Please refer to your distribution's documentation for setup and usage instructions."))
  1412.         
  1413.  
  1414.     
  1415.     def SendFaxButton_clicked(self):
  1416.         self.RunCommand(self.cmd_fax)
  1417.  
  1418.     
  1419.     def MakeCopiesButton_clicked(self):
  1420.         self.FailureUI(self._devmgr4__tr('<p><b>Sorry, the make copies feature is currently not implemented.</b>'))
  1421.  
  1422.     
  1423.     def ConfigureFeaturesButton_clicked(self):
  1424.         self.settingsConfigure_activated(2)
  1425.  
  1426.     
  1427.     def RunCommand(self, cmd, macro_char = '%'):
  1428.         self.ToggleFunctionButtons(False)
  1429.         self.ToggleFunctionButtons(True)
  1430.  
  1431.     
  1432.     def helpAbout(self):
  1433.         dlg = AboutDlg(self)
  1434.         dlg.VersionText.setText(prop.version)
  1435.         dlg.exec_loop()
  1436.  
  1437.     
  1438.     def deviceSettingsButton_clicked(self):
  1439.         
  1440.         try:
  1441.             self.cur_device.open()
  1442.             self.cur_device.device_settings_ui(self.cur_device, self)
  1443.         finally:
  1444.             self.cur_device.close()
  1445.  
  1446.  
  1447.     
  1448.     def setupDevice_activated(self):
  1449.         self.cur_device.device_settings_ui(self.cur_device, self)
  1450.  
  1451.     
  1452.     def faxSettingsButton_clicked(self):
  1453.         
  1454.         try:
  1455.             self.cur_device.open()
  1456.             
  1457.             try:
  1458.                 (result_code, fax_num) = self.cur_device.getPML(pml.OID_FAX_LOCAL_PHONE_NUM)
  1459.             except Error:
  1460.                 log.error('PML failure.')
  1461.                 self.FailureUI(self._devmgr4__tr('<p><b>Operation failed. Device busy.</b>'))
  1462.                 return None
  1463.  
  1464.             fax_num = str(fax_num)
  1465.             
  1466.             try:
  1467.                 (result_code, name) = self.cur_device.getPML(pml.OID_FAX_STATION_NAME)
  1468.             except Error:
  1469.                 log.error('PML failure.')
  1470.                 self.FailureUI(self._devmgr4__tr('<p><b>Operation failed. Device busy.</b>'))
  1471.                 return None
  1472.  
  1473.             name = str(name)
  1474.             dlg = FaxSettingsForm(self.cur_device, fax_num, name, self)
  1475.             dlg.exec_loop()
  1476.         finally:
  1477.             self.cur_device.close()
  1478.  
  1479.  
  1480.     
  1481.     def addressBookButton_clicked(self):
  1482.         self.RunCommand(self.cmd_fab)
  1483.  
  1484.     
  1485.     def helpContents(self):
  1486.         f = 'file://%s' % os.path.join(sys_cfg.dirs.doc, 'index.html')
  1487.         log.debug(f)
  1488.         utils.openURL(f)
  1489.  
  1490.     
  1491.     def __tr(self, s, c = None):
  1492.         return qApp.translate('DevMgr4', s, c)
  1493.  
  1494.  
  1495.