
    =	f0                         d dl  d dlmZmZ d dlmZ d dl ddl d dlm	Z	 d dl
mZ d dl d dl d dl ddlmZ d dlZd ZdZ G d	 d
ee      Zy)    )*)deviceutils)cups   )pluginhandler)
to_unicode)	Ui_DialogNc                       e Zd ZeefdZd Zd Zd Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd ZddZy)PluginDialogc                    t         j                  | |       || _        || _        d| _        d| _        t        j                         | _        | j                  |        t               | _        | j                  j                          | j                  j                          | j                          t        j!                  d| j"                         y )N Fr   )QDialog__init__install_modeplugin_reasonplugin_pathresultr   PluginHandle	pluginObjsetupUiUserSettingsuser_settingsloaddebuginitUiQTimer
singleShotshowSourcePage)selfparentr   r   s       $/usr/share/hplip/ui5/plugindialog.pyr   zPluginDialog.__init__0   s    v&(*&335T)^!  "!T001    c                 6    | j                   j                         S N)r   	getStatusr    s    r"   isPluginInstalledzPluginDialog.isPluginInstalledB   s    ~~''))r#   c                    | j                   j                  j                  | j                         | j                  j                  j                  | j
                         | j                  t        t        dd                   i t        d t        | j                  d      t        | j                  d      t        | j                  d      t        | j                  d      t        d t         d t"        | j                  d      t$        | j                  d      t&        | j                  d	      t(        d t*        d t,        | j                  d
      t.        | j                  d      t0        d t2        d | _        y )Nhp_logo128x128z)This plugin will enable printing support.z%This plugin will enhance print speed.z'This plugin will enhance print quality.z'This plugin will add printing features.z)This plugin will enable scanning support.z(This plugin will enhance scanning speed.z0This plugin will enhance scanning image quality.z'This plugin will enable faxing support.z)This plugin will enhnace faxing features.)CancelButtonclickedconnectCancelButton_clicked
NextButtonNextButton_clickedsetWindowIconQIconload_pixmapPLUGIN_REASON_NONEPLUGIN_REASON_PRINTING_SUPPORT_PluginDialog__trPLUGIN_REASON_FASTER_PRINTING PLUGIN_REASON_BETTER_PRINTING_PQPLUGIN_REASON_PRINTING_FEATURESPLUGIN_REASON_RESERVED_10PLUGIN_REASON_RESERVED_20PLUGIN_REASON_SCANNING_SUPPORTPLUGIN_REASON_FASTER_SCANNING PLUGIN_REASON_BETTER_SCANNING_IQPLUGIN_REASON_RESERVED_200PLUGIN_REASON_RESERVED_400PLUGIN_REASON_FAXING_SUPPORTPLUGIN_REASON_FAX_FEATURESPLUGIN_REASON_RESERVED_20000PLUGIN_REASON_RESERVED_40000PLUGIN_REASON_TEXTr'   s    r"   r   zPluginDialog.initUiF   s~    	!!))$*C*CD''(?(?@ 	5Y	!BCD#
#
*DII6a,b#
 *4995\+]#
 -dii8a.b	#

 ,TYY7`-a#
 &t#
 &t#
 +DII6a,b#
 *4995_+`#
 -dii8j.k#
 '#
 '#
 )$))4]*^#
 '		2](^#
 )$#
  )$!#
r#   c                 p   | j                         }| j                  t        k(  rR| j                  j	                  d       d}||d|z  z  }| j
                  j                  | j                  |             nI| j                  t        k(  r6d}||d|z  z  }| j
                  j                  | j                  |             | j                  j                  t           j                  | j                         | j                  j                  t           j                  | j                         | j                  j                  t           j                  | j                          | j"                  j$                  d   j                  | j&                         | j(                  j*                  j                  | j,                         t/        j.                  t.        j0                  t.        j2                         | j(                  j5                  t7        t9        dd                   | j;                  t<               y )NFzAn additional driver plug-in is required to operate this printer. You may download the plug-in directly from an HP authorized server (recommended), or, if you already have a copy of the file, you can specify a path to the file (advanced).z
<br><br>%sa(  An optional driver plug-in is available to enhance the operation of this printer. You may download the plug-in directly from an HP authorized server (recommended), skip this installation (not recommended), or, if you already have a copy of the file, you can specify a path to the file (advanced).zconst QString &folder_open16x16)plugin_reason_textr   PLUGIN_REQUIREDSkipRadioButton
setEnabled
TitleLabelsetTextr7   PLUGIN_OPTIONALDownloadRadioButtontoggledboolr.   DownloadRadioButton_toggledCopyRadioButtonCopyRadioButton_toggledSkipRadioButton_toggledPathLineEdittextChangedPathLineEdit_textChangedBrowseToolButtonr-   BrowseToolButton_clickedsignalSIGINTSIG_DFLsetIconr3   r4   displayPagePAGE_SOURCE)r    reason_textmsgs      r"   r   zPluginDialog.showSourcePagef   s   --//  ++E2 CC&|K//OO##DIIcN3/1 }C&|K//OO##DIIcN3  ((.66t7W7WX$$T*2243O3OP$$T*2243O3OP%%&78@@A^A^_%%--d.K.KLfmmV^^4%%eKw,O&PQ%r#   c                    |ru| j                   j                  d       | j                  j                  d       | j                  j                  d       	 | j                   j	                  d       d | _        y y # t
        $ r Y w xY wNFTr   rX   rM   r[   r0   setStyleSheetAttributeErrorr   r    bs     r"   rT   z(PluginDialog.DownloadRadioButton_toggled   {    ((/!!,,U3OO&&t,!!//3  $D  "    A9 9	BBc                     |ro| j                   j                  d       | j                  j                  d       t        | j                   j	                               | _        | j                          y y )NT)rX   rM   r[   r	   textr   setPathIndicatorsrj   s     r"   rV   z$PluginDialog.CopyRadioButton_toggled   sZ    ((.!!,,T2)$*;*;*@*@*BCD""$	 r#   c                    |ru| j                   j                  d       | j                  j                  d       | j                  j                  d       	 | j                   j	                  d       d | _        y y # t
        $ r Y w xY wrf   rg   rj   s     r"   rW   z$PluginDialog.SkipRadioButton_toggled   rl   rm   c                 D    t        |      | _        | j                          y r%   )r	   r   rp   )r    ts     r"   rZ   z%PluginDialog.PathLineEdit_textChanged   s    %a= r#   c                    d}| j                   r5| j                   rqt        j                  j                  | j                         rH| j                  j                  | j                  d| j                  j                         z               d}nt        j                  j                  | j                         | j                  j                         k7  rG| j                  j                  | j                  d| j                  j                         z               d}|s8	 | j                  j                  d       | j                  j                  d       y 	 | j                  j                  d       | j                  j                  d       | j                  j                  d       y # t        $ r Y zw xY w# t        $ r Y Qw xY w)NTz)You must specify a path to the '%s' file.Fz!The plugin filename must be '%s'.zbackground-color: yellow; r   )r   ospathisdirrX   
setToolTipr7   r   getFileNamebasenamerh   ri   r0   rM   )r    oks     r"   rp   zPluginDialog.setPathIndicators   s`   D$4$4tGWGW9X((3^_c_m_m_y_y_{3{)}~BWWd../4>>3M3M3OO((3VW[WeWeWqWqWs3s)tuB!!//0LM OO&&u-!!//3 OO&&t,((, "  " s$   F$ F3 $	F0/F03	F?>F?c                    t        | j                  j                               }d}t        j                  j                  |      sJt        j                  | | j                  d      | j                  j                  | j                  d            }|rd|d   | _        | j                  j                  | j                         | j                  | j                  _
        | j                  j                          | j                          y )Nr   zSelect Plug-in FilezPlugin Files (*.run)r   )r	   rX   ro   ru   rv   existsQFileDialoggetOpenFileNamer7   r   working_dirr   rO   saverp   )r    rs   rv   s      r"   r\   z%PluginDialog.BrowseToolButton_clicked   s    t((--/0ww~~a ..tTYY?T5U/3/A/A/M/M/3yy9O/PRD
 #AwD%%d&6&67-1-=-=D*##% r#   c                 \    | j                  |       | j                  j                  |       y r%   )updateStepTextStackedWidgetsetCurrentIndex)r    pages     r"   ra   zPluginDialog.displayPage   s$    D!**40r#   c                 $    | j                          y r%   )closer'   s    r"   r/   z!PluginDialog.CancelButton_clicked   s    

r#   c           	      h	   | j                   j                         r&t        j                  d       | j	                          y t                	 | j                  r0| j                  j                  d      sd| j                  z   | _        nt        j                  d       t        j                         }|sVt        j                  d       t                t        | | j                  d             | j	                          	 t                y t        j                  d| j                  z         | j                  j!                  | j                  | j"                        \  }}}|t$        t&        fv rt                t(        j+                  | d| j                  d|z        t(        j,                  t(        j.                  z  t(        j.                        t(        j,                  k7  r| j                  j1                  |       | j	                          	 t                y |t2        k7  rM| j                  j1                  |       t                t        | |       | j	                          	 t                y | j                  j5                  |t6              s\| j                  j1                  |       t                t        | | j                  d	             | j	                          	 t                y t9        j:                  d
g      }|D ]  }t9        j<                  |      }|j?                  dd      s+t        j                  t        jA                  d|z               	 d }	 t9        jB                  |      }|jG                         rt        j                  d       n(t                t        | | j                  d|z               ||j	                           	 t                | j                  j1                  |       tI        | | j                  d             d| _%        | j	                          y # tD        $ rU t        j                  d       t                t        | | j                  d|z               Y |v|j	                          w xY w# |j	                          w w xY w# t                w xY w)NzSkipping plug-in installation.zhttp://zfile://z"Checking for network connection...z Network connection not detected.zDownloading plug-in from: %s z<b>%s</b><p>Without this, it is not possible to authenticate and validate the plug-in prior to installation.</p>Do you still want to install the plug-in?zPlug-in install failed.hpzfw-downloadFz%
Downloading firmware to device %s...zError opening device.z3<b>Firmware download to device failed.</b><p>%s</p>zFirmware download successful.
z&<b>Plug-in installation successful</b>T)&rL   	isCheckedlogr   r   beginWaitCursorr   
startswithinfor   check_network_connectionerrorendWaitCursor	FailureUIr7   r   downloadplugin_download_callbackERROR_UNABLE_TO_RECV_KEYSERROR_DIGITAL_SIGN_NOT_FOUNDQMessageBoxquestionYesNodeleteInstallationFilesERROR_SUCCESS
run_pluginGUI_MODEr   getSupportedCUPSDevicesqueryModelByURIgetboldDeviceErrordownloadFirmware	SuccessUIr   )	r    r{   statusdownload_plugin_file	error_strcups_devicesdevmqds	            r"   r1   zPluginDialog.NextButton_clicked   s   ))+II67JJLI	''229='043C3C'CD$ =>335II@A!OdDII.P$QRJJLt Oq HH3d6F6FFG6:nn6M6MdN^N^_c_|_|6}3F()35QRR''c		  #~  @I  #I  J(3+..(H+..Z]h]l]lm NN::;OPJJLV OS =(667KL$	*

H OE >>,,-A8L667KL$		*C DE

: O7 "994&AL# &++C066-/HHSXX&NQT&TUV& % &c 2A --/HH%FG)O%dDII6klo6o,pq =GGI1&4 O../CD$		"JKL

+  % %II&=>)O%dDII6klo6o,pq$ =GGI% =GGI ) Os   B1R% 	DR% A
R% -A0R% )AR% ,+R% RP,0AR>R% R% ,AR
2R3R% 7R% 	R

RR""R% %R1c                      y r%    )r    csrs   s       r"   r   z%PluginDialog.plugin_download_callback6  s    r#   c                     t        |       y r%   )print)r    r   s     r"   plugin_install_callbackz$PluginDialog.plugin_install_callback:  s	    ar#   c           	      x    | j                   j                  | j                  d|dz   dt        dz                y )NzStep r   z of )StepTextrO   r7   PAGE_MAX)r    ps     r"   r   zPluginDialog.updateStepText>  s*    dii!A#xz(JKLr#   c                 T    	 | j                   | j                     S # t        $ r Y y w xY wr%   )rF   r   KeyErrorr'   s    r"   rJ   zPluginDialog.plugin_reason_textB  s0    	**4+=+=>> 		s    	''Nc                 0    t         j                  d||      S )Nr   )qApp	translate)r    r   r   s      r"   __trzPluginDialog.__trI  s    ~~nQq11r#   r%   )__name__
__module____qualname__PLUGIN_NONEr5   r   r(   r   r   rT   rV   rW   rZ   rp   r\   ra   r/   r1   r   r   r   rJ   r7   r   r#   r"   r   r   /   sf    ,7GY 2$*
@&8	$%	$!
-0!,1
UpM2r#   r   )base.gbaser   r   prntr   
base.codesui_utils	installerr   base.sixextr	   PyQt5.QtCorePyQt5.QtGuiPyQt5.QtWidgetsplugindialog_baser
   r]   rb   r   r   r   r   r#   r"   <module>r      sI   0      # #    ( [27I [2r#   