This file is indexed.

/usr/share/hplip/ui5/cleandialog.py is in hplip-data 3.16.11+repack0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# -*- coding: utf-8 -*-
#
# (c) Copyright 2001-2015 HP Development Company, L.P.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
# Authors: Don Welch
#

# StdLib
import operator
import signal

# Local
from base.g import *
from base import device, utils, maint
from prnt import cups
from base.codes import *
from .ui_utils import *

# Qt
from PyQt5.QtCore import *
from PyQt5.QtGui import *

# Ui
from .cleandialog_base import Ui_Dialog


CLEAN_TYPE_INITIAL = 1000
CLEAN_TYPE_TEST = 1001

PAGE_START = 0
PAGE_LEVEL_1 = 1
PAGE_LEVEL_2 = 2
PAGE_LEVEL_3 = 3
PAGE_FRONT_PANEL = 4

BUTTON_CLEAN = 0
BUTTON_NEXT = 1
BUTTON_FINISH = 2

LEDM_CLEAN_VERIFY_PAGE_JOB=b"<ipdyn:JobType>cleaningVerificationPage</ipdyn:JobType>"


#d = None
def true():
    return True



class CleanDialog(QDialog, Ui_Dialog):
    def __init__(self, parent, device_uri):
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.device_uri = device_uri
        self.clean_type = CLEAN_TYPE_INITIAL
        self.abort = False
        self.seq_index = 0
        self.step = 1
        self.step_max = 0

        self.max_steps = {
                      CLEAN_TYPE_UNSUPPORTED : 1,
                      CLEAN_TYPE_PCL : 4,
                      CLEAN_TYPE_LIDIL : 4,
                      CLEAN_TYPE_PCL_WITH_PRINTOUT : 4,
                      CLEAN_TYPE_LEDM : 4,
                    }

        self.seq = { # (func|method, tuple of params|None)
                    CLEAN_TYPE_INITIAL: [ # (used when starting up and clean-type isn't known)
                               (self.showStartPage, None),
                               (self.endStartPage, None), # switch to a valid clean-type here
                            ],

                    CLEAN_TYPE_UNSUPPORTED : [
                                (self.showFrontPanelPage, None),
                                (self.endFrontPanelPage, None),
                                (self.close, None),
                            ],

                    CLEAN_TYPE_PCL : [ # 1
                            (self.showLevel1Page, None),
                            (self.endLevel1Page, None),
                            (self.doClean, (1,)),
                            (self.showLevel2Page, None),
                            (self.endLevel2Page, None),
                            (self.doClean, (2,)),
                            (self.showLevel3Page, None),
                            (self.endLevel3Page, None),
                            (self.doClean, (3,)),
                            (self.close, None),
                            ],

                    CLEAN_TYPE_LIDIL : [  # 2
                            (self.showLevel1Page, None),
                            (self.endLevel1Page, None),
                            (self.doClean, (1,)),
                            (self.showLevel2Page, None),
                            (self.endLevel2Page, None),
                            (self.doClean, (2,)),
                            (self.showLevel3Page, None),
                            (self.endLevel3Page, None),
                            (self.doClean, (3,)),
                            (self.close, None),
                            ],

                    CLEAN_TYPE_PCL_WITH_PRINTOUT : [ # 3
                            (self.showLevel1Page, None),
                            (self.endLevel1Page, None),
                            (self.doClean, (1,)),
                            (self.showLevel2Page, None),
                            (self.endLevel2Page, None),
                            (self.doClean, (2,)),
                            (self.showLevel3Page, None),
                            (self.endLevel3Page, None),
                            (self.doClean, (3,)),
                            # TODO: Add print-out
                            (self.close, None),
                            ],

                    CLEAN_TYPE_LEDM : [ # 4
                            (self.showLevel1Page, None),
                            (self.endLevel1Page, None),
                            (self.doClean, (1,)),
                            (self.showLevel2Page, None),
                            (self.endLevel2Page, None),
                            (self.doClean, (2,)),
                            (self.showLevel3Page, None),
                            (self.endLevel3Page, None),
                            (self.doClean, (3,)),
                            # TODO: Add print-out
                            (self.close, None),
                            ],
                    }


        self.initUi()
        QTimer.singleShot(0, self.nextSequence)


    def initUi(self):
        # connect signals/slots
        self.CancelButton.clicked.connect(self.CancelButton_clicked)
        self.NextButton.clicked.connect(self.NextButton_clicked)
        self.DeviceComboBox.DeviceUriComboBox_noDevices.connect(self.DeviceUriComboBox_noDevices)
        self.DeviceComboBox.DeviceUriComboBox_currentChanged.connect(self.DeviceUriComboBox_currentChanged)
        self.DeviceComboBox.setFilter({'clean-type': (operator.ne, CLEAN_TYPE_NONE)})

        signal.signal(signal.SIGINT, signal.SIG_DFL)

        if self.device_uri:
            self.DeviceComboBox.setInitialDevice(self.device_uri)

        # Application icon
        self.setWindowIcon(QIcon(load_pixmap('hp_logo', '128x128')))


    def NextButton_clicked(self):
        self.nextSequence()


    def nextSequence(self):
        while True:
            try:
                seq, params = self.seq[self.clean_type][self.seq_index]
            except IndexError:
                break

            if seq is None:
                self.seq_index += 1
                continue

            self.new_page = False

            t = []
            if params is not None:
                for p in params:
                    try:
                        t.append(p())
                    except:
                        t.append(p)

            try:
                log.debug("%s(%s)" % (seq.__name__, ','.join([repr(x) for x in t])))
            except AttributeError:
                pass

            try:
                seq(*t)
            except Error:
                CheckDeviceUI(self)
                break

            self.seq_index += 1

            if self.new_page:
                break

            if self.abort:
                self.close()


    def showStartPage(self):
        self.setCleanButton(BUTTON_NEXT)
        num_devices = self.DeviceComboBox.setDevices()

        if num_devices == 1:
            self.skipPage()
            return

        self.DeviceComboBox.updateUi()
        self.displayPage(PAGE_START)


    def endStartPage(self):
        self.mq = device.queryModelByURI(self.device_uri)
        self.clean_type = self.mq.get('clean-type', CLEAN_TYPE_NONE)
        self.seq_index = -1

        log.debug("clean-type=%d" % self.clean_type)
        self.step_max = self.max_steps[self.clean_type]

        try:
            self.dev = device.Device(self.device_uri)
        except Error:
            CheckDeviceUI(self)
            return


    def showLevel1Page(self):
        self.setCleanButton(BUTTON_CLEAN)
        self.displayPage(PAGE_LEVEL_1)


    def endLevel1Page(self):
        pass


    def showLevel2Page(self):
        self.displayPage(PAGE_LEVEL_2)


    def endLevel2Page(self):
        pass


    def showLevel3Page(self):
        self.displayPage(PAGE_LEVEL_3)


    def endLevel3Page(self):
        pass


    def showFrontPanelPage(self):
        self.setCleanButton(BUTTON_FINISH)
        self.displayPage(PAGE_FRONT_PANEL)


    def endFrontPanelPage(self):
        pass


    def DeviceUriComboBox_currentChanged(self, device_uri):
        self.device_uri = device_uri


    def DeviceUriComboBox_noDevices(self):
        FailureUI(self, self.__tr("<b>No devices that support printhead cleaning found.</b><p>Click <i>OK</i> to exit.</p>"))
        self.close()


    def CancelButton_clicked(self):
        self.close()


    def doClean(self, level):
        try:
            try:
                self.dev.open()
            except Error:
                CheckDeviceUI(self)
            else:
                if self.dev.isIdleAndNoError():
                    if self.clean_type in (CLEAN_TYPE_PCL, # 1
                                      CLEAN_TYPE_PCL_WITH_PRINTOUT): # 3

                        if level == 1:
                            maint.cleanType1(self.dev)
                            maint.print_clean_test_page(self.dev)

                        elif level == 2:
                            maint.primeType1(self.dev)
                            maint.print_clean_test_page(self.dev)

                        else: # 3
                            maint.wipeAndSpitType1(self.dev)
                            maint.print_clean_test_page(self.dev)


                    elif self.clean_type == CLEAN_TYPE_LIDIL: # 2
                        if level == 1:
                            maint.cleanType2(self.dev)
                            maint.print_clean_test_page(self.dev)

                        elif level == 2:
                            maint.primeType2(self.dev)
                            maint.print_clean_test_page(self.dev)

                        else: # 3
                            maint.wipeAndSpitType2(self.dev)
                            maint.print_clean_test_page(self.dev)

                    elif self.clean_type == CLEAN_TYPE_LEDM: # 4
                        IPCap_data = maint.getCleanLedmCapacity(self.dev)
                        print_verification_page = True
                        if LEDM_CLEAN_VERIFY_PAGE_JOB not in IPCap_data:
                            print_verification_page = False

                        if level == 1:
                            maint.cleanTypeLedm(self.dev)
                            maint.cleanTypeVerify(self.dev,level, print_verification_page)
                            if print_verification_page is False:
                                self.setCustomMessage(self.Prompt_5,"Cleaning level 1 is Completed. \nPress \"Cancel\" to Finish. Press \"Clean\" for next level clean")

                        elif level == 2:
                            maint.cleanTypeLedm1(self.dev)
                            maint.cleanTypeVerify(self.dev,level, print_verification_page)
                            if print_verification_page is False:
                                self.setCustomMessage(self.Prompt_6,"Cleaning level 2 is Completed. \nPress \"Cancel\" to Finish. Press \"Clean\" for next level clean")

                        else: # 3
                            maint.cleanTypeLedm2(self.dev)
                            maint.cleanTypeVerify(self.dev,level, print_verification_page)

                else:
                    CheckDeviceUI(self)

        finally:
            if self.dev is not None:
                self.dev.close()


    #
    # Misc
    #

    def displayPage(self, page):
        self.updateStepText(self.step)
        self.step += 1
        self.new_page = True
        self.StackedWidget.setCurrentIndex(page)


    def skipPage(self):
        self.step += 1
        self.new_page = False


    def updateStepText(self, p=None):
        if p is None or not self.step_max:
            self.StepText.setText(str(""))
        else:
            self.StepText.setText(self.__tr("Step %s of %s" % (p, self.step_max)))


    def setCleanButton(self, typ=BUTTON_CLEAN):
        if typ == BUTTON_CLEAN:
            self.NextButton.setText(self.__tr("Clean"))
        elif typ == BUTTON_NEXT:
            self.NextButton.setText(self.__tr("Next >"))
        elif typ == BUTTON_FINISH:
            self.NextButton.setText(self.__tr("Finish"))


    def setCustomMessage(self, button, message):
        button.setText(self.__tr(message))

    def __tr(self,s,c = None):
        return qApp.translate("CleanDialog",s,c)