%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/system-config-printer/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/system-config-printer/__pycache__/newprinter.cpython-312.pyc

�

Hf�����ddlZddlZddlZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
ZddlZddl
Z
ddlZddl�ddlZddlmZddlmZddlZddlZ	ddladaddlZddlmZdd	lmZdd
lmZddlmZddl�ddl Z ddl!Z"ddl#Z"ddl$m%Z%ddl&�dd
l'm'Z'ddl(Z(ddl)Z)ddl*Z*ddl+Z+ddl,Z,ddl-Z-e-j\ej^ej`��dZ1e2d�Z3d�Z4d�Z5d�Z6d�Z7d-d�Z8d�Z9d�Z:d�Z;d�Z<Gd�de�Z=d�Z>e?dk(�rddl@Z@	e@j�ej�dddd d!g�\ZCZDdZGdZHeCD]\ZIZJeId"k(reJZG�eId#k(s�eJZH�d$ej�d%<ddlLZLej�ej�d�eLj��ePd�ej�eR�e=�ZSd&�ZTeSj�d'eT�eSj�d(eT�eSj�d)eT�eG�eSj�d*eGeH�+�neSj�d,�ej��yy#daY���xYw#e@j�$re>�ej�d�Y��)wxYw).�N)�OpenPrintingRequest)�*)�Gdk)�GtkTF)�GObject)�GLib)�GtkGUI)�OptionWidget)�SMBURI)�PhysicalDevice)�domain�	localedirg.@z^The firewall may need adjusting in order to detect network printers.  Adjust the firewall now?c�X�tjj|�\}}|�|dk(ryy)z*Returns True is the provided URI is valid.�FT)�urllib�parse�	splittype)�uri�scheme�rests   �./usr/share/system-config-printer/newprinter.py�validDeviceURIrLs+���\�\�+�+�S�1�N�V�T�
�~��2����c��|j�}|j�\}}|D�cgc]"}tjj	||���$}}|j�}|D]W}|j
�}|j|�}|j|d�}	|j|	�|j|��Yycc}w�Nr)�
get_selection�get_selected_rowsr�TreeRowReference�new�	get_model�get_path�get_iter�get�append�remove)
�
treeview_from�treeview_to�	selection�
model_from�rows�row�model_to�path�iter�row_datas
          r�moveClassMembersr0Us����+�+�-�I� �2�2�4��J��AE�F�#�C� � �$�$�Z��5�F�D�F��$�$�&�H�� ���|�|�~���"�"�4�(���>�>�$��*������!����$�� ��	Gs�'B>c���|j�}|j�}g}|r8|j|j|d�d�|j	|�}|r�8|j�|Sr)r �get_iter_firstr$r#�	iter_next�sort)�treeview�modelr.�results    r�getCurrentClassMembersr8cse����� �E����!�D�
�F�
��
�
�e�i�i��a�(��+�,����t�$����K�K�M��Mrc��|sy|j�}|j�D].}|jr�|jj�|k(s�.yy)NFT)�lower�values�
discovered�name)�printersr=�printers   r�checkNPNamer@msM�����:�:�<�D��?�?�$����!�!�g�l�l�&8�&8�&:�D�&@���rc���	|j�}|rP|j|�tj�r*tj�tj�r�)yyy#t�YyxYw�N)�
get_window�
set_cursorr�events_pending�main_iteration�nonfatalException)�win�cursor�gdkwins   r�readyrKus\������!������v�&��$�$�'��"�"�%��$�$�'������s�AA%�%A3c��t|tjjtjj
��yrB)rKr�Cursorr�
CursorType�WATCH)rHs r�busyrPs#��	�3��
�
���s�~�~�3�3�4�5rc�$�|j�y�NT)�hide)�widget�events  r�on_delete_just_hiderV�s��
�K�K�N�rc�0�t|t�r|dS|S)z{If we don't know whether getPPDs() or getPPDs2() was used, this
    function can unwrap an item from a list in either case.r)�
isinstance�list)�xs r�
_singletonr[�s���1�d����t���Hrc�V�|jd�std|z�yd}	tjj	|t
��5}|jdk(r|j�jd�}ddd�|�td	|z�ytjd
tj�}|j|�}|r/|jd�j�j!dd
�Sy#1swY��xYw#t$r}td|�d|���Yd}~��d}~wwxYw)aGet GPG fingerprint from URL.

    Check that the URL is HTTPS with a valid and trusted server
    certificate, read it, extract the GPG fingerprint from it, and return
    it. Return None if the URL is invalid, not trusted, or the fingerprint
    can't be found.
    zhttps://z0Not a https fingerprint URL: %s, ignoring driverN)�timeout���utf-8zCannot retrieve �: zCannot retrieve %sz$ ((?:(?:[0-9A-F]{4})(?:\s+|$)){10})$�� r)�
startswith�
debugprintr�request�urlopen�
HTTPS_TIMEOUT�status�read�decode�	Exception�re�compile�M�search�group�strip�replace)�url�content�resp�e�keyid_re�ms      r�download_gpg_fingerprintry�s���>�>�*�%��E��K�L���G�8�
�^�^�
#�
#�C��
#�
?�	6�4��{�{�c�!��)�)�+�,�,�W�5��	6����'�#�-�.���z�z�A�2�4�4�H�H����� �A���w�w�q�z���!�)�)�#�b�1�1��!	6�	6���8��s�A�6�7�7��8�s/�%D�	/C8�8D�8D�=D�	D(�
D#�#D(c�B�eZdZejj
ddfejj
deffejj
deeffejj
deffejj
ddfd�ZdZ	dZ
dZdZdZ
d	Zd
ZdZdZd
Zdddddddddddd	d
dd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z		d�d�Zd�Zd�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+�Z0d�d,�Z1d-�Z2d.�Z3d/�Z4d0�Z5d1�Z6d2�Z7d�d3�Z8d4�Z9d5�Z:d6�Z;d7�Z<d8�Z=d9�Z>d:�Z?d;�Z@d<�ZAd=�ZBd>�ZCd?�ZDd@�ZEdA�ZFdB�ZGdC�ZHdD�ZId�dE�ZJdF�ZKdG�ZLdH�ZMdI�ZNdJ�ZOdK�ZPdL�ZQd�dM�ZRd�dN�ZSdO�ZTdP�ZUdQ�ZVd�dR�ZWdS�ZXdT�ZYdU�ZZdV�Z[dW�Z\dX�Z]dY�Z^dZ�Z_d[�Z`d\�Zad]�Zbd^�Zcd_�Zdd`�Zeda�Zfdb�Zgdc�Zhdd�Zide�Zjdf�Zkdg�Zldh�Zmdi�Zndj�Zodk�Zpdl�Zqdm�Zrdn�Zsdo�Ztdp�Zudq�Zvdr�Zwds�Zxdt�Zydu�Zzdv�Z{dw�Z|dx�Z}dy�Z~dz�Zd{�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�y)��
NewPrinterGUIN�)�destroy�
printer-added�printer-modified�driver-download-checked�dialog-canceledrra������TF)�parallel�usb�	bluetooth�hal�beh�hp�hpfax�dnssd�socket�lpd�scsi�serial�smb�networkc��tjj|�tjtj�|_i|_t�|_t�|_	d|_
d|_d|_d|_
d|_d|_g|_d|_d|_d|_d|_g|_d|_i|_d|_d|_d|_|j7gd�ddggd�d�t8j:��|j<t?d�d	gd
d
gddgddgd
d
gddgddgddgddgg	f|j@t?d�d	gt?d�dgt?d�dgt?d�dggf|jBt?d�d	gddgddggf|jDt?d�d	gt?d�dgt?d�dgt?d�dgt?d�dggffD]�\}}tGjHtJtJ�}|D]}|jM|��|jO|�tGjP�}|jS�|jU|d�|jW|d d!���tFjXjZ}tFjXj\}tFjXj^}t?d"�tGjHtJ�|j`|ft?d#�tGjHtJ�|jb|ft?d$�tGjHtJ�|jd|ft?d%�tGjHtJ�|jf|ft?d&�tGjHtJtJ�|jh|ft?d'�tGjHtJtJ�|jj|ft?d(�tGjHtJ�|jl|ft?d)�tGjHtJ�|jn|ffD]t\}	}
}}tGjP�}tGjp|	|d!�*�}
|jO|
�|js|
�|ju�jw|��v|jxj{d+t|�|j~j{d+t|�|_@|j�j�d�|j�j�d�|j�j�d�|j�j�d�d!|_Fd|_Gd|_H|j�}tGjP�}|jU|d�|jW|d d!�t8j�r-|j�|j�fD]}|j���t�j�j�d,�st�j�j�d-�rd.t8_Qd/|_Rn=t�j�j�d0�rd1t8_Qd2|_Rndt8_Sd3�}|j�|j�|j�fD]}|j{d4|��|j�|j�|j�|j�fD]}|j{d5d6���|jdju�}|j�|j�d�|jdj�|j�d�|jdj{d7|j��|jdj{d8|j��|j�j{d9|j��|j�j�d:�tGj�tj��|_d|j�j�d�t�s$|j�j�t?d;��|j�jO|j��tGjpt?d<��}tGjP�}|jU|d�|j�||j�d�|j�js|�tGjpt?d=��}tGjP�}|jU|d�|j�||j�d�|j�js|�|j�ju�}|j�|j�d�|jxj�|j��|jlj�d�|jlj{d>|j��tGj��}|j�t?d?��|j�d@�|j�dA�|j�dB�|j�dC�|j�dD�|j�j�|�tGj��}|j�t?dE��|j�dF�|j�j�|�dG|_wdH|_x|j��t�dI|z�y)JNF)M�NewPrinterWindow�ntbkNewPrinter�	btnNPBack�btnNPForward�
btnNPApply�spinner�	entNPName�entNPDescription�
entNPLocation�tvNPDevices�
ntbkNPType�lblNPDeviceDescription�expNPDeviceURIs�tvNPDeviceURIs�cmbNPTSerialBaud�cmbNPTSerialParity�cmbNPTSerialBits�cmbNPTSerialFlow�btnNPTLpdProbe�
entNPTLpdHost�entNPTLpdQueue�entNPTJetDirectHostname�entNPTJetDirectPort�	entSMBURI�btnSMBBrowse�
tblSMBAuth�rbtnSMBAuthPrompt�rbtnSMBAuthSet�entSMBUsername�entSMBPassword�btnSMBVerify�entNPTNetworkHostname�btnNetworkFind�lblNetworkFindSearching�lblNetworkFindNotFound�entNPTDevice�tvNCMembers�tvNCNotMembers�btnNCAddMember�btnNCDelMember�
ntbkPPDSource�	rbtnNPPPD�	tvNPMakes�rbtnNPFoomatic�filechooserPPD�rbtnNPDownloadableDriverSearch�entNPDownloadableDriverSearch�btnNPDownloadableDriverSearch�#btnNPDownloadableDriverSearch_label�$cmbNPDownloadableDriverFoundPrinters�
tvNPModels�tvNPDrivers�rbtnChangePPDasIs�rbtnChangePPDKeepSettings�scrNPInstallableOptions�vbNPInstallOptions�tvNPDownloadableDrivers�"ntbkNPDownloadableDriverProperties�lblNPDownloadableDriverSupplier�$cbNPDownloadableDriverSupplierVendor�lblNPDownloadableDriverLicense�$cbNPDownloadableDriverLicensePatents�!cbNPDownloadableDriverLicenseFree�"lblNPDownloadableDriverDescription�&lblNPDownloadableDriverSupportContacts�hsDownloadableDriverPerfText�hsDownloadableDriverPerfLineArt� hsDownloadableDriverPerfGraphics�hsDownloadableDriverPerfPhoto�$lblDownloadableDriverPerfTextUnknown�'lblDownloadableDriverPerfLineArtUnknown�(lblDownloadableDriverPerfGraphicsUnknown�%lblDownloadableDriverPerfPhotoUnknown�#frmNPDownloadableDriverLicenseTerms�tvNPDownloadableDriverLicense�rbtnNPDownloadLicenseYes�rbtnNPDownloadLicenseNo�
WaitWindow�lblWait)�SMBBrowseDialog�tvSMBBrowser�btnSMBBrowseOk)r�r�r�)r
�Defaultr�1200�2400�4800�9600�19200�38400�57600�115200�None�none�Odd�odd�Even�even�8�7zXON/XOFF (Software)�softzRTS/CTS (Hardware)�hardzDTR/DSR (Hardware)T�textrzMembers of this class�Others�Devices�Connections�Makes�Models�DriverszDownloadable Drivers)r��delete-eventz/etc/apt/sources.listz/etc/apt/sources.list.d�deb�aptz
/etc/yum.conf�rpm�yumc�F�t|dd�}|�|j|�yy)N�protect_active)�getattr�
set_active)�
toggle_widget�actives  r�protect_togglez.NewPrinterGUI.__init__.<locals>.protect_toggle�s*���m�-=�t�D�F��!��(�(�&�1�"r�clickedzchange-valuec��yrRr|)rZ�y�zs   r�<lambda>z(NewPrinterGUI.__init__.<locals>.<lambda>�s�rz
row-activatedzrow-expandedznotify::expandedrazBrowsing requires pysmbc module�Share�Commentz
query-tooltipzQPostScript Printer Description files (*.ppd, *.PPD, *.ppd.gz, *.PPD.gz, *.PPD.GZ)z*.ppdz*.PPDz*.ppd.gzz*.PPD.gzz*.PPD.GZz
All files (*)r���r?z+%s){r�__init__�locale�	getlocale�LC_MESSAGES�language�options�set�changed�	conflicts�device�ppd�remotecupsqueue�exactdrivermatch�installable_options�
ppdsloader�installed_driver_files�searchedfordriverpackages�founddownloadabledrivers�founddownloadableppd�downloadable_driver_for_printer�downloadable_printers�nextnptab_rerunr>�recommended_model_selected�
_searchdialog�_installdialog�
getWidgets�config�PACKAGEr��_r�r�r�r�	ListStore�strr$�	set_model�CellRendererText�clear�
pack_start�
add_attribute�
SelectionMode�MULTIPLE�SINGLE�BROWSEr�r�r�r�r�r�r�r��TreeViewColumn�
append_columnr�set_moder��connectrVr��WaitWindow_handlerr��
set_show_tabsr�r�r��
spinner_count�opreq�opreq_handlersr��DOWNLOADABLE_ONLYFREEr�r�rS�osr-�exists�
packagesystem�packageinstaller�DOWNLOADABLE_ONLYPPDr�r�r�r�r��set_select_function�device_select_function�set_row_separator_func�device_row_separator_fn�device_row_activated�device_row_expandedr��on_expNPDeviceURIs_expanded�set_expanded�	TreeStore�
TYPE_PYOBJECT�	smb_storer��
set_sensitive�PYSMB_AVAILABLE�set_tooltip_textr��set_cell_data_func�smbbrowser_cell_share�smbbrowser_cell_comment�smb_select_function�set_transient_forr��set_has_tooltip�on_NPDrivers_query_tooltip�
FileFilter�set_name�add_patternr��
add_filter�device_selected�dialog_mode�connect_signalsrd)�selfrT�opts�storer+�cellrx�s�br=r6r5�selection_mode�column�comboboxr�slct�col�
ppd_filters                   rrzNewPrinterGUI.__init__�s�	����� � �$�'��(�(�&�*<�*<�=��
�����u�������������$��� %���#(�� ����&(��#�).��&�(-��%�$)��!�/3��,�%'��"�$�����
�*/��'�!���"������L9�\+�'�)�0�eT1�l &�~�~�m	�V	/�t�-�-��I�,��+� �&�)� �&�)� �&�)� �&�)�!�7�+�!�7�+�!�7�+�"�H�-�/�	0��/�/��I�,��+��F�)�V�,��E�(�E�*��F�)�V�,�.�/��-�-��I�,��+��s���s��%�&�
�-�-��I�,��+��F�)�V�,��1�2�F�;��0�1�6�:��0�1�6�:�	<�=�-�'	3�
�V�
�<�M�M�3��,�E��
#�����c�"�
#�
���e�$��'�'�*�D��L�L�O����t�T�*�� � �$���2�O'	3�T
���&�&�����$�$�����$�$��
�&�
'����s�);�
�
�
�q�
"�
�x�[�#�-�-��,�d�.A�.A�1�E�
�y�\�3�=�=��-�t�/?�/?��C�
�}�
�s�}�}�S�1�4�3F�3F��J�
�w�Z����s�C�0�$�.�.��C�
�x�[�#�-�-��S�1�4�?�?�1�E�
�y�\�3�=�=��-�t�/?�/?��B�
�%�
&��
�
�c�(:�
�
)�
)�1�
.�6�	>�1�D�%��>��'�'�)�D��'�'��d��;�F����u�%��"�"�6�*��"�"�$�-�-�n�=�#	>�*	
���$�$�n�6I�J�"&�/�/�"9�"9�>�;N�#P���	
���)�)�%�0����(�(��/����%�%�e�,��/�/�=�=�e�D������
�"����<�<���#�#�%�����T�4�(����t�V�Q�/��'�'��A�A��D�D�F�
������
��7�7�>�>�1�2�b�g�g�n�n�%�7'�#(�F� �$)�D�!�
�W�W�^�^�O�
,�#(�F� �$)�D�!�+/�F�'�	2�
�@�@��=�=��@�@�B�	7�F�
�N�N�I�~�6�	7�
�8�8��;�;��<�<��9�9�;�	2�F�
�N�N�N�0�
2�		2����-�-�0��� � �$�"=�"=�t�D����/�/��1M�1M�t�T���� � �/�4�3L�3L�M���� � �.�$�2J�2J�K�	
���$�$�&8�&*�&F�&F�	H����)�)�!�,�����(=�(=�>������'�'��.�����.�.��3;�1<�
=����#�#�T�^�^�4�� � �!�G�*�-���#�#�&������e�$�����d�&@�&@�$�G����'�'��-�� � �!�I�,�/���#�#�&������e�$�����d�&B�&B�D�I����'�'��-�� � �.�.�1��� � �$�":�":�D�A����.�.�t�/D�/D�E����(�(��.���� � ��$�2Q�2Q�R��^�^�%�
����A�q�r�s����w�'����w�'����z�*����z�*����z�*����&�&�z�2��^�^�%�
����A�o�.�/����s�#����&�&�z�2�!���$��������E�D�L�!rc� �td|z�y)Nz-%s)rd�rjs r�__del__zNewPrinterGUI.__del__�s���E�D�L�!rc�0�td|z�|jr!|jj�d|_|jr!|jj�d|_|jr"|jj�d|_yy)NzDESTROY: %s)rdr�r}r�r�rws r�
do_destroyzNewPrinterGUI.do_destroysx���M�D�(�)����� � �(�(�+�#'�D� �� � ��!�!�)�)�,�$(�D�!��?�?��O�O�#�#�&�"�D�O�rc��|jdk(r4|jj�|jj�|xjdz
c_y)Nrra)rEr��show�startrws r�inc_spinner_taskzNewPrinterGUI.inc_spinner_tasksA������"��L�L��� ��L�L���!����a��rc��|xjdzc_|jdk(r5|jj�|jj�yy�Nrar)rEr�rS�stoprws r�dec_spinner_taskzNewPrinterGUI.dec_spinner_tasksF�����a�������"��L�L��� ��L�L��� �#rc�l�t|�dt|��d|�d��t|||j��S)Nz: IPP error dialog (�, �)��parent)rd�repr�show_IPP_Errorr�)rj�	exception�messages   rr�zNewPrinterGUI.show_IPP_Errors2���t�T�9�=M�7>�@�	A��y�'�$�:O�:O�P�Prc�8�|j�r|jj|�n|jj|�|jr|jj|�n|jj|�|j�yrB)�
is_changedr�add�discardr�setDataButtonState)rj�options  r�option_changedzNewPrinterGUI.option_changed sn�������L�L���V�$��L�L� � ��(�����N�N���v�&��N�N�"�"�6�*����!�rc�b�|jjt|j��yrB)r�rY�boolrrws rr�z NewPrinterGUI.setDataButtonState.s"�����'�'�D����,@�(@�Arc�p�|jdd�}|jdd�}|jdd�}t|j|�sid}t|j|dzt|�z�s1|dz
}|dk(rn&t|j|dzt|�z�s�1|dt|�zz
}|S)z-Make a suggested queue name valid and unique.rb�-�/�#r�ra�d)rrr@r>r5)rjr=�suffixs   r�makeNameUniquezNewPrinterGUI.makeNameUnique1s����|�|�S�#�&���|�|�S�#�&���|�|�S�#�&���D�M�M�4�0��F�!�4�=�=�$��*�s�F�|�2K�L��!����S�=��"�4�=�=�$��*�s�F�|�2K�L�
�C�#�v�,�&�&�D��rc�&�|jd�y)Nr})�emitrws rr}zNewPrinterGUI.destroy?s���	�	�9�rc
�	�||_|js|jjd�||_||_||_||_||_||_||_	|stj�|_|stj�|_i|_
t�|_t�|_d|_d|_d|_d|_|j+�st,�	t/j0|j|j|j��|_
	t=j>|j�|_ |jFjI�|jJjMd�|jJjOd�|jPjMd�|jRjI�|jTjW�}
|
jY�|jZ}|j]t_j`tbtb��|jdjOd�|jf}|jOtid��|jjjOd�|jljod�|	d	k7rK|jr?|jjq�|jjs|j�|jd
k(r|ju�n�|jdk(r|jw�n�|jdk(r|jy�n`|jd
k(r|j{�n@|jdk(r|j}�n |jdk(r|j�y|	d	k(r'|jr|jjs|�|jj��|j��y#tj2$r.}
|
j4\}t7||j�Yd}
~
yd}
~
wt,$rt7d|j�Yyt8$r}
t;|
�Yd}
~
yd}
~
wwxYw#tjB$r1}
|
j4\}
}tE|
||j��Yd}
~
yd}
~
wwxYw)NF)r��host�
encryptionrr�Tr�Search�9100rr?�classr �printer_with_urir!�download_driver)Br�r��set_focus_on_maprh�_device_uri�orig_ppd�devid�_host�_encryption�_name�cups�	getServer�
getEncryptionrrrr�fetchDevices_conn�ppds�ppdsmatch_result�printer_finder�_validInitParameters�RuntimeError�authconn�
Connection�	HTTPError�args�show_HTTP_ErrorrkrG�cupshelpers�getPrintersr>�IPPErrorr�r�rSr�rY�set_textr�r�r�r r8r�r6rr4r5r�r�r3r�r�r�show_nowr`�_initialisePrinterMode�_initialiseClassMode�_initialiseDeviceMode�_initialisePrinterWithURIMode�_initialisePPDMode�_initialiseDownloadDriverModer|�setNPButtons)rjrh�
device_urir=r!r�r�r�r��xidrvrnrxr6rr�labels                r�initzNewPrinterGUI.initBs�������{�{��!�!�2�2�E�:�&���%�����
���
���
�%�����
�����*�D�J��#�1�1�4�D������u�������!%�����	� $���"����(�(�+���
	� �+�+�D�4I�4I�26�*�*�8<�8H�8H�J�D�I�	�'�3�3�T�Y�Y�?�D�M�	
�$�$�)�)�,��"�"�0�0�$�7��"�"�+�+�R�0����)�)�4�0��#�#�(�(�+����(�(�*��
���
��<�<�����C�M�M�3��4�5��*�*�3�3�R�8��8�8��
����(��$�� � �)�)�&�1����)�)�$�/��!�8�����!�!�*�*�,��!�!�3�3�T�[�[�A����y�(��'�'�*�
�
�
��
(��%�%�(�
�
�
��
)��&�&�)�
�
�
�!3�
3��.�.�1�
�
�
��
&��#�#�&�
�
�
�!2�
2��.�.�1���!�8�����!�!�3�3�V�<����"�"�$�������{�~�~�	��6�6�D�Q��Q����,����	��R����-���	��q�!���	���}�}�	��V�V�F�Q���A�q����5���	�sB�.;P�*$R�R�'$Q�"R�4R�<R�R�S�''S�Sc�x�|jdvr|jduS|jdk(r|jdk7Sy)N)r�r r!r�rT)rhr�r�rws rr�z"NewPrinterGUI._validInitParameters�sC�����D�D��#�#�4�/�/�
�
�
�!2�
2��:�:��#�#�rc���|jd�|jjtd��|j	�|j
j
|j�y)Nr�z	New Class)�_initialiseWidgetsForModer��	set_titler3�fillNewClassMembersr��set_current_page�PAGE_DESCRIBE_PRINTERrws rr�z"NewPrinterGUI._initialiseClassMode�sP���&�&��0����'�'��;��8�� � �#�	
���,�,�d�.H�.H�Irc�D�|jd�|jjtd��|jj|j�|j�|jjd�|j|j�y)Nr?�New PrinterT)r�r�r�r3r�r��PAGE_SELECT_DEVICE�
fillDeviceTabr�r�on_rbtnNPFoomatic_toggledrws rr�z$NewPrinterGUI._initialisePrinterMode�sy���&�&�	�2����'�'��=�)9�:�	
���,�,�d�.E�.E�F��������&�&��-��&�&��(;�(;�<rc���|jjtd��|jj	|j
�|j
|j�y)NzChange Device URI)r�r�r3r�r�r�r�r�rws rr�z#NewPrinterGUI._initialiseDeviceMode�sJ�����'�'��+>�)?�@����,�,�d�.E�.E�F����D�,�,�-rc��|jd�|j�|jjt	d��|j
j
|j�|jjd�|j|j�|jjd�|j�|jd��y)Nr?r�Tr��step)r��_initialiseDeviceFromURIr�r�r3r�r��PAGE_SELECT_INSTALL_METHODr�rr�r��_initialiseAutoVariables�	nextNPTabrws rr�z+NewPrinterGUI._initialisePrinterWithURIMode�s����&�&�	�2��%�%�(����'�'��=�)9�:����,�,�d�.M�.M�N����&�&��-��&�&��(;�(;�<��&�&�1�1�4�8��%�%�(����q��!rc���|jjtd��|jj	|j
�d|_|jd��y)NzDownload Printer DriverTrr�)r�r�r3r�r��PAGE_DOWNLOAD_DRIVERr,r�rws rr�z+NewPrinterGUI._initialiseDownloadDriverMode�sL�����'�'��+D�)E�F����,�,�d�.G�.G�H�#������q��!rc��|j�|jjtd��|js�t|jjdd�d�}|g}|dvr|jddg�tj�|_|jjtd��|j�tj|j||j |j �	�|j"j%|j&�|j(j+d
�|j-|j(�|j.j+d
�|j1�y)Nz
Change Driver�:rar�r�r��ipp�snmpr��fetching device list��include_schemes�
reply_handler�
error_handlerT)r�r�r�r3r�r5r��split�extend�	asyncconnr�r��_begin_operationr~r��
getDevices�change_ppd_got_devsr�r�r�r�rr�r�r�)rjr�schemess   rr�z NewPrinterGUI._initialisePPDMode�s:���%�%�(����'�'��?�);�<��z�z��$�*�*�0�0�#�q�9�!�<�=�F��h�G��1�1������ 1�2�%.�%9�%9�%<�D�"��"�"�3�3�Q�7M�5N�O��!�!�$��"�"�D�$:�$:�4;�26�2J�2J�26�2J�2J�
L�
	
���,�,�d�.M�.M�N����&�&��-��&�&��(;�(;�<��&�&�1�1�4�8��%�%�(rc�*�|jj|j|��|jj�|j|j
|j|j|jfD]}|jd��y�Nr)	r�r�r��
grab_focusr�r�r�r�r�)rj�	mode_namerTs   rr�z'NewPrinterGUI._initialiseWidgetsForMode�sx��������!4�!4�i�!@�A����!�!�$��)�)��,�,��~�~�t�':�':��*�*�,�	!�F�
�O�O�R� �		!rc�R�i}tj|jfi|��|_yrB)r��Devicer�r )rj�device_dicts  rr�z&NewPrinterGUI._initialiseDeviceFromURI�s$����!�(�(�$�*:�*:�J�k�J��rc�.�d|_d|_d|_yr�)�	auto_make�
auto_model�auto_driverrws rr�z&NewPrinterGUI._initialiseAutoVariables�s����������rc��|jj�|jj�d|_|j�t	|t
�ri}n|}d}d}|jdk7r
|j}nF|j|jj�}|r|j}|j}||_|jj|j�|jd��y)Nrrr�)r��_end_operationr}r�rXrkr�r#r r�id�make_and_modelr�r�r�r�)rj�connr7�current_devicesr��mmr s       rr�z!NewPrinterGUI.change_ppd_got_devss������-�-�0����&�&�)�!%������ ��v�y�)� �O�$�O���
���:�:����J�J�E�$�(�(�$�+�+�/�/�:�F���	�	���*�*��$���	
���,�,�d�.M�.M�N����a�� rc��|j|�|jsy|jrd|_t	d�d|_|jj�|jk(r|jd��y|j�y)a
        This method is called when the PPDs loader has finished
        loading PPDs in preparation for the next screen the user will
        see, having clicked 'Forward'.  We are creating a new queue,
        and dialog_mode is either "printer" or "printer_with_uri".
        NTz-Loaded PPDs this time; try nextNPTab again...rr�)
�_getPPDs_replyr��_jockey_has_answeredr'rdr,r��get_current_pager�r�)rjr%s  r�on_ppdsloader_finished_nextz)NewPrinterGUI.on_ppdsloader_finished_nextss��	
���Z�(��y�y���*�*�-1�D�*��C�D�#������/�/�2�d�6U�6U�U��N�N�1�N�%��N�N�rc���|j�}|r|j�	|�|j�}|r@||_|j�|_	|jr%|j�|_nd|_d|_	|j�d|_
y#tj$r+}|j\}}|j||�Yd}~yd}~wwxYwrB)�	get_errorr}r�r�r�r��get_ppdsr��get_ppdsmatch_resultr�r�get_installed_filesr&r%)rjr%�excrvrxr�s      rrzNewPrinterGUI._getPPDs_reply5s���"�j�"�"�%����J���!�
��	�#�z�"�"�%����D�I�$C�J�$C�$C�$F�D�!��.�.�.L�j�.L�.L�.O��+��D�I�$(�D�!��
��������!�=�=�
������A��#�#�Q��*���
�s�B"�"C �5!C�C c���|jj�}|j�|jj�}|j�	t	j
|j�|_|jj�D]?}|j|jtjzr�.|j|f��Ay#tj$r
i|_Y�ywxYwrB)
r�r r8r�r�r�r�r>r��keys�type�CUPS_PRINTER_CLASSr$)rjr6r?s   rr�z!NewPrinterGUI.fillNewClassMembersOs���� � �*�*�,��
���
��#�#�-�-�/��
���
�	�'�3�3�T�Y�Y�?�D�M��}�}�)�)�+�	)�G��=�=��)�.�.��1H�1H�H����g�Z�(�	)���}�}�	��D�M�	�s�$C�C4�3C4c���t|j|j�|jj	tt
|j���|j	d�y�NF)r0r�r�r�rYr�r8�rj�buttons  r�on_btnNCAddMember_clickedz'NewPrinterGUI.on_btnNCAddMember_clicked]sL����,�,�d�.>�.>�?����%�%��'��(8�(8�9�:�	<����U�#rc���t|j|j�|jj	tt
|j���|j	d�yr)r0r�r�r�rYr�r8rs  r�on_btnNCDelMember_clickedz'NewPrinterGUI.on_btnNCDelMember_clickedcsL����)�)�4�+>�+>�?����%�%��'��(8�(8�9�:�	<����U�#rc��|j�}|�y|j�\}}|jj|gk7�yrB)rrr�rY�rjrTr(r)r*s     r�on_tvNCMembers_cursor_changedz+NewPrinterGUI.on_tvNCMembers_cursor_changedi�D���(�(�*�	����$�6�6�8��
�D����)�)�$�"�*�5rc��|j�}|�y|j�\}}|jj|gk7�yrB)rrr�rYrs     r� on_tvNCNotMembers_cursor_changedz.NewPrinterGUI.on_tvNCNotMembers_cursor_changedqrrc��|jr1|jj�d|_|j�|jr!|jj�d|_|jr1|jj�d|_|j�|jj�|j�T|jD]}|jj|��d|_	|jj�d|_d|_i|_|jd�y)Nr�T)r�r}r�r%r��cancelr�rSrFrG�
disconnectr r>r�)rjrTrU�handlers    r�on_NPCancelzNewPrinterGUI.on_NPCancel{s���!�!��"�"�*�*�-�%)�D�"��!�!�$��?�?��O�O�#�#�&�"�D�O�������&�&�)�"&�D���!�!�$����"�"�$��:�:�!��.�.�
0���
�
�%�%�w�/�
0�#'�D���J�J��� ��D�J������
��	�	�$�%�rc�&�|jd�y)Nr�r��rjrTs  r�on_btnNPBack_clickedz"NewPrinterGUI.on_btnNPBack_clicked�s�����r�rc�$�|j�yrBr&r's  r�on_btnNPForward_clickedz%NewPrinterGUI.on_btnNPForward_clicked�s�����rc�X�|j|�}|sy|d}|d}|d}td�|z}tj|jddtj
jtjj|��|_	|jjtd��|jj�}tj�}|j|�|j�||j_|jj!d	|j"�|jj%�|j'|||�}	|jr;|jj)�|jj+�d|_	|	S)
NFr=�repo�keyidzInstalling driver %sT)r��modal�destroy_with_parentr�buttonsr�zInstalling ...�response)�_getDriverInstallationInfor3r�
MessageDialogr��MessageType�INFO�ButtonsType�CANCELr/�format_secondary_text�get_message_area�ProgressBarr�r|�
_progress_barrB�_installdialog_response�show_all�do_installdriverpackagerSr})
rj�driver�install_infor=r,r-�fmt�
dialogarea�pbar�rets
          r�installdriverpackagez"NewPrinterGUI.installdriverpackage�sc���6�6��?�����F�#���F�#���W�%���&�'�$�.��!�/�/��8M�8M�7;�QU�69�o�o�6J�6J�9<���9O�9O�69�	;���	
���1�1�1�5E�3F�G��(�(�9�9�;�
���� �����t���	�	��-1����)����#�#�Z��1M�1M�N����$�$�'��*�*�D�$��>��������$�$�'����'�'�*�"&�D���
rc
��tdt|��dt|��dt|����tjj	�}d|d<|rd|||g}nd||g}tdt|�z�d}	tj||dt
jt
j�	�|_	|jj|jj}}d
}	|jj}
|jj���.|j�j!�}t#|�dkDr�|dk(rd}	n�|j%d
�rO	t'|dd�}|dk\r|
j)|dz�n%|
j+|dz�|
j-�n*|j.j1|j3d��t5j6�r)t5j8�t5j6�r�)|st;j<d�|jj����.|jj>dk7r|	sd
}|sg|_|S#Y��xYw#d
}Y�xYw)NzInstalling driver: z; Repo: z
; Key ID: �C�LC_ALLzinstall-printerdriverzRunning command: T)�env�	close_fds�stdin�stdoutFr�done�Prar�r_g�������?) rdr�rI�environ�copy�
subprocess�Popen�DEVNULL�PIPE�prL�stderrr/r;�poll�readlinerq�lenrc�float�set_fraction�set_pulse_step�pulser&r$rjrrErF�time�sleep�
returncode)
rjr=r,r-�new_environr�rDrLrVrMrC�line�
percentages
             rr>z%NewPrinterGUI.do_installdriverpackage�s����$�K��$�K��%�L�"�	#��j�j�o�o�'�� #��H���+�T�4��?�D�+�T�4�8�D��'�$�t�*�4�5���$	��%�%�t���-7�-?�-?�.8�o�o�?�D�F�
!%���
�
�t�v�v�}�}�V�V��D��&�&�4�4�D��&�&�+�+�-�'����)�/�/�1����I��M��v�~�#�������.�!�).�t�A�B�x��J�)�Q�� $� 1� 1�*�S�.� A� $� 3� 3�Z�K��O� D� $�
�
����3�3�:�:�4�;�;�w�;O�P��(�(�+��&�&�)��(�(�+���J�J��$�+�&�&�+�+�-�'�,�v�v� � �A�%�d���
�*,�D�'��
��#!� ��	��C�s3�;CI2�A
I+�(A'I2�1I2�I2�+I/�-I2�2I8c���|jdi�}t|j��}t|�dk(rt	d�yt|�dkDrt	dt|�z�y||d}t|�dk7rt	d�yt|j��d}d}|j
d�r|jd	�d}nC|j
d
�r$dj|jd�dd�}ntd
|z��d}d||vr#tjrI|ddvrBt	d�yt||d�}tjr|ddvr|st	d�y||jdi�j|j�}|s8t	d|j�dt||jdi�����y|||d�S)N�packagesrzNo packages for driverrazMReturned more than one matching architecture, please report this as a bug: %sz=Returned more than one package, this is currently not handledrz.debr3z.rpmr����zUnknown package type: �fingerprint)�all�noarchz?Not installing driver as it does not have a GPG fingerprint URLzANot installing driver as it does not have a valid GPG fingerprint�repositorieszLocal package system z not found in )r=r,r-)r#rYrrYrdr��endswithr��join�
ValueErrorr1�DOWNLOADABLE_PKG_ONLYSIGNEDryrL)rjr?�pkgs�arches�pkgr=r-r,s        rr2z(NewPrinterGUI._getDriverInstallationInfos����z�z�*�b�)���d�i�i�k�"���v�;�!���/�0���v�;��?��f�im�ou�iv�v�w���F�1�I����t�9��>��V�W���4�9�9�;���"�����<�<����9�9�S�>�!�$�D�
�\�\�&�
!��8�8�C�I�I�c�N�1�R�0�1�D��5��;�<�<�����S�	�)��1�1�f�Q�i�GX�6X��\�]��,�T�#�Y�}�-E�F�E��1�1�f�Q�i�GX�6X�af��^�_���C�y�}�}�^�R�0�4�4�T�5J�5J�K�����-�-��d�3�i�m�m�N�B�?�@�B�
C���t�e�=�=rc�8�|jj�yrB)rU�	terminate�rj�dialogr1s   rr<z%NewPrinterGUI._installdialog_response1s�������rc���|jj�}td|z�d}|jdk(s-|jdk(s|jdk(s|jdk(r"|j	|�}||j
k(rd}|std�y|j
�}||j|�|z}d}	|j|j�d	kDr||jk(xr|d
k\}td|z�|r�|j�|_d|_
|j�yt|jtj �r|j#�n*|j}d|_|j#�||_|js&||jk(r||j|�dz}||jk(r(|js|d
kr||j|�dz
}td
|z�|d
k\r||j$k(r|j'�|d
k\�rL||j(k(�r<d}	d}
	|j*j,rM|j*j.dvr5|j*j0d�d|j*j0d��}		|	��t|jtj �r]|jj5d�j6}t8j:j=|�\}}
|r
|
r|�d|
��}	n
|s|
r|�|
��}	|	r|	}
nd}	|j?|	�}	|j@jC|	�|
r|jDjC|
�|jjG|�|jI�y#t$r||jk(xr|d
k\}Y���wxYw#t3�Y��5xYw#t3�Y��xYw)NzNext clicked on page %dTr?r�r!r�Fz9Interrupting execution of nextNPTab(): Operations pendingrrzWill fetch ppd? %drazWill advance to page %d)r�r�r��http�httpsr��MFGrb�MDL�	modelName)%r�rrdrh�_handlePrinterInstallationMode�INSTALL_RESULT_OPS_PENDING�_getPagesOrderForDialogMode�index�
PAGE_APPLYrm�PAGE_INSTALLABLE_OPTIONS�getNPPPDr!r$rXr��PPD�fillNPInstallableOptionsr��fillDownloadableDriversr�r r�r�id_dictrG�findAttr�valuer�r��ppdMakeModelSplitr�r�r�r�r�r�)rjr��page_nr�
keep_going�install_result�order�next_page_nr�	fetch_ppdr!r=�descr�mname�maker6s              rr�zNewPrinterGUI.nextNPTab4s����%�%�6�6�8���-��7�8��
����y�(�D�,<�,<�@R�,R����%�'�4�+;�+;�?P�+P�!�@�@�$�G�N���!@�!@�@�#�
���S�T���0�0�3���U�[�[��1�$�6�7���	�	T��{�{�D�O�O�,�r�1�(�D�O�O�;�I���	�	�	�(�9�4�5���}�}��D�H�',�D�$��x�x����$�(�(�D�H�H�-��-�-�/��h�h������-�-�/�����+�+��4�#@�#@�@�#(����\�)B�1�)D�#E�L��4�8�8�8��,�,���� ����\�!:�1�!<�=�L��-��<�=��1�9���)B�)B�B��(�(�+��1�9���)C�)C�C��D��E�
%��K�K�N�N����(�(�-K�K�&*�k�k�&9�&9�%�&@�&*�k�k�&9�&9�%�&@�B�D�
	
%��<�J����$�(�(�$C� �H�H�-�-�{�;�A�A�E�"-�"2�"2�"D�"D�e�"L�K�D�%���*.��6����)-�u�5����� ���&�&��-�D��N�N�#�#�T�*���%�%�.�.��6����,�,�\�:������Q�	T�$��(E�(E�E�S�$�RS�)�I�	T��Z
%�!�$��
%�!�$�s,�4N&�A#O�'BO�&O	�O	�O�O,c��	�g}|jdk(r%|j|j|jg}|S|jdk(r|jg}|S|jdk(�r�|j
r|j|jg}|S|jr�|jj�s�|jr0|j|j|j|jg}|S|j|j|j|j|j|jg}|S|jr?|jj�s%|j|j|jg}|S|jj�r;|j|j|j|j|jg}|S|jj�r0|j|j|j|jg}|S|j|j|j|j|jg}|S|jdk(r�|jj�r0|j|j|j|jg}|S|jj�r%|j|j|jg}|S|j|j|j|jg}|S|jdk(r|jg}|S|j
r|jg}|S|jr�|jj�sl|jr%|j|j|jg}|S|j|j|j|j|jg}|S|jr4|jj�s|j|jg}|S|jj�r0|j|j|j|jg}|S|jj�r%|j|j|jg}|S|j|j|j|jg}|S)Nr�r�r?r!r )rhr��PAGE_CHOOSE_CLASS_MEMBERSr�r�r"r�r(r��
get_activer#r�r��PAGE_CHOOSE_DRIVER_FROM_DBr�r�)rjr�s  rr~z)NewPrinterGUI._getPagesOrderForDialogMode�s��������w�&��*�*��.�.�����E�T��K�
�
�!2�
2��)�)��E�H��C�
�
��
*��#�#��+�+��.�.���~��w�/�/��9�9�D�D�F��(�(��/�/��1�1��5�5��2�2�	�E�p��a�/�/��1�1��7�7��7�7��5�5��2�2�
�E�b��S�'�'��9�9�D�D�F��+�+��1�1��.�.���N��E�$�$�/�/�1��+�+��3�3��3�3��1�1��.�.���B��u���*�*�,��+�+��3�3��1�1��.�.�	��r��a�+�+��3�3��-�-��1�1��.�.���b��U�
�
��
&��"�"�-�-�/��3�3��3�3��O�O��1�1�	��P��E���*�*�,��3�3��O�O��1�1���B��s�3�3��-�-��O�O��1�1�	��t��i�
�
��
)��'�'��E�f��_�#�#��.�.���\��W�/�/��9�9�D�D�F��(�(��1�1��5�5��2�2��E�P��C�1�1��7�7��7�7��5�5��2�2��E�D��7�'�'��9�9�D�D�F��1�1��.�.���2��+�$�$�/�/�1��3�3��3�3��1�1��.�.�	��(�����*�*�,��3�3��1�1��.�.������3�3��-�-��1�1��.�.�	���rc���t|j�|jj�}|jj�}|j}||j
k(s||jk(r|dkDs#||jk(s||jk(r|dk(r|j||�}||jk(r�|jjsm	|jj�j�\}}|j|d�d}|j!|�}|j"j%|�t)|j�|S#t'�Y�%xYwr)rPr�r�r�INSTALL_RESULT_DONEr�r�r��_handlePrinterInstallationStager�r r�r�r�get_selectedr#r�r�r�rGrK)rjr�r�r7r6r.r=s       rr|z,NewPrinterGUI._handlePrinterInstallationMode(s4���d�#�#�$��%�%�6�6�9���%�%�6�6�9���)�)����0�0�0���2�2�2��q����8�8�8���2�2�2���	��9�9�7�D�I�F��d�5�5�5��;�;�>�>�)�"&�/�/�"?�"?�"B�".�,�/� �E�4� �9�9�T�1�-�a�0�D��.�.��5�D��N�N�+�+�T�2�	�t�$�$�%��
��	)�%�(�s
�A,E�E%c�2�|jdk7rV|jj}|r>|jd�r-t	|dd��j�}|j
�||jk(s||jk(r|j�n.||jk(r|jdk(r|j�d}|jr|jdk(rp|jdk7r|jj}|s|j}|sd}|j �-|jdk7r|j#|�|j$Sd|_||jk(s||jk(r|j'�|j)|||�S)Nr�r�r��rFr!)rhr rrcr�sanitize_uri�_installSMBBackendIfNeededr�r��_selectDeviceForInstallationr�r,�_handleDriverInstallationr"r�r�r��_loadPPDsForDevicer}�_installHPScannerFilesIfNeeded�_installPrinterFromDeviceID)rjr�r�rr�s     rr�z-NewPrinterGUI._handlePrinterInstallationStageKsf�����0�0��+�+�/�/�C��s�~�~�u�-��#�a�b�'�*�7�7�:���/�/�2��d�-�-�-��D�<[�<[�1[��-�-�s�3�
��1�1�
1�d�6J�6J�e�6S��*�*�-����#�#�t�'7�'7�5�'@����#4�4���������
�
������y�y� �T�%5�%5�9J�%J��'�'���4��6�6�6�$����d�-�-�-��D�<[�<[�1[��/�/�2��/�/����F�Frc�T�|jdk(r�|js{|jdk(s|jddk(rYtjdtj
�s4t
d�	tj�}|jddd�yyyyy#t�YyxYw)NF�	localhostrr�z/usr/lib/cups/backend/smbz$No smb backend so attempting install�	smbclient)r,r'r�rI�access�F_OKrd�installpackage�
PackageKit�InstallPackageNamerG�rj�pks  rr�z(NewPrinterGUI._installSMBBackendIfNeededms���� � �E�)�$�2P�2P��
�
�k�)�T�Z�Z��]�c�-A��9�9�9�2�7�7�C��>�?�
%�#�.�.�1���%�%�q�!�[�9�D�.B�3Q�)��
%�!�$�s�-'B�B'c� �|j�|j�|j_|jr1|jj�d|_|j
�|jr1|jj�d|_|j
�|jjs(|jjdvr|j�d|_tjd|�}|�r�|j�}t!|d�dkDrt#|ddd�}nd}	t%d�t&j(j+|d|�}|j-dd|d	z�|j/�}|j0d
k(r
|d	|_|j3�}t5j6�5}|j9|�|j;�	t=j>|j@�}		ddd�	t<jH}
t=jJ|d||
��}d
dg}|jM||��}
|
jOd
d�}|
jOdd�}t!|�dkDr|jPjS|�t!|�dkDr||j_*yy|jYd�s|jYd�rH|j[d�dk7r3|jj\r|jj\|_yyyy#t<jBtDf$rtGd��wxYw#1swY��NxYw#Y��VxYw#tD$rYytW�YyxYw)Nr�z"ipp://(\S+?)(:\d+|)/printers/(\S+)rariwz$Download ppd file from remote server�GETz/printers/%s.ppdr�r^zServer's ppd file is corrupted.)r��portr�zprinter-infozprinter-location)r�requested_attributesr�dnssd:�mdns:�/cupsr)/r��getDeviceURIr rr�r}r�r�r!r�r�getNetworkPrinterMakeModelr"rlro�groupsrY�intrdrw�client�HTTPConnectionre�getresponserhri�tempfile�NamedTemporaryFile�write�flushr�r�r=r�r��IOError�HTTP_ENCRYPT_IF_REQUESTEDr��getPrinterAttributesr#r�r��locationrGrc�find�info)rjr�res�resgr�rru�
ppdcontent�tmpfr!r��c�r�attrsr�r�s                rr�z*NewPrinterGUI._selectDeviceForInstallationzs���%�%�(��+�+�.������!�!��"�"�*�*�-�%)�D�"��!�!�$�������&�&�)�"&�D���!�!�$�������K�K��� 8�8�
�+�+�.� $����i�i�>��D����:�:�<�D��D��G�}�q� ��D��G�A�B�K�(����
��A�B��{�{�1�1�$�q�'�4�@�����U�$6��a��$@�A��'�'�)���;�;�#�%�+/��7�D�(�!�Y�Y�[�
��0�0�3�I�t��J�J�z�*��J�J�L�I�"�h�h�t�y�y�1��	I�
%�!�;�;�
��O�O�$�q�'�*.�0:�<��$�%7�8���.�.�C�EF�/�H���y�y�.�"�5�� �9�9�&8�"�=����:��>��)�)�2�2�D�9���>�A�%�+3�D�K�K�(�&��~�~�x�(�C�N�N�7�,C����'�"�b�(�T�[�[�-=�-=�#'�;�;�#3�#3�D� �.>�(�-D��7!�M�M�<�8�I�%�&G�H�H�I��I�I��
���( �
��
%�!�$�sJ�>BM-�"M �4L8�M-�B.M5�8%M�M � M*�%M-�-M2�5	N
�N
c��|j}|j�j�\}}d}|�|j|d�}|�	|dk(sd|vry|j	|�}|rt|j�dk(ryd|_|jdk7rp|jjsY|jjr|jjdk(r)|jr|j|j_yyyyy�Nrarrer��Unknown�
r�rr��	get_valuerErYr&r�rhr r�rr*)rjr5r6r.r?r7s      rr�z'NewPrinterGUI._handleDriverInstallation�s����/�/���,�,�/�<�<�?���t������_�_�d�A�.�F��>�V�q�[�J�f�,D���*�*�F�3����T�8�8�9�Q�>�
���	���� 1�1��;�;�>�>��;�;�-�-����1K�1K�y�1X��2�2�)-�)M�)M�D�K�K�&�3�2Y�"�
2rc�h�t|jd�r�|jjr~tjdtj
�sYtjdtj
�s4t
d�	tj�}|jddd�yyyyy#YyxYw)N�hp_scannablez/etc/sane.d/dll.d/hpaioz/etc/sane.d/dll.d/hplipz+No HPLIP sane backend so attempting installrz
libsane-hpaio)
�hasattrr r�rIr��R_OKrdr�r�r�r�s  rr�z,NewPrinterGUI._installHPScannerFilesIfNeeded�s����T�[�[�.�1�d�k�k�6N�6N��I�I�8�"�'�'�B��I�I�8�"�'�'�B��-�
.�
�#�.�.�1���%�%�q�!�_�=�
C�C�7O�1��
��s�'B-�-B1c���td�tj|||j|j|j
��}||_|j
d|j�|j�y)NznextNPTab: need PPDs loaded)�	device_idr�r�r�r��finished)	rdr%�
PPDsLoaderr�r�r�rBr�run)rjr�rrUs    rr�z NewPrinterGUI._loadPPDsForDevice�s`���1�2��!�!�U�.1�*.�*?�*?�(,�
�
�.2�.>�.>�	
@��
���	�	�	�:�d�>�>�?�	���rc���d}g|_	|jdk(rd}d}�nv|jrQ|j�	d}||_|j}|j	|�}|j
j
|�d}�n|jjs2|jjr|jjdk7s|�rq|jjr|jj}no|rtj|�}nWi}tjj|jj�\|d<|d<d	|d
<g|d<d|d�d
|d�d�}|jj|d|d|d
|d|jj |jj�}t#dt%|�z�|jj't)|j+��|j,||��}	t#dt%|	�z�|	|_|	d}||}�n`|jdk(r�|j.r�|j.j1d�}
|
s|j.j1d�}
|
r�|
j2r�|
j2}|j5d�r|dd}tjj|�}|\}
}|jj7|
|�}|j9�D]&\}}t;|j=d��|k(s�$|}n|rd}n_d}||_d}nS|jdk(rd}||_d}n8|jj?dddg|jj �\}}d}|r0|jr|jdk(r|jC||||�S|jDS#tA�Y�LxYw)Nr��download�generic�raw�exactr�ryrzr�DES�CMD�MFG:�;MDL:�;zSuitable PPDs found: %s)r��fitzPPDs in priority order: %srr!�NickName�	ModelName� (recommended)i��ppd-make-and-model�Generic�PrinterzGeneric Printer)#�id_matched_ppdnamesrhr"r!r�r�r�r r�rr�r��
parseDeviceIDr�r��getPPDNamesFromDeviceIDrrdr��orderPPDNamesByPreferencerYrr&r�r�r�rk�getInfoFromModel�itemsr[r#�getPPDNameFromDeviceIDrG� _installPrinterOrSearchForDriverr�)rjr�r�r��ppdnamerhr=r�r��ppdnamelist�attrr��mfgmdlr�r6r�r!r�s                  rr�z)NewPrinterGUI._installPrinterFromDeviceID�s�����#%�� �Y	!����#4�4�$��"���%�%��8�8�#�#�G�&�D�H��+�+���*�*�D�1�����'�'��.� ���+�+�.�.��;�;�-�-��;�;�-�-��:���;�;�>�>�"�k�k�1�1�G��)�7�7��?�G� �G�'2�'7�'7�*�*�D�K�K�,F�,F�G�%�W�U�^��U�^�%'�G�E�N�%'�G�E�N�07���07���@�E��i�i�+�+�W�U�^�-4�U�^�-4�U�^�-4�U�^�-1�[�[�_�_�-1�[�[�-G�-G�I���5��S�	�A�B�"�i�i�-�-�t�C�H�H�K�/@�/3�/J�/J�5<�#�.�G���8�4��;L�L�M�+6��(�%�a�.���W����"�"�e�+��
�
��}�}�-�-�j�9����=�=�1�1�+�>�D��D�J�J� �J�J�E��~�~�'7�8� %�d�s���(�-�-�?�?��G�F�$*�M�T�5� �9�9�5�5�t�U�C�D�%)�Z�Z�]�"�	��T�&��(+��-A�(B�D�!�"�'*�G�!�"��$�F�#�G�&�D�H�&�F��!�!�U�*���"��� ��$(�I�I�*�*�I�,5�,=�,.�,0�K�K�O�O�	=�"���#��
��%�%��)9�)9�U�)B��8�8�%��&�RY�[_�`�`��'�'�'��	!�� �s�L!O�-A)O�O"c�L�	|dk7rr|jj|�}t|d�}tjj	|�\}}	||_|	|_||_|j||	�|dk(s|dk(r*|jdk7rd|_
|dk(�r�|j}�n�d|_
|jdk7�r||jdk(�rl|�rit|�dkD�rZ|jd	�dk\�sE|jd
�dk\�s0|jd�dk\�s|jd�dk\�s|jd
�dk\�s�|jd�dk\�s�|jd�dk\�s�|jd�dk\�s�td�td|z�d|_d|_t#d�}
t%j&|j(ddt$j*j,t$j.j0|
��|_|j2j5t#d��t7�|_|j2j;d|j<�|j2j?�g|_ |j@jC|j8j;d|jD��|j@jC|j8j;d|jF��d|_$|j8jK|�|jLS|jdk(s*|jdk7r+|jPs||jRk7r|jU�|jVS#tO�Y�cxYw)Nr�r�r�z	exact-cmdr!TrFzMFG:generic;zMFG:Generic;zMFG:unknownzMFG:UnknownzMDL:unknownzMDL:UnknownzMFG:;zMDL:;z7nextNPTab: No exact driver match, querying OpenPrintingznextNPTab: Searching for "%s"�	Searching�r�r.r/�message_typer0r�zSearching for driversr1r��errorr�),r��getInfoFromPPDNamer[r�r�r�r�r��fillDriverListrhr#r�r'rYr�rd�_searchdialog_canceledr3rr3r�r4r5r6r7r.r8rrFrB�_searchdialog_responser=rGr$�opreq_id_search_done�opreq_id_search_error�opreq_user_search�searchPrintersr}rGr"r��fillMakeListr�)rjr�r�rhr�r��ppddict�
make_modelr�r6rAs           rr�z.NewPrinterGUI._installPrinterOrSearchForDriveras)��D	!��*�$��)�)�6�6��@��'��1E�)F�G�
��$�$�6�6�
�C���u�!%���"'���#*�� ��#�#�D�%�0��7�"�f��&;�� � �E�)�(,��%��1�9�"�;�;�G�(-��%��$�$��-��2�2�e�;��c�%�j�1�n����N�3�q�8����N�3�q�8����M�2�a�7����M�2�a�7����M�2�a�7����M�2�a�7����G�,��1����G�,��1�� Y�Z�� ?�%� G�H�59�D�2�27�D�/��K�.�C�),�):�):�#�4�4�"�,0�%(�_�_�%9�%9� #��� 6� 6� �
*"�D�&��&�&�<�<��1�2�4�"5�!7�D�J��&�&�.�.�"�D�$?�$?�A��&�&�/�/�2�*,�D�'��'�'�.�.��
�
�*�*�&� �5�5�7�8��'�'�.�.��
�
�*�*�#� �6�6�8�9�.3�D�*��J�J�-�-�u�5� �:�:�:�
����%��!�!�%6�6��)�)�g��9R�9R�.R������'�'�'��	!�� �s�L=N�N#c�6�|jjd�|jjt	d��g|_d|_d|_d|_t|j�tj|jj�y�NTr�F)r�rYr�r�r3r&r'r(r)rKr�r�idle_addrFr!rts   rrz$NewPrinterGUI._searchdialog_response�sv��	
�*�*�8�8�$�?��0�0�9�9�1�X�;�G�&(��#�)-��&�(-��%�$)��!�
�t�$�$�%�	
�
�
�t�z�z�(�(�)rc��|jD]}|j|��tj�	d|_d|_d|_|jj�|jj�d|_t|�dkrNt|j�d|_|jdk(r|jd�n�|j�n�||_||_d|_	|jj%�|j'�|j)�sNt|j�d|_|jdk(r|jd�nC|j�n2|jdk(r|jd��n|j�tj,�y#t+�|j�Y�3xYw#tj,�wxYw)NFrar�Trr�)rGr"r�
threads_enterrrFr.rSr}rYrKr�r(rhr$r�r+�downloadable_driversr|r�r�rG�
threads_leave)rjrFr>�driversr#s     rrz"NewPrinterGUI.opreq_id_search_done�s����*�*�	'�G����g�&�	'�	����,	!�%*�D�"�"&�D���D�J����#�#�&����&�&�)�!%�D���H�~��!��t�,�,�-�05��-��#�#�'8�8��$�$�T�*��N�N�%�-5��*�,3��)�04��-�&��)�)�.�.�0��%�%�'��7�7�9��t�4�4�5�8=��5��+�+�/@�@� �,�,�T�2� �N�N�-��+�+�/@�@� �N�N�1�N�5� �N�N�-�
��� ��&�%�(��N�N�%��
��� �s�CG*�:B:G	�	G'�%G*�*Hc�|�td|t|�fz�|j|t�t	��y�Nz$OpenPrinting request failed (%d): %s)rdr�rrY�dict�rjrFrh�errs    rrz#NewPrinterGUI.opreq_id_search_error�s9���:�f�>B�C�j�>J�J�	K��!�!�5�$�&�$�&�9rc��|j}|j�j�\}}d}|�|j|d�}|�	|dk(sd|vry|j	|�rt|j�dkryd|_|jdk7rp|jjsY|jjr|jjdk(r)|jr|j|j_yyyyyr�r�)rjr5r6r.r?s     r�&_installSelectedDriverFromOpenPrintingz4NewPrinterGUI._installSelectedDriverFromOpenPrinting�s����/�/���,�,�/�<�<�?���t������_�_�d�A�.�F��N�f��k�Z�v�-E���(�(�&�1��D�/�/�0�A�5����	����0�0��K�K�N�N��[�[�/�/����+�+����4�4��8�8����*�5��#�1rc��|jj�}|jdk(r�|jj	�|j
j	�|jj�	|j�}t|�}|jj|�y|jdk(�r@||jk(r�|js@td�|j
j	�|jj�y|j
j�|jj	�y||jk(r5|j
j	�|jj�y|j
j�|jj	�||j k(�r|jj	�|j
j�d}|j"j%�r@|j&}|j)�}|r"|j+�j-|d�rd}|j
jt/|j0j%�xr|j2j5�dduxs|j6j9�xs|��y|jj�|jdk(rz|jj	�|j
j	�|jj�|j;�}|jj|�y||j<k(rTd}	|j�}t|�}|j
j|�|jj	�n|jj�|j
j�|jj	�||j@k(�r)|jj�|jd	k(s|jd
k(r{|j
j	�|jj�|jjtC|jD|jFjI���|jdk(r|jj	�|jd
k(r>|jJs|jLr&|js|jj	�||j k(r�d}|j"j%�r@|j&}|j)�}|r"|j+�j-|d�rd}|j
jt/|j0j%�xs|j6j9�xs|��|jd
k(r|jj	�||jNk(rO|jPjS�jU�\}}|j
jt/|��||jVk(rk|j
j	�|jj�|jjt/tY|jZ���||jk(r5|jd
k(r&|jLr|jj	�||j\k(r,|j;�}|j
j|�yy#t$rd}Y��5wxYw#t?�Y��&xYw)Nr Fr!zNo installable optionsraTrr�r?r�r�)/r�rrhr�rSr�r�r|r�r�AttributeErrorrYr�r$rdr�r�r�r�r��get_active_iterr r�r�r�r��
get_cursorr��get_filename�_is_driver_license_acceptedr�rGr�r@r>r��get_textr"r#r�r�rr�r�r8r�r�)	rj�nrr�valid�downloadable_selectedrrr.�acceptedr6s	         rr�zNewPrinterGUI.setNPButtonss-��
�
 �
 �
1�
1�
3�����x�'��N�N���!����"�"�$��O�O� � �"�
��'�'�*��&��,��
�O�O�)�)�5�1�����u�$��T�_�_�$��/�/�� 8�9��%�%�*�*�-��O�O�(�(�+���%�%�*�*�-��O�O�(�(�+���t�4�4�4��!�!�&�&�(����$�$�&���!�!�&�&�(����$�$�&��T�4�4�4����#�#�%��!�!�&�&�(�(-�%��6�6�A�A�D�#�H�H�H�#�3�3�6�D��� 2� 2� 5� ?� ?��q� I�04�-��!�!�/�/���,�,�7�7�9�D����2�2�4�Q�7�t�C�.��+�+�8�8�:�.�.�	1/�0�
����#�#�%����0�0��N�N���!����"�"�$��O�O� � �"��7�7�9�H��O�O�)�)�(�3����(�(�(��E�
%��'�'�*��&��,��
���+�+�E�2��N�N���"��N�N���!������ �������
��+�+�+��N�N���!����9�,��$�$�(:�:��!�!�&�&�(����$�$�&����-�-���
�
�t�~�~�/F�/F�/H�I�K����7�*����#�#�&����#5�5��)�)��/�/�"&�":�":����#�#�&�
��0�0�0�$)�!��2�2�=�=�@��D�D���/�/�2���H�.�.�1�;�;�T�1�E�,0�)����+�+�D��#�#�.�.�0�&��#�#�0�0�2�&�%�-'�
(����#5�5����#�#�%�
��0�0�0��*�*�8�8�:�G�G�I�K�E�4����+�+�D��J�7�
��/�/�/����"�"�$��O�O� � �"��O�O�)�)��+�D�,<�,<�=�>�
@�
��.�.�.����#5�5��)�)����#�#�&�
��*�*�*��7�7�9�H����+�+�H�5�+��k"�
���
��x
%�!�$�s�9^;�_
�;_
�	_
�
_c�:�|jj�}||jk(r|jj	�S|j
}|j
�j�\}}|s&|j�\}}|r|j|�}|duSrB)
r�rr�r�r�r�rr�rr")rj�current_pager5r6r.r-rqs       rrz)NewPrinterGUI._is_driver_license_accepted�s����>�>�O�O�Q���4�2�2�2��0�0�;�;�>�>��/�/���,�,�/�<�<�?���t��#�.�.�0�L�D�&���~�~�t�,���4��rc��|j�}|}|jdd�}|jdd�}|jdd�}||k7r|j|�|jdk(r0|jjt
|j|��y|jjt
|j|��y)Nr�rr�rbr?)	rrrr�rhr�rYr@r>r�)rjrTr��new_texts    r�on_entNPName_changedz"NewPrinterGUI.on_entNPName_changed�s������ �����#�#�C��,���#�#�C��,���#�#�C��,����>��O�O�H�%����y�(��O�O�)�)��D�M�M�8�4�
6�
���+�+��D�M�M�8�4�
6rc����td��j�gd�}�j}|dk(r*��fd�}tj�j
|||��y��fd�}tj�j
|||��y)N�fetchDevices)r�r��
driverless�bjnpr�Fc�*���j||��SrB)�local_devices_reply�rZr�current_urirjs  ��rrz,NewPrinterGUI.fetchDevices.<locals>.<lambda>�s���!%�!9�!9�1�a�;F�"H�r)�exclude_schemesr�r�c�*���j||��SrB)�network_devices_replyr-s  ��rrz,NewPrinterGUI.fetchDevices.<locals>.<lambda>�s���!%�!;�!;�Q��=H�"J�rr�)rdr~�error_getting_devicesr�r�r�)rjr�r.�network_schemesr�r�s` `   rr(zNewPrinterGUI.fetchDevices�s�����N�#���� �O���2�2�
��e��H�M�
�"�"�D�$:�$:�4C�2?�2?�
A�
J�M�
�"�"�D�$:�$:�4C�2?�2?�
Arc���tdt|�z�|j�|jj	�|jj�d|_y)NzError fetching devices: %s)rdr�r�r�r�r})rjrrs   rr2z#NewPrinterGUI.error_getting_devices�sL���0�4��:�=�>���� ����-�-�0����&�&�)�!%��rc�n�|j�|jd|��|j||�y)NT�r�r.)r�r(�add_devices)rjrr7r.s    rr,z!NewPrinterGUI.local_devices_reply�s5����� �	
���4�[��A�	
���&�+�.rc�����jj��jj�d�_d}i}|j�D]\}}|j	d�s�|||<d}� |j�D]}||=��j
|�|��t|�dkDr;tj|�}�j�|j��fd����j��j�y)NTzdnssd://F��no_morerc�(���j�|�SrB)�dnssd_resolve_reply)�devicesr.rjs ��rrz5NewPrinterGUI.network_devices_reply.<locals>.<lambda>�s���"&�":�":�K�<C�#E�r�r�)r�r�r}r�rcrr7rY�dnssdresolve�DNSSDHostNamesResolverr~�resolver��check_firewall)	rjrr7r.r:�need_resolvingrr �resolvers	`  `     rr1z#NewPrinterGUI.network_devices_reply�s������-�-�0����&�&�)�!%�������!�<�<�?�	 �K�C���~�~�z�*�&,��s�#���	 �
"�&�&�)�	�C��s��	�	
���&�+�w��?����!�#�#�:�:�N�K�H��!�!�$����-E��
F�	
��� ����rc�l�|j||d��|j�|j�y)NTr9)r7r�rB)rjr.r=s   rr<z!NewPrinterGUI.dnssd_resolve_reply�s/�����'�;���=���� ����rc�v�tjj�}d|d<d|d<dddd|zg}t|d	zt	|�z�	tj||d
t
jt
jt
j��}|j�\}}d}|j�jd
�D]U}|jd�dk(r�tjd|�}	|	r|	j�}
	t!|
d�}|dk\s�Un|dkry|dk(ryy#YyxYw#d}Y�#xYw)NrGrHr�DISPLAYzhp-infoz-xz-i�-dr`T)rIrJrKrLrVr�
zfax-typez(\d+)rr�zMFG:HP;MDL:Fax 2;DES:HP Fax 2;zMFG:HP;MDL:Fax;DES:HP Fax;)rIrOrPrdr�rQrRrSrT�communicaterjr�r�rlror�r�)rj�faxurirar�rUrLrV�faxtyperbr�r�s           r�get_hpfax_device_idz!NewPrinterGUI.get_hpfax_device_ids8���j�j�o�o�'�� #��H��!#��I���4��t�f�}�5���F�T�M�D��J�.�/�	�� � �$�K�4�(2�(:�(:�)3���)3���:�A� !�}�}�/��V�V�
���M�M�$�*�*�D�1�	�D��y�y�*�%��+���)�)�X�t�,�C���z�z�|��!�!�$�q�'�l�G��!�|��	��a�<��
��\�3�/��-	���!� �G�s�
AD+�D2�+D/�2D8c��dddd|g}t|dzt|�z�	tj|dtjtj
tj
��}|j
�\}}|jdk7ry	|j�j�}|jd	d
�}t|�dkry|d
}|dk(ry|S#YyxYw)
Nzhp-queryz-kz	scan-typerHr`T�rJrKrLrVr�=rar��0)rdr�rQrRrSrTrJr`rjrqr�rY)	rjrr�rUrLrV�	scan_type�fieldsr�s	         r�get_hplip_scan_type_for_uriz)NewPrinterGUI.get_hplip_scan_type_for_uri&s����D�+�t�S�9���C�$�J��d��+�,�
	�� � �$�$�(2�(:�(:�)3���)3���:�A� !�}�}�/��V�V��|�|�q� ��!��M�M�$�*�*�-�	����#�q�)����<�!����q�	���C�<�����	��s�A&C�Cc��|dk(rd}n
|dk(rd}nd}d||g}t|dzt|�z�d}	tj|dtjtj
tj
��}|j
�\}}|jd	k7ry	|j�j�}|S#YyxYw)
N�printz-c�faxz-fz
hp-makeurir`TrOr)
rdr�rQrRrSrTrJr`rjrq)	rjr��mode�modr�rrUrLrVs	         r�!get_hplip_uri_for_network_printerz/NewPrinterGUI.get_hplip_uri_for_network_printer@s����7�?�$�C�
�U�]�$�C��c��c�4�(���D�4�K�$�t�*�,�-���
	�� � �$�$�(2�(:�(:�)3���)3���:�A� !�}�}�/��V�V��|�|�q� ��!��m�m��$�$�'���
��	��s�A&B=�=Cc	��d}|�|j}|��|jjd�}|dk7r�|dz
}|j|djd�}|dk(r|j|djd�}|dk(r|j|djd�}|dk(rt|j�}|j|||z}|�r�d|g}t	|d	zt|�z�d}	t
j|d
tjtjtj��}|j�\}}	|jdk7rd}|��/	|jd
�j�}
tj |
�}t|�}|dkr|j#gd��|dd}d}n|dkDr|dd}d}|dk(r
|\}
}}}}}n|dk(r	|\}
}}}}n|dk(r|\}
}}}|dk(rBt	d�t$j&j)�\}}d|�d|�d|�d|�d�	|_nt	dz�||_t%j,|j*�|_|_|_|dk(r|_||fS#Y��;xYw#t$r%|jdd��j�}
Y��HwxYw)z�
        Try to determine the make and model for the currently selected
        network printer, and store this in the data structure for the
        printer.
        Returns (hostname or None, uri or None).
        N�://rr�r�r��?z/usr/lib/cups/backend/snmpr`TrOrr_z
iso-8859-1�ignore)�encoding�errorsr�)rrrrr�r�zNo Device ID from snmp backendr�r�z;DES:rbr�zGot Device ID: %s)r rr�rYrdr�rQrRrSrTrJr`rjrq�UnicodeDecodeError�
probe_printer�wordsepr�r�r�r�r�r�r�rr�r�)rjr�r rrnrvr�rLrUrVrb�words�n�device_classrr�r��device_location�mk�mds                    rr�z(NewPrinterGUI.getNetworkPrinterMakeModelVs������>��[�[�F��<��
�
����'�A��B�w��Q����J�J�q�r�N�'�'��-����7��
�
�1�2�� 3� 3�S� 9�A���7��
�
�1�2�� 3� 3�S� 9�A���7��V�Z�Z� 0�A��z�z�!�A�a�C�(���0�$�7�D���t��d�4�j�0�1��F�

��$�$�d�d�,6�,>�,>�-7�_�_�-7�_�_�>��$%�=�=�#3� ����<�<�1�$�!�F�
�!�[�!�=�=�'�2�8�8�;�D�
&�-�-�t�4����K���q�5��L�L�-�0�!�"�1�I�E��A���U�!�"�1�I�E��A���6�9>�7�\�3���9�o��!�V�(-�&�\�3���9��!�V�@E�=�\�3�����6�� @�A�*�/�/�)�)�>�:��R��>@�"�>@�"�!F�F�I�� 3�i� ?�@� )�F�I�!,�!:�!:�F�I�I�!F���(6��%�"�����6�&5�F�O��c�{���a
���
*�[�"�=�=�<��=�Q�W�W�Z�D�[�s�,A(J
�J�
J�*K�?Kc��d|_tjttj
t�}tjdidtd�i��}t|�}|g|_|jd|j�|dg��}|jdtd�ddg��}dtd	�d
�}tjdi|��}|j||dt|�dg��}	|j||	gd���dtd�d
�}
tjdi|
��}|j||
dt|�dg��}|j|	|gd���||_|	|_||_d|_|j&j)|�|j*j-d�|j.j1�|j&j3d
�}
|j&j5tj6�|
d�||_d|_t=d�|j?�y)Nrr�device-infoz	Enter URIF�r+zNetwork Printerr�zFind Network Printer)�device-classrk)rNT�Windows Printer via SAMBArzFetching devices)r�r�)r�) rgrrVr5rrWr�r�r�r3rr=r$�get_info�insert_after�devices_uri_iter�devices_find_nw_iter�devices_network_iter�devices_network_fetchedr�r6r�r�r�rS�
get_columnrD�TreePathr.�firewallrd�start_fetching_devices)rjr.r6�other�	physother�uri_iter�network_iter�network_dictr��find_nw_iter�smbdev_dict�smbdev�
find_smb_iterrqs              rr�zNewPrinterGUI.fillDeviceTab�s1��!����
�
�s�&�4�4�#�%���"�"�I�-��;��)H�I��"�E�*�	�!�{����<�<��I�,>�,>�,A�,5�u�,>�<�?���|�|�T��2C�0D�04�05�07�|�8��*3�()�*@�(A�D���$�$�@�<�@���|�|�\�*6�}�*E�*8�'�*B�E�*K�$�L��	���L�,�<L��M�(1�'(�)D�'E�H���#�#�:�k�:�����l�*5�m�*D�*8�&�*A�5�*J�%�K�
�	���L�-�=M��N� (���$0��!�$0��!�',��$����"�"�E�*����"�"�B�'����!�!�$��!�!�,�,�a�0�����#�#�S�\�\�^�V�U�C�&�����
��&�'��#�#�&rc
���|j}d}	|j�}|j�}|xr|}tdz}|s3|dt	d�zdzz
}|jtj�|s3|dt	d�zdzz
}|jtj�|s�td|z�tj|jddtjjtjj t	d��	�}|j#|�|j%t	d
�tj&j(t	d�tj&j*�|j-d|j.�|j1�|rtd�yy#t2j4t6f$r
t9�Y�4wxYw)
NT�

�- z%Allow all incoming IPP Browse packetsrIzAllow all incoming mDNS trafficz,Asking for permission to adjust firewall:
%s�Adjust Firewallr��Do It Laterr1z"Firewall all OK, no changes needed)rx�check_ipp_client_allowed�check_mdns_allowed�TEXT_adjust_firewallr3�add_service�firewallsettings�IPP_CLIENT_SERVICE�MDNS_SERVICErdrr3r�r4�QUESTIONr6�NONE�format_secondary_markup�add_buttons�ResponseType�NO�YESrB�adjust_firewall_responser|�dbus�
DBusExceptionrkrG)rj�data�f�allowed�ipp_allowed�mdns_allowed�secondary_textrus        r�on_firewall_readzNewPrinterGUI.on_firewall_read�s����M�M����	!��4�4�7�K��/�/�2�L�"�3�|�G�1�F�:�N���4�#$�%L�#M�$N�#'�$(�)���
�
�/�B�B�C���4�#$�%F�#G�$H�JN�$O�P���
�
�/�<�<�=���K�*�+�,��*�*�4�3H�3H�26�D�9<���9Q�9Q�47�O�O�4H�4H�23�4E�2F�	H��
�.�.��?��"�"�A�m�$4�c�6F�6F�6I�6I�$%�&7�$8�#�:J�:J�:N�:N�P����
�D�,I�,I�J�������<�=����"�"�I�.�	!�� �	!�s�FF9�9#G�Gc���|j�|tjjk(r_|jj�}|s)|jj
tj�|jj�td�tj�|_
|jjtd��|j!d��y)Nz7Fetching network devices after firewall dialog responser�Tro)r}rr�r�rx�check_ipp_server_allowedr�r��IPP_SERVER_SERVICEr�rdr�r�r�r�r3r()rjrur1�ipp_server_alloweds    rr�z&NewPrinterGUI.adjust_firewall_response�s��������s�'�'�+�+�+�!%���!G�!G�!J��%��
�
�)�)�+;�+N�+N�O��M�M���"��M�N�!*�!5�!5�!8������/�/��3I�1J�K����4��(rc��tj�|_|jjt	d��|jd|j��|`y)Nr�Fr6)r�r�r�r�r3r(r.rws rryz$NewPrinterGUI.start_fetching_devices	sL��!*�!5�!5�!8������/�/��3I�1J�K����5�d�6F�6F��G��rc
�p�|ro||vr|j|�}nY|jdd�|vr$|jdd�}|j|�}n!|rtj|�}d|_nd}t|j
��}|D]3}|jdk(s�|jjdd�|_�5d�}tt||��}tt|�dz
�D]�}t|dzt|��D]�}||}	||}
|	jdk(s|
jdk(r�,|	j|
jk(s�F|	jsd|	_�Z|
jsd|
_�nt|	j�t|
j�krd|	_��d|
_����|D�cgc]}|jdvs�|��}}g}|D�]}td	|jz�t|d
�rtd|jz�t|d�rtd
|j z�t#|�}
tdt%|
�z�	|j&j)|
�}td|z�|j&|j+|�tdt%|
�|t%|j&|�fz�td���|j&j1�|rUt#�}	|j&j)|�}|j&|j+|�|j&|}nd}|j2j5�}|j6}|j8}|D�]�}d}	|j&j)|�}|j&|}|j;�}|dj<dk(}|j?�}||k(r|tAd�z
}||dg}|rz|dj|djk7rG|jC|||��}||k(r�|jE|�}|j2jG|d�n�|j/||��}n�|jE|�}|jI�}|jE|�|k7r>|jK|d�}||kDrn&|jM|�}|jE|�|k7r�>|jCd||��}||k(s���|jE|�}|j2jO|d��|j2jQd�}|j2jS||d����d}|rm|jTj5�}|jI�}d}|r>|jK|d�}||jk(r|}y|jM|�}|dz
}|r�=yy|jVs�|j2jQd�}|j2jStYjZ�|d�|jTjQd�}|jTjS||d�yycc}w#t,$rG|j&j/|
�|j/|
�tdt%|
�z�Y���wxYw#t,$r0|j&j/|�|j/|�Y���wxYw#t,$rtdt%|�z�Y���wxYw)Nz:9100rzCurrent devicer�c�b�|jdk(r	d|_|S|jdk(rd|_|S)Nzhp:/no_device_foundr�zhpfax:/no_device_foundr�r��r s r�replace_genericz2NewPrinterGUI.add_devices.<locals>.replace_generic!	s8���z�z�2�2�!��
��M����7�7�$��
��Mrra�delete)	r�r�r�r�r�r�rwr*r�zAdding device with URI %s�addressz   Device address %s�hostnamez   Device host name %sz   Created physical device %sz)   Physical device %d is the same printerz;   New physical device %s is same as physical device %d: %sz   Joining devicesz0   Physical device %s is a completely new devicezQERROR: Cannot identify new physical device with its entry in the device list (%s)rr��
 (Current)Frl��?)�	row_align).�poprrr�r�r�rYr;rr�map�rangerYr�rdr�r�r�rr�r=r�
add_devicermr$r4r�r rtrs�get_devicesrfrpr3�
insert_beforer!�
expand_rowr2r�r3�scroll_to_cellrvrDr�rgrrw)rjr=r.r:�currentr r��i�j�device1�device2rZ�
newdevices�physicaldevice�current_devicer6r}r�	newdevice�devsr�r�r+r.�network_path�physdev�device_select_pathrq�connection_select_path�devs                              rr7zNewPrinterGUI.add_devices	s�����g�%�!�+�+�k�2���$�$�g�r�2�g�=�)�1�1�7�B�?��!�+�+�k�2���%�,�,�k�:��/���"���w�~�~�'�(���	>�F��{�{�h�&�#�Z�Z�/�/��"�=��
�	>�	��s�O�W�5�6����W�
��)�*�	/�A��A��E�3��=�1�
/��!�!�*��!�!�*���;�;�(�*�g�k�k�X�.E���;�;�'�+�+�-�#�J�J�&.���%�j�j�&.����w�z�z�*�S�'�*�*�-=�=�&.���&.���
/�	/� &�B�����7A�*A�1�B��B��
��	g�F��2�V�Z�Z�?�@����+��1�F�N�N�B�C����,��3�f�o�o�E�F�+�V�4�N��7�$�~�:N�N�O�

g��L�L�&�&��7���G�!�K�L����Q��*�*�F�3��Y�!�.�1�1�d�4�<�<��?�6K�L�M�N��0�1�	g�(	
�������+�W�5�N�
3��L�L�&�&��7�����Q��*�*�G�4�!%���a���
"�N�� � �*�*�-���0�0���0�0��#�0	P�I��F�
��L�L�&�&�	�2�����a���
�%�%�(�D��1�g�*�*�i�7�G��?�?�%�D���'���,��'���v�u�%�C����7�;�;�$�q�'�,�,�.� �.�.��l�47�/�9�D���/�',�~�~�|�'D���(�(�3�3�\�5�I�!�<�<��3�<�?�D� %�~�~�|�<���+�+�.���n�n�d�+�|�;�#�o�o�t�Q�7�G���'�� �?�?�D�1�D��n�n�d�+�|�;��*�*�D�$�C�*�@����'�%*�^�^�T�%:�"�� � �/�/�1C�;>�0�@��)�)�4�4�a�8��� � �+�+�-?���O�a0	P�d"#����'�'�1�1�4�E��'�'�*�D��A���o�o�t�Q�/���#�'�'�)�-.�*������-���Q�����%�%��%�%�0�0�!�4�F����'�'�������G��(�(�3�3�Q�7�F����*�*�,B�F�E�R�&��SB��(�
g����#�#�^�4��!�!�>�2��N�QU�Vd�Qe�e�f�
g���
3����#�#�^�4��!�!�>�2�
3���
��n��	�?�+�,��
�sE�=Y=�Y=�"BZ�A[�*\�A[�[�5\�
\� \5�4\5c��trytd�	tj�}|j	ddd�	ddladatd	�y#t
$r/}td�tdj
|��Yd}~yd}~wwxYw#t$r/}td�tdj
|��Yd}~yd}~wwxYw)
NTz3No SMB client library present so attempting installrzpython3-smbcz.Error during installation/setup of SMB client.z{}FzSMB client setup failed.z-SMB client successfully installed and set up.)	rZrdr�r�r�r��format�pysmb�ModuleNotFoundError)rjr�rvs   r�install_python3_smbc_if_neededz,NewPrinterGUI.install_python3_smbc_if_needed�	s������I�J�	��*�*�-�B��!�!�1�a��8�	�� �O�	�C�D����	��H�I��t�{�{�1�~�&���	��#�	��2�3��t�{�{�1�~�&���	�s.�'A�B	�	B�%B�B�		C�%B<�<Cc�d�|j}|j�t|j�Gd�d�}|�}tj
j|_td�|_	d|_
|jd|g�tj�r)tj�tj�r�)d}t�rd}t	j |j�}tj
j#||j$��}d}	|j'�dkDr4	|j)d	�j+�}|j'�dkDr�4|j�|rl|D]g}
|
jtj
j>tj
j@fvs�D|jd|
g�}|j|�}�itC|jDjG���}
|
jI�\}}}}}tK|�dkDr�Gd�d
�}|�}tj
j@|_||_	d|_
|jd|g�}|j|�}|jM|�}|jNjQ|d�tS|j�|jU��E|jjW�tYtd�td�|jZ��yy#t,$r}|j/|�Yd}~���d}~wwxYw#t0$rF}|j2\}}	|t4j6k7rt9d
t;||	f�z�Yd}~��2d}~wt=�Y��DxYw)zInitialise the SMB tree store.c��eZdZy)�)NewPrinterGUI.browse_smb_hosts.<locals>.XN��__name__�
__module__�__qualname__r|rr�Xr��	s��rr�zScanning...rNr�
��debug�auth_fn�smb://�Runtime error: %sr�c��eZdZy)�1NewPrinterGUI.browse_smb_hosts.<locals>.FakeEntryNr�r|rr�	FakeEntryr��	s��rr�zNo Print Sharesz{There were no print shares found.  Please check that the Samba service is marked as trusted in your firewall configuration.r�).rXr8rPr�r��smbc�
PRINTER_SHARE�	smbc_typer3r=�commentr$rrErF�
get_debugging�AuthContext�Context�callback�perform_authentication�opendir�getdentsrk�failedr�r��errno�ENOENTrdr�rG�	WORKGROUP�SERVERrr�r�separaterYr!r�r�rKr2rS�show_info_dialogr�)rjrlr��dummyr��	smbc_auth�ctx�entriesrvrn�entryr.r��
specified_urirpr��share�user�passwordr��toplevelr-s                      r�browse_smb_hostszNewPrinterGUI.browse_smb_hosts�	s������
�����T�
!�
!�"�	�	�����*�*�2�2����}�%��
���
�
���T�E�7�#�� � �#����!�� � �#������E��%�%�t�';�';�<�	��j�j� � ��*3�*<�*<�!�>����	!��2�2�5��9�)�!�k�k�8�4�=�=�@�G��2�2�5��9�	����� �
,���?�?�u�z�z�';�';�',�z�z�'8�'8�':�:� �<�<���w�7�D����d�+�A�	
,��D�N�N�$;�$;�$>�?�
�/<�/E�/E�/H�,���e�T�8���:��>�
�
� �|�H�!&���!2�!2�H�� �H�M�!�H���<�<���z�2�D����d�#�A��>�>�4�(�D����(�(�$��2�
�d�"�"�#����"�*�� � �%�%�(��a� 1�2��!1�2�&*�%:�%:�
<�+��K!�)��$�$�a�(�(��)���	A��V�V�F�Q���E�L�L� ��/�$��A��-�?�@���	!�� �sB�$M�8L+�M�+	M�4M�M�M�M�	N/�;N�N/c�p�|jj|�}|jj|�S)z9Don't allow this path to be selected unless it is a leaf.)rXr"�iter_has_child)rjr(r6r-�
path_selectedr�r.s       rr_z!NewPrinterGUI.smb_select_function
s.���~�~�&�&��-���>�>�0�0�$�7�7�7rc�l�|j|d�}d}|�|j}|jd|�y�Nrrr�)r�r=�set_property)rjrqrmr6r.r�r�r�s        rr]z#NewPrinterGUI.smbbrowser_cell_share
s6������q�)�������J�J�E����6�5�)rc�l�|j|d�}d}|�|j}|jd|�yr�)r�r�r�)rjrqrmr6r.r�r�r�s        rr^z%NewPrinterGUI.smbbrowser_cell_comment!
s6������q�)�������m�m�G����6�7�+rc�V�|j}|j|�}|j|d�}|rB|jtj
jk(r|jj�y|j|�r|j|�y|j|||�y)z*Handle double-clicks in the SMB tree view.rN)rXr"r�r�r�r�r�r�r�row_expanded�collapse_row�on_tvSMBBrowser_row_expanded)rj�viewr-rqrlr.r�s       r�on_tvSMBBrowser_row_activatedz+NewPrinterGUI.on_tvSMBBrowser_row_activated(
s��������~�~�t�$������q�)���U�_�_��
�
�(@�(@�@����'�'�*�����d�#����t�$��-�-�t�T�4�@rc�R
�|j�}|j|d�}|�y|jtjj
k(�r�	|jry	t|j�d|jz}d}t�rd}tj|j�}tjj||j��}	g}
	|j�dkDr4	|	j|�j!�}
|j�dkDr�4|j5|�r5|j7|d�}
|j9|
�|j5|�r�5|
D]�}|jtjj:tjj<fvr|j?||g�}
|jtjj:k(s�~|j?
�}��|jA|d�|`tC|j�y|jtjj:k(�r�	|jry	t|j�d|jz}d}t�rd}tj|j�}tjj||j��}	g}	|j�dkDr4	|	j|�j!�}|j�dkDr�4|j5|�r5|j7|d�}
|j9|
�|j5|�r�5|D]Q}|jtjj<k(s�+|j?||g�}
t/t1|���S|jA|d�|`tC|j�yy#d|_Y���xYw#t"$r}|j%|�Yd}~��
d}~wwxYw#t&$rF}|j(\}}|t*j,k7rt/dt1||f�z�Yd}~��Hd}~wt3�Y��ZxYw#d|_Y��/xYw#t"$r}|j%|�Yd}~���d}~wwxYw#t&$rY}|j(\}}|t*jDk7r,|t*jFk7rt/dt1||f�z�Yd}~���d}~wt3�Y��xYw)z1Handler for expanding a row in the SMB tree view.rNraz	smb://%s/r�r�r�)$r r�r�r�r�r��
expanding_rowrPr�r=r�r�r�r�r�r�r�rkr�r�r�r�r�rdr�rGr��iter_nth_childr%r�r�r$r�rK�EACCES�EPERM)rjrr.r-r6r�rr�r�r�r�rvrnr�re�sharesr�s                 rrz*NewPrinterGUI.on_tvSMBBrowser_row_expanded7
s_�����!������q�)���=���?�?�e�j�j�2�2�2�

'��%�%��&�

�$�&�&�'���
�
�*�C��E������)�)�4�+?�+?�@�I��*�*�$�$�E�.7�.@�.@�%�B�C��G�
$��6�6�9�A�=�-�"%�+�+�s�"3�"<�"<�"?�� �6�6�9�A�=��&�&��-��(�(�$��2�����a� ��&�&��-�!�
)���?�?�u�z�z�'8�'8�',�z�z�'?�'?�'A�A����d�U�G�4�A��?�?�e�j�j�&7�&7�7����a�(�A�
)�
�O�O�T�1�%��"��4�'�'�(�
�_�_��
�
� 1� 1�
1�
'��%�%��&�

�$�&�&�'���
�
�*�C��E������)�)�4�+?�+?�@�I��*�*�$�$�E�.7�.@�.@�%�B�C��F�
$��6�6�9�A�=�-�!$���c�!2�!;�!;�!>�� �6�6�9�A�=��&�&��-��(�(�$��2�����a� ��&�&��-� �
.���?�?�e�j�j�&>�&>�>����d�U�G�4�A���e��-�
.�

�O�O�T�1�%��"��4�'�'�(�S2��Q
'�%&��"��%�-�!�(�(�!�,�,��-���
E������A�����$�� 3�d�Q��F�m� C�D���
$�!�#��,
'�%&��"��%�-�!�(�(�!�,�,��-���
E������A�����$��e�k�k�)9�� 3�d�Q��F�m� C�D���
$�!�#�s��O*�P!�0O9�P!�R�R7�0R�R7�*	O6�9	P�P�P!�P�P!�!	Q=�*;Q+�+Q=�	R�	R4�R/�)R7�/R4�4R7�7	T&�AT�T&c��|jj|�tr|s(|jjt	d�dz�yy)Nz#Verification requires the %s module�pysmbc)r�rYrZr[r3)rj�ons  r�set_btnSMBVerify_sensitivityz*NewPrinterGUI.set_btnSMBVerify_sensitivity�
sJ�����'�'��,��b����.�.��3>�1?�AI�1J�
K�')rc��tjtjzdz}|j||�|j	�}t|��j
�\}}}}}|r|jj|�|r|jj|�|s|rIt|||��j�}|j|�|jjd�n8|jj	�dk(r|jjd�|jt|��|j!�y)Nz	_-./:%[]@r��rpr�r�Tr)�string�
ascii_letters�digits�
entry_changedrrr�r�r�r��get_urir�rr�rr�r�)	rj�ent�
allowed_charsrrpr�r�r�r�s	         r�on_entSMBURI_changedz"NewPrinterGUI.on_entSMBURI_changed�
s���,�,�V�]�]�:�;�F�
����3�
�.��l�l�o��/5�3�/?�/H�/H�/K�,���e�T�8�����(�(�$�/�����(�(�(�3��8���D��>�F�F�I�C��L�L������*�*�4�0�
�
 �
 �
)�
)�
,��
2��"�"�-�-�d�3��)�)�4��9�5����rc�$�|jj�}|�y|j�\}}d}|r;|j|d�}|r'|jt
jjk(}|jj|duxr|�y)NFr)
r�rr�r�r�r�r�r�r�rY)rjrTr(rlr.�is_sharer�s       r�on_tvSMBBrowser_cursor_changedz,NewPrinterGUI.on_tvSMBBrowser_cursor_changed�
s����%�%�3�3�5�	�����,�,�.���t�����O�O�T�1�-�E�� �?�?�e�j�j�.F�.F�F�����)�)�$�d�*:�*G�x�Hrc
�*�	|j�sy|jjd�	tj�}|j
stj�}|j�}tdz}|�sBtj|jddtjjtjjt!d���}|dt!d�zz
}|j#|�|j%t!d	�tj&j(t!d�tj&j*�|j-�}|j/�|tj&j*k(r/|j1tj2�|j5�|j>jA�|jC�y#t6j8t:f$r
t=�Y�PwxYw)
�<Check whether the needed SMB client library is available andNFr�Tr�r�r�z*Allow all incoming SMB/CIFS browse packetsr�)"r�r�rYr��	FirewallD�running�SystemConfigFirewall�check_samba_client_allowedr�rr3r�r4r�r6r�r3r�r�r�r�r�r�r}r��SAMBA_CLIENT_SERVICEr�r�r�rkrGr�r|r�)rjrr�r�r�rur1s       r�on_btnSMBBrowse_clickedz%NewPrinterGUI.on_btnSMBBrowse_clicked�
s���"��2�2�4�����)�)�%�0�	!�!�*�*�-�A��9�9�$�9�9�<���2�2�5�G�1�F�:�N���*�*�4�3H�3H�26�D�9<���9Q�9Q�47�O�O�4H�4H�12�3D�1E�	G��
�4�#$�&6�$7�$7�8���.�.��?��"�"�A�m�$4�c�6F�6F�6I�6I�$%�&7�$8�#�:J�:J�:N�:N�P�!�:�:�=�����!��s�/�/�3�3�3��M�M�#3�#H�#H�I��G�G�J�	
���!�!�#������	�"�"�I�.�	!�� �	!�s�FG,�,#H�Hc��|jj�j�\}}d}|r;|j|d�}|r'|jt
jjk(}|r|s|jj�y|j|�}|j|�}|j|d�}|j|d�}	|r|j|d�j}
nd}
t|
|	j|j��j�}|jjd�|j jd�|j"j|�|jj�y)NFrrr)r�rr�r�r�r�r�r�r�rS�iter_parentr=rrr�r�r�r�)rjrrlr.rr��parent_iter�domain_iterr�r�rprs            r�on_btnSMBBrowseOk_clickedz'NewPrinterGUI.on_btnSMBBrowseOk_clicked�
s@���'�'�5�5�7�D�D�F���t�����O�O�T�1�-�E�� �?�?�e�j�j�.F�.F�F���8�� � �%�%�'���'�'��.���'�'��5������q�)������Q�/����O�O�[�!�4�9�9�E��E��E��9�9�!�J�J�(�(/��
�	�	
���$�$�b�)����$�$�b�)�������%����!�!�#rc�8�|jj�yrB)r�rS)rjrTr�s   r�on_btnSMBBrowseCancel_clickedz+NewPrinterGUI.on_btnSMBBrowseCancel_clickeds�����!�!�#rc�$�|j�yrB)r�rs  r�on_btnSMBBrowseRefresh_clickedz,NewPrinterGUI.on_btnSMBBrowseRefresh_clicked	s�����rc�V�|jj|j��yrB)r�rYr�r's  r�on_rbtnSMBAuthSet_toggledz'NewPrinterGUI.on_rbtnSMBAuthSet_toggleds�����%�%�f�&7�&7�&9�:rc�����	|j�sy|jj�}t|��j	�\�}}}}d�d�d}|j
j
�}|r4|jj��|jj��d}	d}
t|j�	d}t�rd}|rZ���fd�}tjj||��}
	d	|
_|
j#d
|�d|��t$j&d�}d	}	n�tj(|j����
�}tjj||j*��}
|j-�dkDr>	|
j#d
|�d|��t$j&d�}d	}	|j-�dkDr�>|	sd	}
t=|j�|	r+t?tAd�tAd�|j��y|
s1tAd�}|r|}tCtAd�||j��yy#t $rY��OwxYw#t.$r}|j1|�Yd}~��d}~wwxYw#t2$r4}|j4\}}t7dt9||f�z�|}Yd}~��d}~wt;�Y��xYw)rNr�rFrr�c������fSrBr|)�svr�shr�wg�un�pwrp�passwdr�s     ���r�do_authz6NewPrinterGUI.on_btnSMBVerify_clicked.<locals>.do_auth)s���!�4��0�0rr�Tr�r�i�)�	workgroupr�r7zError accessing share: %szPrint Share VerifiedzThis print share is accessible.r�z#This print share is not accessible.zPrint Share Inaccessible)"r�r�rrr�r�r�r�r�rPr�r�r�r�r��optionUseKerberosr�openrI�O_RDWRr�r�r�rkr�r�r�rdr�rGrKr�r3�show_error_dialog)rjrrr�r��urU�reason�auth_set�
accessible�canceledr�r8r�r�r�rvrnr�rpr7r�s                   @@@r�on_btnSMBVerify_clickedz%NewPrinterGUI.on_btnSMBVerify_clickeds����"��2�2�4���n�n�%�%�(��%+��%5�%>�%>�%A�"���e�Q���������&�&�1�1�3����&�&�/�/�2�D��(�(�1�1�4�F��
����d�#�#�$�*	 ��E������1��j�j�(�(��w�(�G���,0�C�)�
�H�H�t�U�;� �i�i��0��!�
�"�-�-�t�/D�/D�9>�48�6<�>�	��j�j�(�(��2;�2D�2D�)�F���6�6�9�A�=�-��H�H�t�U�&C�&(�i�i��8��%)�
�	 �6�6�9�A�=�"�#�H�	�t�$�$�%���a� 6�7�� A�B�%)�%:�%:�
<�
���:�;�D�����q�!;�<�d�&*�&;�&;�
=�	��O&�����(%�-�!�(�(�!�,�,��-��
�	��V�V�F�Q���3�d�Q��F�m�C�D��F��	 ���sm�8I:�9I�BI:�)I�5I:�	I:�	I�I:�I�I:�	I7�I2�-I:�2I7�7I:�:	K�*J2�2Kc��|j�}|}|D]0}||vs�|j|d�}tdt|�z��2||k7r|j	|�yy)zARemove all chars from entry's text that are not in allowed_chars.rzremoved disallowed character %sN)rrrrdr�r�)rjr�r�origtextr%�chars      rrzNewPrinterGUI.entry_changed\sk���>�>�#�����	M�D��=�(�#�+�+�D�"�5���=��d��K�L�	M��X���N�N�8�$�rc��tjtjzdz}|j||�|j	�y)Nz_-./:%[]()@?=&+�rrrrr��rjrrs   r�on_entNPTDevice_changedz%NewPrinterGUI.on_entNPTDevice_changedgs8���,�,�V�]�]�:�;L�L�
����3�
�.����rc��tjtjzdz}|j||�|j	�y)N�_-.:%[]rHrIs   r�"on_entNPTJetDirectHostname_changedz0NewPrinterGUI.on_entNPTJetDirectHostname_changedls7���,�,�V�]�]�:�9�D�
����3�
�.����rc�d�|j|tj�|j�yrB)rrrr��rjrs  r�on_entNPTJetDirectPort_changedz,NewPrinterGUI.on_entNPTJetDirectPort_changedqs"�����3��
�
�.����rc��|j�}|j|�\}}}}|j�}|j|||||�yrB)�
get_parent�query_child_packing�get_expanded�set_child_packing)rjrT�UNUSEDr��expand�fill�padding�	pack_types        rrTz)NewPrinterGUI.on_expNPDeviceURIs_expandedusU���"�"�%��%�9�9�6�B�	���	�)��$�$�'��� � �&�&�$�")�9�	6rc�&�|j|d�S)Nr�)r�)rjr6r.r�s    rrQz%NewPrinterGUI.device_row_separator_fn�s������a�(�(rc�n�|j|�r|j|�y|j|d�yr)rrr�)rjrr-rqs    rrRz"NewPrinterGUI.device_row_activated�s,�����d�#����t�$��O�O�T�5�)rc�0�|j}|j�}|sy|j|j�}|j	|�sy|j
�y|jdkDrtd�y|jD]N}|j�D]9}|jdk(s�|j|jk7s�-td�y�P	|jdk(s|jddk(rztj�|_|j
j stj"�|_td�|j
j%|j&��yy#t(j*t,f$r
t/�YywxYw)	Nrz3Skipping firewall adjustment: discovery in progressr�z4Skipping firewall adjustment: network printers foundr�r�zExamining firewallr>)r�r r!rtrrxrErdr=r�rfrrr�r�rr r!rir�r�r�rkrG)rjrr6r�r�r s      rrBzNewPrinterGUI.check_firewall�sc���������!�����~�~�t�'@�'@�A��� � �,�/���=�=�$������!��0�
1���|�|�	�G�!�-�-�0�
���'�'�9�4��J�J�&�+�+�-��!9�:��
�	�
	!��
�
�k�)��
�
�1�
��$� 0� :� :� =��
��}�}�,�,�$4�$I�$I�$L�D�M��0�1��
�
�"�"�$�2G�2G�"�H�
%���"�"�I�.�	!�� �	!�s�BE/�/#F�Fc��|j�}|r|sy|j|j�}||k(r|j�yyrB)r r!rtrB)rjrr.r-r6r�s      rrSz!NewPrinterGUI.device_row_expanded�sC�����!���D���~�~�t�'@�'@�A���<�����"� rc��|jj�}|j|�}|j|d��y|j	|j|d�y)z�
        Allow this path to be selected as long as there
        is a device associated with it.  Otherwise, expand or collapse it.
        raNTF)r�r r"r�rR)rjr(r6r-rVr.s      rrOz$NewPrinterGUI.device_select_function�sU��
� � �*�*�-���~�~�t�$���?�?�D�!�$�0���!�!�4�#3�#3�T�4�@�rc��g|_d|_d|_d|_g|_|xj
dz
c_|j
�\}}|�y|j�}|j|�}|j|d�}|�yd}|j�D�]�}|jdk(rtd�|_
�$|jdk(rtd�|_
�D|jdk(rit|d	�rL|jj!�j#d
�dkDr td�d
ztd�z|_
��td�|_
��|jdk(rtd�|_
��|jdk(rtd�|_
��|jdk(r!td�d
ztd�z|_
��,|jdk(rtd�|_
��M|jdk(rtd�|_
��n|jdk(r�t$j&j)|j�\}	}
t$j&j+|
�\}}
t$j&j-|
�\}}
|dk7r"|ddk(r|dd}td�|z|_
��td�|_
��&|jdk(rtd�|_
��G|jd k(r�t$j&j)|j�\}	}
t$j&j+|
�\}}
t$j&j-|
�\}}
|dk7r#|ddk(r|dd}|j/d!�r|d"d}d#|j0vr
d$}
d|_nd}
|dk7rd%td&�zd'z|
|fz|_
��*d%td&�z|
z|_
��B|jd(k(s|jd)k(rtd*�|_
��r|jd+k(s|jd,k(�r;t$j&j)|j�\}	}
t$j&j+|
�\}}
t$j&j-|
�\}}
|dk7r
|ddk(r|dd}|d-k(rEtd.�|_
|j0dk7s��9|xjd'|j0zz
c_
��]d}|j#d/�dk7rd&}n-|j#d0�dk7rd1}n|j#d2�dk7rd3}|�td4�|z|_
���td5�|_
���d}|j|_
���t5j6t8t:j<�}|j>jA|�tC|d6d�dk7�rFd}d}d}d}d}d7d8i}|jDr|jD}|j�D�]�}|jdk(r"d}|jG|j�rd}�nZ|jd9vs�D|��|jd:vrrt$j&j)|j�\}	}
t$j&j+|
�\}}
|�"t$j&jI|�\}}|s��d}|jj/d;�xs|jj/d<�xr|jjKd=�}|jLr|jLd>k(r|s|jO||�?�|j0|d@<|jL|dA<|jP|dB<|jR|dC<���|�sn|�rk|�shjLra|jLd>k(sR|jLj!�j/d�s)|jLj!�j/dD�r�t|dE�r|jTr
|jT}n|}|jW|dF�}|r�tYjZ|fi|��}d|_
|j]|�|jG|j�rd}|jW|d
�}|ra|j_|�}||dB<td�|d@<tYjZ|fi|��}td�d
zdz|_
|j]|�|rd|_0d|_1tC|dGd�_0d}|j�D]$}|je|j|f�|dz
}�&|j>jgd�}|j>jit5jj�|d�|r|jljo�y|jljq�y)HNFraTr�z
Parallel Portr�zSerial Portr�rrWr�Fax� - �USBr��	Bluetoothr�z%HP Linux Imaging and Printing (HPLIP)r�r�z Hardware Abstraction Layer (HAL)r�zAppSocket/HP JetDirectr�rrr�zLPD/LPR queue '%s'z
LPD/LPR queuer�rnr�z	printers/�	r)zDriverless z%s�IPPz (%s)rwrx�HTTPr��mdnsr��Remote CUPS printer via DNS-SD�._ipp�	._printer�LPD�._pdl-datastream�AppSocket/JetDirect�%s network printer via DNS-SD�Network printer via DNS-SD�
checked_hpliprmr�)r�r�r�r�rhr�r�r�r�r�)r�r rkzdevice-make-and-modelz	device-idzdevice-location�hewlett�dnssd_hostnamerVr�)9r&r'r(r)r+rgrr r"r�r�rr3�	menuentryr�rr:r�rrr�	splithost�
splitqueryrcr�r)rr4r5rrWr�r6r
�
_network_hostrT�	splitportrkrr�r�r�rsrZr�r�r�rMr�rqr$rvrDrwr�r=rS)rjrTr-rqr6r.r��	show_urisr rr�hostport�queue�drvlessr=�	cupsqueue�protocol�hp_drivabler��
is_network�
remotecupsr�r�r��	hpliphost�hplipurir�rK�faxdevid�faxdevres                               r�on_tvNPDevices_cursor_changedz+NewPrinterGUI.on_tvNPDevices_cursor_changed�s���&(��#�).��&�(-��%�$)��!�%'��"�����!���(�(�+���f��<��� � �#���~�~�t�$�����$��2���!���	�$�0�0�3�T	.�F��{�{�j�(�#$�_�#5�� �����(�#$�]�#3�� �����%��F�E�*��J�J�$�$�&�+�+�E�2�R�7�'(��x�%�'7�!�E�(�'B�F�$�'(��x�F�$�����+�#$�[�>�� �����$�#$�%L�#M�� �����'�#$�U�8�e�#3��=�>�$?�� �����%�#$�%G�#H�� �����(�#$�%=�#>�� �����%�!'���!7�!7����!D����#)�<�<�#9�#9�4�#@� ��4� &��� 7� 7�� >�
����B�;��Q�x�3�� %�a�b�	��()�*>�(?�*/�)0�F�$�()��'9�F�$�����%�#$�%@�#A�� �����%�!'���!7�!7����!D����#)�<�<�#9�#9�4�#@� ��4� &��� 7� 7�� >�
����B�;��Q�x�3�� %�a�b�	���'�'��4� %�a�b�	���6�;�;�.�+�G�(,�F�%� �G��B�;�)-��%���7�)B�)0�%�(8�)9�F�$�*.��%���G�(C�F�$�����&�&�+�+��*@�#$�V�9�� �����'�6�;�;�&�+@�!'���!7�!7����!D����%�|�|�5�5�t�<���t�$*�L�L�$;�$;�T�$B�!��D���?�y��|�s�':� )�!�"�
�I���&�'(�)I�'J�F�$��{�{�b�(��(�(�G�f�k�k�,A�A�(�#�H��y�y��)�R�/�#(�����;�/�2�5�#(�����#5�6�"�<�#8���+�,-�.M�,N�.6�-7��(��:�;��(�"�	�#)�:�:�� �iT	.�l�
�
�s�&�4�4�6�����%�%�u�-��N�O�T�:�d�B��K� �L��J��J��D�*�I�7�K��+�+�%�3�3��(�4�4�7�
I���;�;�$�&�"&�K��7�7����D�'+����[�[�$M�M��|����7O�(O�)/���)?�)?����)L����+1�<�<�+A�+A�4�+H�(��4�#�/�+1�<�<�+A�+A�8�+L�L�T�4��%)�
�'-�z�z�'<�'<�X�'F�(F�'-�z�z�'<�'<�W�'E�'C�&,�j�j�&9�&9�'�&B�#�!'� 5� 5�"�1�1�Y�>�%� �;�;��CI�<�K�5;�[�[��M�2�@F�@N��$�$;�<�39�9�9��K�0�9?����$5�6�?
I�B�:�j��)�)��%�%��2��%�%�+�+�.�9�9�4�@��%�%�+�+�.�9�9�9�E��^�-=�>�"�1�1� .� =� =�I� $�I��A�A�9�CJ�L���%�,�,�h�F�+�F�C�$K�C�M�"�-�-�s�3��7�7����D�'+��"�C�C�Y�EJ�L�F��#'�#;�#;�V�#D��3;��K�0�56�u�X��M�2�!,�!3�!3�V�!K�{�!K��+,�U�8�e�+;�C�,D��(�&�1�1�6�:��.2��+�+/�N�(�%�~�~�t�L���
��$�0�0�3�	�F��L�L�6�+�+�V�4�5�
��F�A�	��$�$�/�/��3�����&�&�������F��� � �)�)�,�� � �%�%�(rc��|j�\}}|�y|j�}|j|�}|j|d�}||_|j
j
d�|jj|j|j�}|jj|�td|jz�d}|j}	|jjdd�d}
||j k(�rI|jdk(r
t#d�}�n|jdk(rqt%|d	�rX|jj'�j)d
�dkDr,t#d�dzt#d
�z|_t#d�}�n�t#d�}�n�|jdk(r
t#d�}�nt|jdk(r
t#d�}�nX|jdk(r
t#d�}�n<|jdk(r
t#d�}�n |jdk(s|jdk(r�t,j.j1|j�\}}
t,j.j3|
�\}}
t,j.j5|
�\}}
|dk7r
|ddk(r|dd}|dk(rt#d�}nod}|j)d�dk7rd}n-|j)d �dk7rd!}n|j)d"�dk7rd#}|�t#d$�|z}nt#d%�}n|j}|j
j
|��n�|jd&k(r�t,j.j1|j�\}}
d}d'}|d&k(r~t,j.j3|
�\}}
t,j.j7||�(�\}}td)|�d*t9|����|j:dk7r
|j:}n|}|j<j
|�|j>j
tA|���n|jd+k(�r[|jB�sb|jjd,d�}tE|�dkDr|d}nd}|jd-�}i}|D]}|jd.�\}}|||<�|jFd/f|jHd0f|jJd1f|jLd2ffD]�\}}||vr�|j�}|jO�}d}|rI|j|d�d}tA|�tA||�k(rn|jQ|�}|dz
}|r�I|r|jS|���|jSd���|jSd����n|jd3k(�r|jTj
d�|jVj
d�|jVjYd�|jZj]d4�tE|j�d5kD�r|jd5d}|j)d�}|dk7r||dzd}|d|}nd}|jTj
|�|jVj
|�|}|jZj]d6�n�|jd7k(r7|j^j
d�|j`j]d4�n�|jd7k(rp|jbj
d�|jdj
d�|j^j
|jd5d�|jgd6�n1|jr%|jhj
|j�	tE|�dk(r`|jjjd8k(rG|jld9k(s|jlddk(rtojp�}|d}n|jl}|jrj
|�|jw�y#tu�Y�xYw):Nrarz!Selected connection type. URI: %sr�rr�z)A printer connected to the parallel port.r�rrWrarbrczUA fax machine or the fax function of a multi-function device connected to a USB port.z"A printer connected to a USB port.r�z"A printer connected via Bluetooth.r�zUHPLIP software driving a printer, or the printer function of a multi-function device.r�zUHPLIP software driving a fax machine, or the fax function of a multi-function device.r�z?Local printer detected by the Hardware Abstraction Layer (HAL).r�rhrr�r�rirjrfrkrlrmrnrorpr�i�#)�defportzsocket: host is z
, port is r�r]�+rP�baud�bits�parity�flowr�Fr�Tr��directr�)<rr r"r�r r�r��new_printer_device_tabsr#rr�r�r�rdrr�r�r3r�r:r�rtrrrrurv�
splitnportr�r�r�r�r5�is_classrYr�r�r�r�r2r3rr�r��set_completionr�rYr�r�r�r�rr�rfr�rI�unamer�rGr�)rjrTr-rqr6r.r �pager�rrsr�rrr=r}r~r�r�rz�partsr�option_dictr�r�rr�r?r>s                             r� on_tvNPDeviceURIs_cursor_changedz.NewPrinterGUI.on_tvNPDeviceURIs_cursor_changed�s^���(�(�+���f��<��� � �#���~�~�t�$������q�)������#�#�,�,�b�1��+�+�/�/����d�>U�>U�V�����(�(��.��6����C�D����{�{���j�j���s�A�&�r�*���4�-�-�-��{�{�j�(��D�E������%��F�E�*��J�J�$�$�&�+�+�E�2�R�7�'(��x�%�'7�!�E�(�'B�F�$��.�/�D��A�B�D�����+��=�>������$��O�P������'��K�L������%��=�>������'�6�;�;�&�+@�!'���!7�!7����!D����%�|�|�5�5�t�<���t�$*�L�L�$;�$;�T�$B�!��D���?�y��|�s�':� )�!�"�
�I���&��=�>�D�#�H��y�y��)�R�/�#(�����;�/�2�5�#(�����#5�6�"�<�#8���+� �!@�A�H�L�� �!=�>���z�z���'�'�0�0�$�7�
�[�[�(�
"�#�\�\�3�3�V�Z�Z�@�N�V�T��D��D���!�#)�<�<�#9�#9�4�#@� ��4�%�|�|�6�6��$�6�O���t���@D�d��M�N��?�?�b�(�%���H�#�H��(�(�1�1�4�8��$�$�-�-�s�D�z�:�
�[�[�(�
"��?�?��
�
�(�(��a�0����;��?�#�A�h�G� �G�'�'�-�-��,�� ��%�.�F�"(�,�,�s�"3�K�D�%�(-�K��%�.�
�*�*�F�3��*�*�F�3��,�,�h�7��*�*�F�3�	%5�-�L�F�D�
�{�*� &� 0� 0� 2��$�3�3�5����"�$)�I�I�d�1�$5�a�$8�E�"�E�{�c�;�t�3D�.E�E� %�#(�?�?�4�#8�D��!�G�B�#� �"�-�-�b�1�"�-�-�q�1��)�)�!�,�+-�0�[�[�%�
����'�'��,����(�(�"�-����.�.��5����-�-�u�5��F�J�J��!�#��z�z�!�"�~���I�I�s�O����7�"�1�q�5�6�l�G����8�D� �G��"�"�+�+�T�2��#�#�,�,�g�6����#�#�1�1�4�8�
�Z�Z�5�
 ��N�N�#�#�B�'����+�+�E�2�
�[�[�E�
!����(�(�"�-����(�(�"�-��N�N�#�#�F�J�J�q�r�N�3��-�-�t�4��z�z��!�!�*�*�6�:�:�6�
	!��H�~��"�t�{�{�'?�'?�8�'K��J�J�+�-��J�J�q�M�S�(�����A� ��t�H�#�z�z�H�
���'�'��2�	
�����	!�� �s
�B	a2�2bc��|j�}|jjt|�dkD�|j	�yr)rr�rYrYr�)rjrr�s   r�on_entNPTLpdHost_changedz&NewPrinterGUI.on_entNPTLpdHost_changed@
s6���<�<�>�����)�)�3��>�A�+=�>����rc�$�|j�yrB�r�rOs  r�on_entNPTLpdQueue_changedz'NewPrinterGUI.on_entNPTLpdQueue_changedE
������rc��	�|jj�}tj|��	|jjdt
d�zdzt
d�z�|jj|j�|jj�t|j��	fd�}|jj|j�|jjd|�}�	j�}|jj|�|jjdt �|_
|jj#�t%j&t(�}|D]}|j+|g��t%j,�}|j/|�|j1d�|j3d�|j4j7|�y)Nz"<span weight="bold" size="larger">r�z	</span>

zSearching for printersc�&���j�yrR)r})rTrU�servers  �rr�z5NewPrinterGUI.on_btnNPTLpdProbe_clicked.<locals>.stopS
s����N�N��rrr)r�rrb�	LpdServerr��
set_markupr3r�r`r�r�rPr"rCrB�proberVrSrr4r5r$�EntryCompletionr6�set_text_column�set_minimum_key_lengthr�r�)
rjrr�r��signalr>r6r?�
completionr�s
         @r�on_btnNPTLpdProbe_clickedz'NewPrinterGUI.on_btnNPTLpdProbe_clickedH
s�����%�%�.�.�0���(�(��2�������!E�!"�;��"0�2?�"@�!"�#;�!<�"=�	>�	
���)�)�4�+@�+@�A���� � �#��d�o�o��	�	
���"�"�D�$;�$;�<����(�(�.�$�?���<�<�>�����"�"�F�+�"&�/�/�"9�"9�>�;N�#P����������
�
�s�#���	%�G��L�L�7�)�$�	%��(�(�+�
����e�$��"�"�A�&��)�)�1�-����*�*�J�7rc��|j�}|jd�dk7r�|jd�td|z�|jj|�|j
j
�}|j|j�}|j
j|d��|jjdd�|jjd�ytjtjzdz}|j||�|j�}|j j#t%|�dkD�|j&j)�|j+�y)	Nr�rrzURI detected (%s) -> Enter URIF)r-�
start_editingrrL)rr�r�rdr�r�r r!rrrD�
select_region�set_positionrrrrr�rYrYr�rSr�)rjrr�r6r-rrns       r� on_entNPTNetworkHostname_changedz.NewPrinterGUI.on_entNPTNetworkHostname_changedj
s,���|�|����9�9�c�?�b� ��L�L�"���8�4�?�@����&�&��-��$�$�.�.�1�E��>�>�4�#8�#8�9�D����'�'�d�7<�
(�
>����+�+�Q��2����*�*�B�/���,�,�V�]�]�:�9�D�
����3�
�.��L�L�O�����)�)�3��7�Q�;�7��#�#�(�(�+����rc����jj�}�fd�}�jjd��jjd�d�_�j
j
��jj�tj�}�j�|j||�|�_
y)Nc�`���j�ytj�j|�yrB)r�rr
�found_network_printer_callback)�
new_devicerjs �r�found_callbackz?NewPrinterGUI.on_btnNetworkFind_clicked.<locals>.found_callback�
s&����"�"�*���M�M�4�>�>�
�KrFr)r�rr�rY�
network_foundr�rSr�r=rb�
PrinterFinderr~r�r�)rjrr�r��finders`    r�on_btnNetworkFind_clickedz'NewPrinterGUI.on_btnNetworkFind_clicked�
s�����)�)�2�2�5��	L�	
���)�)�5�1��"�"�0�0�%�8�����#�#�(�(�+��$�$�-�-�0��,�,�/����� ����T�>�*�$��rc�2�tj�|r�|xjdz
c_t|�}	|jj|�}|j|j
|�|jj�\}}|rh|jj�}|j|�}|j|d�|j|k(r|j|j�n�d|_|j/�|j0j3�|j4j7d�|j8j7d�|jdk(rD|j:j=dt?d�zdz�|j:jA�tjB�y#t$r�d|_|jj|�|jj!�|jj�}|j#d|j$|j'�|dg��}|jdk(r.|j)|�}|jj+|dd�Y��wxYw)	NraTFrlrz<i>z%No printer was found at that address.z</i>)"rrr�rr=rr�r�rr r"r�r�rmrqr$r4r�rsrpr!rDr�r�r�rSr�rYr�r�r�r3r|r)rjr�r�r�r-rqr6r.s        rr�z,NewPrinterGUI.found_network_printer_callback�
s:����������!�#�� �*�-�C�
D��L�L�&�&��,�����Q��*�*�J�7�!%�!1�!1�!<�!<�!?���v�� �,�,�6�6�9�E� �>�>�4�0�D�����a�0�D�L�L��O�C��:�:�D�<L�<L�M��#'�D���!�!�$��(�(�-�-�0��&�&�4�4�d�;����-�-�t�4��!�!�Q�&��+�+�6�6��89�;E�9F�9F�IO�9O�P��+�+�0�0�3������5�
D�$(��!����#�#�S�)����!�!�$��(�(�2�2�5���*�*�D�$�2K�2K�14����#�u�0M�+�O���%�%��*� �>�>�4�0�D��$�$�/�/��t�U�C��
D�s�CG�CJ�Jc��|jdvr|jjS|jj}|jj||j�}|}||jk(r|jj}|S|dk(rJ|jj�}|jj�}|r|d|zz
}|r|d|zz
}|S|dk(rJ|jj�}|jj�}|r|d|zz
}|r|d|zz
}|S|dk(r�g}|jdf|jd	f|jd
f|j dffD]U\}}	|j#�}
|j%�}|
j'|d�}|d
k7s�>|j(|	dz|z��Wdj+|�}|jjj-d�d}|r|dz|z}|S|dk(r�|j.j�}
t1|
��j3�\}}}}}d
}d
}|j4j7�r4|j8j�}|j:j�}t1|||||��j=�}
|
r|d|
zz
}|S|j>j�}|S)N)r�r!r�r\r�r�r�r�r�r�r�r�rarrPr�r]rr�r�)rpr�r�r�r�) rhr rrr�r#r�r�r�rr�r�r�r�r�r�r�r rr�r$rlr�r�rr�r�r�r�r�rr�)rjrr�r r�r�r?rrTr=r6r.r�rrpr�r>rUr�r�s                    rr�zNewPrinterGUI.getDeviceURI�
s������:�:��;�;�?�?�"��{�{�����+�+�/�/��t�7N�7N�O�����4�-�-�-��[�[�_�_�F�Z�
�Y�X�
��/�/�8�8�:�D��+�+�4�4�6�D���%�$�,�&����c�D�j�(�F�L�
�K�U�]��%�%�.�.�0�D��)�)�2�2�4�G���%�$�,�&����c�G�m�+�F�>�
�=�X�
��G��&�&��/��&�&��/��(�(�(�3��&�&��/�	!1�	
8����
�(�(�+���-�-�/�����$��2���R�<�"�G�N�N�4�#�:��#6�7�	
8��h�h�w�'�G��k�k�o�o�+�+�C�0��3�F���#���/���
��U�]��.�.�)�)�,�C�)/�S�)9�)B�)B�)E�&�U�D�%��A��D��H��"�"�-�-�0��*�*�3�3�6���.�.�7�7�:����D��#�h�8�8?��
�
���%�#�+�%���
��&�&�/�/�1�F��
rc�B�|jj�}|jj�}|jj�}|jj|�|jj|�|r|j}|r|j}|r|j}|jj�|s�|jr�|jD]}|jj|��d|_
|jj�d|_|j jd�|j"j%t'd��t)j*t,t,�}|j.}|j1|�|jd�|j2|j.fD]}|j|��|j j|xr|jdu�|j5�yr	)r�r�r�r�r�rYr�r�r�r�r�r�rFrGr"r!r�r�r�r3rr4r5r�r6r�r�)	rjrT�rbtn1�rbtn2�rbtn3r�r#r6rrs	         rr�z'NewPrinterGUI.on_rbtnNPFoomatic_toggled�
s����#�#�.�.�0�����)�)�+���3�3�>�>�@�����$�$�U�+����)�)�%�0���-�-�D���*�*�D���2�2�D����+�+�T�2������.�.�
0���
�
�%�%�w�/�
0�#'�D���J�J��� ��D�J��.�.�<�<�d�C��4�4�=�=�q��{�K��M�M�3��,�E��@�@�H�����&��"�"�E�*��9�9��@�@�B�	(�F�� � ��'�	(�	
�*�*��M�5�9�d�j�j�D�&8�:����rc�$�|j�yrBr�r's  r�#on_filechooserPPD_selection_changedz1NewPrinterGUI.on_filechooserPPD_selection_changed#r�rc�6�d|_|j�T|jD]}|jj|��d|_|jj	�d|_|jd�|j}|jtd��|jj�}tdt|�z�t�|_g|_|jj|jjd|j ��|jj|jjd|j"��|jj%|�|j&jd�y)NTFr�zSearching for "%s"r�r�)r'rFrGr"r!rYr�r�r3r�rrdr�rr$rB�opreq_user_search_done�opreq_user_search_errorrr�)rjrTr#r��
searchterms     r�(on_btnNPDownloadableDriverSearch_clickedz6NewPrinterGUI.on_btnNPDownloadableDriverSearch_clicked&sJ��)-��&��:�:�!��.�.�
0���
�
�%�%�w�/�
0�#'�D���J�J��� ��D�J����e�$��8�8��
����+��'��7�7�@�@�C�
��(�4��+<�<�=�(�+��
� ������"�"��J�J���
� $� ;� ;�
=�	>�	
���"�"��J�J���� $� <� <�
>�	?�	
�
�
�!�!�:�.��1�1�?�?��Grc�0�|jD]}|j|��d|_d|_d|_d|_||_||_|j}|j}tj�	|jtd��|jd�tjt t �}t#|j
�dk7rft#|j
�dkDrtd�}ntd�}|j%d�}	|j'|	d|�|j'|	dd�g}
|j
D]\}}|
j%||f��|
j)t+j,d���	�|j.j1�j3�}
d}|
D]d\}}|j%d�}	|j'|	d|�|j'|	d|�|j3�|
k(s�Q|j5|	�d}�f|j6}|j9|�|j;|�|jd�|j=�tj@�y#t?�Y�#xYw)
NTr�raz -- Select from search results --z-- No matches found --rrc�:�tj|d|d�S)Nra)r��	modelSort)rZrs  rrz6NewPrinterGUI.opreq_user_search_done.<locals>.<lambda>as��D�N�N�TU�VW�TX�Z[�\]�Z^�D_�r)�key)!rGr"rrFr(r+r
r�r�rrr�r3rYrr4r5rYr$�	set_valuer4�	functools�
cmp_to_keyr�rr:r!r�r6rr�rGr)rjrFr>rr#rr�r6�firstr.�sorted_list�
printer_id�printer_name�sought�select_indexr�r=rrs                  rr�z$NewPrinterGUI.opreq_user_search_done@sJ���*�*�	'�G����g�&�	'�"&���"�����
�(,��%�%-��"�$+��!��3�3���8�8������!	 ��N�N�A�h�K�(�� � �$�'��M�M�3��,�E��D�.�.�/�1�4���2�2�3�a�7��@�A�E��6�7�E��|�|�T�*������q�%�0�����q�"�-��K�,0�,F�,F�
@�(�
�L��"�"�Z��$>�?�
@�
���)�"6�"6�7_�"`��a��7�7�@�@�C�I�I�L�F��L�'�
<���D��|�|�T�*������q�$�/�����q�"�-��:�:�=�F�*�#(�>�>�4�#8��#;�L�
<��@�@�H�����&�����.��"�"�D�)���� �	�����	 ���s�:FJ�
A%J�Jc�|�td|t|�fz�|j|t�t	��yr)rdr�r�rYrrs    rr�z%NewPrinterGUI.opreq_user_search_errorts9���:�f�>B�C�j�>J�J�	K��#�#�U�D�F�D�F�;rc�d�|j�|j��|jD]}|jj|��d|_|jj	�d|_|j
j
d�|jjtd��yy)NTr�)
r�rFrGr"r!r�rYr�r�r3)rjrTr#s   r�/on_cmbNPDownloadableDriverFoundPrinters_changedz=NewPrinterGUI.on_cmbNPDownloadableDriverFoundPrinters_changedys��������:�:�!��.�.�
0���
�
�%�%�w�/�
0�#'�D���J�J��� ��D�J��.�.�<�<�d�C��4�4�=�=�q��{�K�"rc�d�td�d|_|jdk(r�|j}|j	�}|j�}|rv|j
|d�}|j
|d�}|dk(rd|jd�|j�}|r%|j
|d�}|j
|d�}nd}d}nd}d}n|jd\}}|�|jD�cgc]}|d��	}}n|g}|r||_tjttj�}d}d}	|D]�}|j|}
|
j�D]�}d|vst!|d�dkr3t"j$s|j'|�st)d|dz��K|j+d�}|	�|}	|j-|d|d�|j-|d|�|d	s��|}����|	�y
|j.j1�sO|j2dk7r@|j+d�}|j-|dt5d��|j-|dd�|�|	}|j6}|j9|�|�|j;�j=|�|j?|�ycc}w)
N�filldownloadableDriversTrarrr�zRemoved invalid driver entry %sr=�recommendedFr�zLocal Driver) rVr*rr�r rr�rr+rr4r5rrWr
r;rYr1rMr2rdr$r�r�r�rhr3r�r6r�select_iter�)on_tvNPDownloadableDrivers_cursor_changed)
rjrTr6r.r��printer_strrZ�printer_ids�recommended_iter�
first_iterrr?r5s
             rr�z%NewPrinterGUI.fillDownloadableDrivers�s���
�(�)�/3��,��!�!�T�)��>�>�F��$�$�'�E��)�)�,�D��"�_�_�d�A�6�
�#�o�o�t�Q�7����#��%�%�q�)�!�1�1�4�D��%*�_�_�d�A�%>�
�&+�o�o�t�Q�&?��%)�
�&*��!�
�"��&*�&@�&@��&C�#�J����*.�)C�)C�D�A�1�Q�4�D�K�D�%�,�K��3>�D�0��
�
�s�&�4�4�6�����
�%�	,�J��/�/�
�;�G�!�.�.�+�
,���6�)�����(�A�-��0�0��9�9�6�B�� A� &�v��!/�0���|�|�T�*���%�!%�J�����q�&��.�9�����q�&�1��-�(�'+�$�!
,�	,�(����2�2�=�=�?����0�0��<�<��&�D��O�O�T�1�a��&7�8��O�O�T�1�a�(��#�)���/�/�����E�"��'��"�"�%�1�1�3C�D��6�6�x�@���aEs�-J-c�$�|j�yrBr�r's  r� on_rbtnNPDownloadLicense_toggledz.NewPrinterGUI.on_rbtnNPDownloadLicense_toggled�s�����rc��d|_|jj�}|jj	�}|j�d}|jr*tjj|j�}nd}|D]�}|xr"tjj|�|k(}|jr'|jjr|r|td�z}n|}|j||f�}|s�t|j|�}	|jj|	dd�|jj|	dddd�d}��|sN|jjt!j"�dd�|jjddddd�d}
|jrZ|jj$rD|jj$}|dr|d	r|dd
z|d	z}
n|dr|d}
n
|dr|d}
|
dk(r9|j�-|
|jz
}
|j&�|
d
|j&zz
}
|
j)d�s|
j)d
�rd}
|j*j-|
�y)NFr�Tr�r�rryrzrbr�r�r�)�recommended_make_selectedr��getMakesr�r r8r�r��	normalizer rr3r$r!rDr�rrwr�r�rcr�r�)rj�makesr6�found�auto_make_normr�r�r�r.r-ro�
devid_dicts            rrzNewPrinterGUI.fillMakeList�s=��).��&��	�	�"�"�$�����(�(�*��
���
����>�>�(�-�-�7�7����H�N�!�N��	�D�)�O�&�+�+�5�5�t�<��N�
��{�{�t�{�{�9�9�k��a� 0�1�1�����<�<��t�
�.�D���~�~�d�+�����)�)�4��u�=����-�-�d�D�.2�C��>���	� ��N�N�%�%�s�|�|�~�t�U�C��N�N�)�)�!�T�4��c�B����;�;�4�;�;�.�.����,�,�J��%� �Z��%6�#�E�*�S�0�:�e�3D�D���E�"�#�E�*���E�"�#�E�*���R�<�D�N�N�6��d�n�n�$�F����*��#����/�/�����i�(����i�(��F��*�*�3�3�V�<rc��|j�\}}|��|j��|j�}|j|�}|j	|d�d|_|jxrStjj|j�tjj|j
�k(}||_	|j�yyyr�)rr�r r"r#�NPMaker�r�r�r��
fillModelList)rjr�r-rqr6r.�recommended_makes       r�on_tvNPMakes_cursor_changedz)NewPrinterGUI.on_tvNPMakes_cursor_changeds��� �+�+�-���f����	�	� 5��'�'�*�E��>�>�4�(�D��)�)�D�!�,�Q�/�D�K� $���!I� +� 0� 0� :� :�D�N�N� K� +� 0� 0� :� :�D�K�K� H�!I�
�.>�D�*���� �!6�rc��d|_|jj|j�}|jj�}|j
�d}tjj|j�tjj|j�k(}|r)tjj|j�}|D]�}|xr"tjj|�k(}|jr'|jjr|r|td�z}n|}|j||f�}	|s�t|j|	�}
|jj!|
dd�|jj#|
dddd�d}��|sN|jj!t%j&�dd�|jj#ddddd�|jj)�y)NFr�Tr�rr�)r-r��	getModelsr�r�r r8r�r�r�r�r rr3r$r!rDr�rrw�columns_autosize)rj�modelsr6�selected�is_auto_make�auto_model_norm�pmodelr�r�r.r-s           rr�zNewPrinterGUI.fillModelLists���*/��'����$�$�T�[�[�1�����)�)�+��
���
���#�(�(�2�2�D�K�K�@�#�(�(�2�2�D�N�N�C�D���)�.�.�8�8�$�/�/�J�O��	 �F�'�+�&�+�+�5�5�v�>�*�+�
��{�{�t�{�{�9�9�k���"2� 3�3�����<�<��v��0�D���~�~�d�+�����*�*�D�$��>����.�.�t�T�/3�S�#�?���	 � ��O�O�&�&������e�D��O�O�*�*�1�d�D�#�s�C����(�(�*rc��||_|jj�}|j�|jr|jj
}nd}|jrw|jjra|jrU|jrI|jj}|j|_	tdt|j�z�n�|jr�|dz|z}|jj||�}t|j��}|j }	|jj#||||�|_	|j&rl|jr`g}	|jD]5}
|
|j&k(r|	j)d|
��%|	j+|
��7|	|_	ntd�g|_	g}g}d}
|jD�]}|jj-|�}t/|d�}
|
j1dd�}
	dt/|d	�z}|
|z
}
|
|v}|jr|jjs�|j&|k(r�|j+|
�|j+|�|
d
z
}
|j+|
t5d�zf�}|j7|�}|jj9�j;|�|jj=|ddd
d���+|jr�|
dk(r�|j+|
�|j+|�|
d
z
}
|j+|
t5d�zf�}|j7|�}|jj9�j;|�|jj=|ddd
d����|r���|j+|
�|j+|�|
d
z
}
|j+|
f���||_	|jj?�y#t%�||_	Y���xYw#t2$rY��
wxYw)NzID matched PPDs: %srbrzNo PPDs available?r�r�rz [%s]zppd-natural-languagerar�Tr�r�) �NPModelr�r r8r r�rr-r��	NPDriversrdr�r�r�rYrr&r�rGr��insertr$r�r[rr�KeyErrorr3r!r�select_pathr�r�)rj�pmaker�r6r�rr��ppdnames�filesrr?�
driverlistr�r�r�r!�lpostfix�	duplicater.r-s                    rr�zNewPrinterGUI.fillDriverList7s������� � �*�*�,��
���
��;�;��K�K�'�'�E��E��K�K�D�K�K�6�6��+�+��$�$�!�[�[�7�7�N�"�5�5�D�N��-��d�n�n�0E�E�F�
�Y�Y�#�S�[�6�1�N��9�9�-�-�e�V�<�D��D�I�I�L�)�H��/�/�E�
*�!%���!D�!D�X�EJ�ES�EJ�"L������D�K�K���"�n�n�0�F���!1�!1�1�����6�2�����/�	0�")���
�,�-��D�N��
��	�
���~�~�&	)�G��)�)�.�.��8�C���%9�!:�;�F��^�^�$4�b�9�F�
�"�Z��5K�1L�%M�M���(�"���*�,�I��[�[�T�[�[�%?�%?�� � �G�+��!�!�6�*�� � �'�*��Q����|�|�f�&'��o�'6�&8�9���~�~�t�,��� � �.�.�0�<�<�T�B�� � �/�/��d�D�#�s�K�����a���!�!�6�*�� � �'�*��Q����|�|�f�&'�(8�&9�':�&<�=���~�~�t�,��� � �.�.�0�<�<�T�B�� � �/�/��d�D�#�s�K����!�!�6�*�� � �'�*��Q������f�Z�(�M&	)�P#������)�)�+��
*�!�$�!)����8�
��
�s�0#P�P4�P1�4	Q�Qc�r�|r|j�d}|�0y|j||�\}}|j||�}	|	�y|	d}|j|d}
|jj|
�}t
|d�}|
jd�r|dz
}|td�z
}|j|�y)NrFr�z	foomatic:rbz"This PPD is generated by foomatic.T)
r�#convert_widget_to_bin_window_coords�get_path_at_posr�r�r�r[rcr3r�)
rj�tvrZr�
keyboard_mode�tooltipr-�bin_x�bin_yrD�
drivernamer�markups
             rrbz(NewPrinterGUI.on_NPDrivers_query_tooltip�s�����=�=�?�1�%�D��|���A�A�!�Q�G�L�E�5��$�$�e�U�3�C��{���q�6�D��^�^�D��G�,�
��)�)�.�.�z�:���W�%9�:�;���!�!�;�/��c�M�F��a�<�=�=�F����6�"�rc��|j�\}}|��|j�}|j|�}|j|d�d}|jxr9|j
xr+|j
j
�|j
�k(}||_|j|j|�|j|j�yyr�)rr r"r#r�r�r:r-r�r��on_tvNPDrivers_cursor_changedr�)rjrTr-rqr6r.r��recommended_models        r�on_tvNPModels_cursor_changedz*NewPrinterGUI.on_tvNPModels_cursor_changed�s����(�(�*���f����$�$�'�E��>�>�4�(�D��Y�Y�t�Q�'��*�F�"&�!?�!?�"M�!%���"M�!%���!6�!6�!9�V�\�\�_�!L�
�/@�D�+�������V�4��.�.�t�/?�/?�@�rc�$�|j�yrBr�r's  rr
z+NewPrinterGUI.on_tvNPDrivers_cursor_changed�r�rc�
�|jjd�|jjd�|jjd�|jjd�|j
j
d�|jj�|j�}|�y|j�\}}|s(|j�\}}|r|j|�}ny|j|d�}|dk(r6|jj|j �|j#�y|jj|j$�|j'dt)d��}|j*}	|d}
d�}||	|
�|jj|�|j'd	t)d
��}|j,}
|j.}||
|d�|||d�|jj|�|j'd
t)d��}|jj1|�d|vr�|d}dD]�}|j3�}d}|j4j'd|z�}|j4j'd|z�}||vrT|rR	t7||�}|j9dd�|j;|�|j=�|j�|���|j�|j=���d}d|vrd|dD]\}|ds�	d|dz}d}|dr||dz}|dr|r|t)d�z}||dz}|s�@|t)d�|zz}|r|dz}||z}�^|st)d�}|jj|�d|vr_|jj?�|j'dt)d��}|j@jC�j|�n|jj�|dsU|dsP|jDj
d�|jDj�|j
j�n�|j
j
d�|jDj?�|j
j?�|jj?�|j'dt)d��}|j@jC�j|�d |vrtG|d �dkDrd|_$nd!|_$|j#�y#Y��uxYw)"NrTrar�supplier�OpenPrinting�manufacturersuppliedc�4�||_|j|�yrB)r	r)rTr
s  r�set_protect_activezSNewPrinterGUI.on_tvNPDownloadableDrivers_cursor_changed.<locals>.set_protect_active�s��$*�F�!����v�&r�license�
Distributable�patents�freesoftware�shortdescriptionr��
functionality)�Graphics�LineArt�Photo�TextzhsDownloadableDriverPerf%sz"lblDownloadableDriverPerf%sUnknownr��supportcontactsr=rbrs�levelr�z
(%s)rIzNo support contacts known�licensetextzNot specified.�nonfreesoftwarer�F)%r�r�r�r�r�r�rr�rSrr�rr"r�r�r�r�r�r�r#r3r�r�r�r�r:�__dict__r��	set_ranger�r=r|r��
get_bufferr�rYr))rjrTr(r6r.r-rqr?r�vendorr
rrr�free�descriptionr�fieldr�r��hs�unknownr!�supportentry�supportcontact�supportcontact_extra�termss                           rr�z7NewPrinterGUI.on_tvNPDownloadableDrivers_cursor_changed�s���,�,�5�5�r�:��+�+�4�4�b�9��/�/�8�8�"�=��3�3�<�<�b�A��$�$�/�/��6��0�0�5�5�8��(�(�+�	�����,�,�/���t��!�,�,�.�L�D�&���~�~�t�,������$��*���Q�;��3�3�D�D�d�F`�F`�a�������/�/�@�@�$�BY�BY�Z��:�:�j�!�N�*;�<���:�:���.�/��	'�	�F�F�+��,�,�5�5�x�@��*�*�Y��/�(:�;���;�;���5�5���G�V�I�%6�7��D�&��"8�9��+�+�4�4�g�>��j�j�!3�Q�v�Y�?���/�/�:�:�K�H��f�$�"�?�3�M�A�
(���k�k�n�����]�]�&�&�(D�u�(L�M���-�-�+�+�-Q�/4�.5�6���-�'��!�$'��s�);�$<�E��L�L�!�S�1��L�L�%�0��K�K�N�#�L�L�O��=��G�G�J��$�$�'�'
(�*����&� &�'8� 9�
K����'�%*�\�&�-A�%A�N�+-�(�#�E�*�/C�(��/�00�,�#�G�,�/�3G�!�D�'�3Q�0�/C�(��1�02�,�+�)7��h�K�*>�>�*?��*�.=��.D�O�*9�N�*J��#
K�$�� ;�<�O��3�3�<�<�o�N��F�"��4�4�9�9�<��J�J�}�a�0@�.A�B�E��.�.�9�9�<�E�E�u�M��4�4�9�9�<��'�(��	�1B��)�)�4�4�d�;��)�)�.�.�1��(�(�-�-�0��(�(�3�3�T�:��)�)�.�.�1��(�(�-�-�0��4�4�9�9�<��J�J�}�a�0@�.A�B�E��.�.�9�9�<�E�E�u�M��V���F�6�N� 3�a� 7�(,�D�%�(-�D�%������k!� �s
�6AU7�7U<c�
�d}	|jj�st|j�dkDr_|jdk(rP|j
j
�j�\}}|j|�d}|j|}�nu|jj�r/tj|jj��}�n,|j}|j
�j�\}}|j!|d�}|dk7r�d|vr�t|d�dkDr�|dd}t#d|zdz�|j%�}t|�dkDr�t&j(j+|�}|j-�}	|j/�t1j2�5}
|
j5|	�|
j7�tj|
j8�}ddd�t#dtA|�z�t[|t\�r�|jj_tCd��	|dk7rE|jja|�}tj|�}tcjd|�|jjk�|S#1swY��xYw#t:t&j<j>f$�r�}t#dtA|�z�|jj�r�tCd�}tCd	�}
|j
j
�j�\}}|j|�d}|j|}|jEd
�rtCd�dz}n�|
||jF|jHfz}n�|jj�r�tCd
�}|jj�}tCd�dz}	tKjLdd|gdtJjNtJjPtJjP��}|jS�\}}||jU�z
}n#�xYwtCd�}tCd�}tW|||jX�Yd}~yd}~wwxYw#t:$rtg�t#d�Y��;tjh$rtg�t#d�Y��ewxYw)NrFrar�zppd file to download [�]zRuntimeError: zDatabase errorz4The '%s' driver cannot be used with printer '%s %s'.�
gutenprintzFYou will need to install the '%s' package in order to use this driver.zgutenprint-foomaticz	PPD errorz2Failed to read PPD file.  Possible reason follows:rIz/usr/bin/cupstestppdz-rvvTrOzDownloadable driverszFailed to download PPD.zppd: zfetching PPDr�z/libcups from CUPS 1.3 not available: never mindz)CUPS 1.3 server not available: never mind)6r�r�rYr&r)r�rr�r!r�r�r�r�r�rr�r�rdrqrrerfri�closer�r�r�r�r=r�r�r�r�r3rcr�r�rQrRrSrTrJrjr=r�rXr5r��getServerPPDrI�unlinkrGr�r�)rjr!r6r.rr5r?�file_to_download�	ppdurlobjr�r�rv�	err_title�err_textr�filenamerUrLrVr�s                    rr�zNewPrinterGUI.getNPPPD5sB����K	��$�$�/�/�1���3�3�4�q�8��)�)�U�2�"�.�.�<�<�>�K�K�M���t��^�^�D�)�!�,���n�n�R�(�����*�*�,��h�h�t�2�2�?�?�A�B�� �7�7��&�4�4�7�D�D�G���t����$��2���Q�;�6�V�#3��F�6�N�+�a�/�+1�&�>�!�+<�(�"�$<�?O�$O�QT�$T�U�+;�+A�+A�+C�(�� 0�1�A�5�(.���(>�(>�?O�(P�I�)2���)9�J�%�O�O�-�!)�!<�!<�!?�:�4� $�
�
�:� 6� $�
�
�
�&*�h�h�t�y�y�&9��:�j	�7�T�#�Y�&�'��c�3���I�I�&�&��.�(9�:�

I��%�<��	�	�.�.�s�3�A��(�(�1�+�C��I�I�a�L�
�I�I�$�$�'��
�O:�:��
�f�l�l�4�4�5�.	��(�4��8�3�4��"�"�-�-�/��.�/�	��:�;��#�/�/�=�=�?�+�|�~���t��^�^�D�)�!�,������+���$�$�l�3��;�<�1�2�C�#�f�d�k�k�4�<�<�%H�H�C����*�*�,��k�N�	��.�.�;�;�=���#�$�&*�+��
�#�(�(�+A�+1�8�+=�48�0:�0B�0B�1;���1;���B�A�()�}�}�'7�$�V�V��6�=�=�+�+�C������4�5�	��1�2���y�#�t�/D�/D�E���].	��r �
O�!�#��M�N��=�=�
I�!�#��G�H�
I�sd�F=K�AJ<�K�A
R:�<K�K�$R7�,DR2�A-Q:�9R2�:Q=�=0R2�2R7�:T�'T�Tc	���td�d|_i|_|j}|j	�D]}|j|��|jsLtjtd���}|j|�|j�td�y|jjD�]�}|jdk7r�d|_tj�}|jd�|j!d�|j|�d	}t#|j�D�]9\}}|j$d
k(r�|dz
}t'||j|�}	|j)|	j*d	|dd�tj,�}
|	j.r|tj0j3ddd
d
�}|j5d	d	d	d�|j|	j.�|j)|d|dd�|j)|
d|dd�n|j)|
d|dd�|
j7|	j8ddd	�|	|j|j$<��<���|js@tjtd���}|j|�|j�|j:j=�|j:j?�y)NzExamining installable optionsFzNo Installable Options)r�z No PPD so no installable options�InstallableOptionsTr�r�
PageRegionrar�g�?r�) rdr$rr��get_childrenr%r!r�Labelr3r�r|�optionGroupsr=�Grid�set_column_spacing�set_row_spacing�	enumerate�keywordr
�attach�conflictIcon�Boxr��	Alignmentr�set_paddingr9�selectorr�rSr=)rj�	container�child�lrp�gridr*rr��o�hbox�as            rr�z&NewPrinterGUI.fillNPInstallableOptions�s[���3�4�#(�� �����+�+�	��+�+�-�	$�E����U�#�	$��x�x��	�	��":� ;�<�A��M�M�!��
�F�F�H��:�;���X�X�*�*�	1�E��z�z�1�1��'+�D�$��8�8�:�D��#�#�A�&�� � ��#��M�M�$���D�'��
�
�6�
1�
��F��>�>�\�1����	�� �����4�8�����A�N�N�A�r�1�a�8��w�w�y���7�7��
�
�)�)�3��S�#�>�A��M�M�1�a��A�.��E�E�1�7�7�O��K�K��1�b�!�Q�/��K�K��a��Q��2��K�K��a��Q��2�����
�
�E�5�!�<�/0����V�^�^�,�#
1�	1�8�'�'��	�	��":� ;�<�A��M�M�!��
�F�F�H��$�$�)�)�+��$�$�-�-�/rc��|jr1|jj�d|_|j�|jr!|jj�d|_|jr1|jj�d|_|j�|jdvrO|jj�}|jj�}|jj�}n|j}|j}|jdk(r<t|j�}	|D]}	|jj!||��!�n�|jdk(s|jdk(�r�d}
|j*j,r|j*j,}
n|j/�}
|js|j1d�y|j2j5�D]}|j7��t9|j:�t=j>�r)t=j@�t=j>�r�)|jjCtEd�|z�	tG|tH�r!|jjK|||
��ne|� |jjK||
��nCtMjN||jPd	�|jjK|||
�
�|jjU�tS|j:�|jdvr�|jjCtEd�|z�	tMjX|j|�|jj[|�|jj]|�|jjU��n�|jd
k(rq|jjCtEd�|z�	|j/�}
|jjK||
��|jjU��n|jdk(�r�|s+|j_�x}|_|s|j1d�y|jjCtEd�|z�d}tG|tH�r�|j`jc�r	|jjK|d��	|jjK||��	|jje|�}
tjf|
�}tijj|
�n�|j`jc�sEtG|jntjf�r!tMjp|jn|�n#tMjN||jPd	�|j2j5�D]}|j7��	|jjK||��|jjU�n |jdk(r|j1d	�|j:js�|jdvr|jud|�nV|jdk(r|jud|jv�n*|jud||jn|jk7�d|_i|_<y#t"$rY��wxYw#tj$$r+}|j&\}}	|j)||	�Yd}~yd}~wwxYw#tj$$rZ}|j&\}}	tS|j:�|j)||	�|jjU�Yd}~yd}~wtS|j:�|jjU�tWd�Y��xYw#tj$$rE}|j&\}}	|j)||	�|jjU�Yd}~yd}~wwxYw#tj$$rE}|j&\}}	|j)||	�|jjU�Yd}~yd}~wwxYw#tj$$r,}|j&\}}	|j)||	�Yd}~���d}~wwxYw#tj$$rE}|j&\}}	|j)||	�|jjU�Yd}~yd}~wwxYw#tj$$ra}|j&\}}	|tjlk(rd}n1|j)||	�|jjU�Yd}~yYd}~���d}~wwxYw#tj$$rE}|j&\}}	|j)||	�|jjU�Yd}~yd}~wwxYw)N)r�r?r�r�r?r�rzadding printer %s)r�r r�r�)r r�r�r)r!r r�r�razmodifying printer %sr r�r!Fr�)r�T)r!r�)r?r�r�r~r�r)=r�r}r�r%r�r!rhr�rr�r�r�r!r8r�r��addPrinterToClassr�r�r�r�r rr�r�rr;�	writebackrPr�rrErFr�r3rXr5�
addPrinterr��setPPDPageSizerrKr��fatalException�activateNewPrinter�setPrinterLocation�setPrinterInfor�r�r��getPPDr�rIr7�
IPP_NOT_FOUNDr��copyPPDOptionsrSr�r&r>)rjrTr=r�r�r!�members�memberrv�msgrr�r�r<s              r�on_btnNPApply_clickedz#NewPrinterGUI.on_btnNPApply_clicked�s,���!�!��"�"�*�*�-�%)�D�"��!�!�$��?�?��O�O�#�#�&�"�D�O�������&�&�)�"&�D���!�!�$����G�G��>�>�*�*�,�D��)�)�2�2�4�H��(�(�1�1�3�D��:�:�D��h�h�����w�&�,�T�-=�-=�>�G�

�%�!�F�!��	�	�3�3�F�D�A�!��
�
��
*�� � �$6�6��C��{�{����k�k�o�o���'�'�)���8�8����r�"���,�,�-�-�/�
#��� � �"�
#�
�$�'�'�(��$�$�'��"�"�%��$�$�'��I�I�&�&��*=�(>��(E�F�
#��c�3�'��I�I�(�(��s� #�$��)�C��[��I�I�(�(��c�.2�X�)�G� �.�.�s�D�M�M�!�4D�E��I�I�(�(��3�s�.2�X�)�G�
�I�I�$�$�&��4�(�(�)����G�G��I�I�&�&��*@�(A�D�(H�I�
��.�.��	�	�4�@��	�	�,�,�T�8�<��	�	�(�(��t�4�
�I�I�$�$�'�
�
�
��
)��I�I�&�&��*@�(A�D�(H�I�
��'�'�)���	�	�$�$�T�#�$�6�
�I�I�$�$�'�
�
�
��
&��!%����0��d�h���N�N�2�&���I�I�&�&��*@�(A�D�(H�I��C��#�s�#��)�)�4�4�6�4��	�	�,�,�T�5�,�A���I�I�(�(��s�(�;��#�y�y�/�/��5�H��(�(�8�,�C��I�I�h�'��/�/�:�:�<���
�
�t�x�x�8��.�.�t�}�}�c�B��.�.�s�D�M�M�!�4D�E�#�l�l�1�1�3�'�F��$�$�&�'���I�I�(�(��3�(�7�
�I�I�$�$�'�
�
�
�!2�
2��N�N�1�����"�"�$����G�G��I�I���-�
�
�
�!2�
2��I�I�0�$�2M�2M�N��I�I�)�4����$�(�(�1J�K������
��s(�!� �!���=�=�
��6�6���C��#�#�A�s�+���
��N�=�=�
��6�6���C��t�,�,�-��#�#�A�s�+��	�	�(�(�*���
#��t�,�,�-��	�	�(�(�*���"���=�=�
��6�6���C��#�#�A�s�+��	�	�(�(�+���	
���=�=�
��6�6���C��#�#�A�s�+��	�	�(�(�+���	
��2 �=�=�4�#$�6�6���C��+�+�A�s�3�3��4��
�}�}�� �v�v�H�Q���'�'��3�/��I�I�,�,�/���	���}�}�� �v�v�H�Q���D�.�.�.�"���+�+�A�s�3��	�	�0�0�3��	����,�}�}�� �v�v�H�Q���'�'��3�/��I�I�,�,�/���	�s��]	�\9�$]	�
B^
�A`7�3-b�
c-�+d/�	Af
�h�9	]�]	�]�]	�	^�!^�^�
`4�A_2�2?`4�7b�
;b
�
b�c*�%;c%�%c*�-d,�!d'�'d,�/f�;f�f�
g>�Ag9�9g>�i�;i�i)NNNrNNNrrB)ra)FN)NN)F)�r�r�r�r�SignalFlags�RUN_LASTr5r��__gsignals__r�r�r�r�r�r�r�r�r�r}r�rrxrzr~r�r�r�r�r�r}r�r�r�r�r�r�r�r�r�r�r�r�rrr�rrrrr$r(r*rEr>r2r<r�r~r|r�r�r�r�r�r�r�r�rrrrr�rr&r(r2r,r1r<rMrTrZr�r�r�r�ryr7r�r�r_r]r^rrrrrr$r)r+r-r/rCrrJrMrPrTrQrRrBrSrOr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�rbrr
r�r�r�rdr|rrr{r{�s���%�0�0�9�9�4��D�$�0�0�9�9�4�#��H�$�0�0�9�9�4�!�"�%�&�%,�$7�$7�$@�$@�$���#O�$�0�0�9�9�4��D�
�L�����!"��!"�� !���J� ����
��!&����������������
��"a"�F	"�#� �!�Q�
�B���AE�DE�`�D�J�=�.�
"�"�)�4!�K� �
!�2�0�4)�$�$�6�6��:��&�P8�t/>�b�b�JM�^!�F G�D%�N4�`N�4�	�c(�JM(�^*� 2!�h:�9�8A6�F �6� A�2&�/��8�
"0�H�4�,Q�f('�T$>�L)��_S�F�<F<�P8�
*�,�
A�`)�DK��&I�& �P$�<$� �;�K=�Z	%��
�
�6� )�*�)!�V#��J)�Xc�J�
�8�D�,%�&+�\6�t&�P�H�42�h<�
L�L�\�
0=�d
!�+�@_,�B�*
A��t�la�J20�lwrr{c��td�y)Na�
This is the test/debug mode of the new-printer dialog of system-config-printer.

Options:

  --setup-printer URI
            Select the (detected) CUPS device URI on start up
            and run the new-printer wizard for it.

  --devid   Supply a device ID which should be used for the
            setup of the new printer with "--setup-printer".
            This can be any printer's ID, so that driver 
            selection can be tested for printers which are not
            physically available.
)rVr|rr�	show_helpri�s��	�
1�
2r�__main__rarzsetup-printer=zdevid=z--setup-printerz--devid�ui�SYSTEM_CONFIG_PRINTER_UIc�,�tj�yrB)r�	main_quit)r�s r�	on_signalro�s���
�
�rr~rr�r�)r�r�r?rB)Wr1r�r�rr��sysrIr�r^rl�http.clientrwrrrQ�timedopsr��
gi.repositoryrrr�r�r�rZrrr�guir	�
optionwidgetsr
r�rb�urllib.requestr�urllib.parse�smburir�errordialogsrr�r�r%r?r��gettext�installr2rrgr3r�rr0r8r@rKrPrVr[ryr{rir��getopt�
gnu_getopt�argvrkr��GetoptError�exit�
setup_printerr��opt�optargrO�	ppdippstr�	setlocalerHr��
set_debugging�set_debugprint_fnrdrerorB�mainr|rr�<module>r�sb��2���3��/�/�/�
�
�����������O��!���&���#���)�����������v�~�~��1A�1A�B��
��)�*��� ����6��
��@ZC�F�ZC�xF2��z����&�V�&�&�������b�)9�)1�)3�4�
��d��M��E�����V��#�#�"�M�
�I�
��E�	�.2�B�J�J�)�*���F���f�m�m�R�(��I�N�N���4��!�K�!�!�:�.���A���I�I��	�*��I�I�!�9�-��I�I� �)�,�� �	���"�}�E��J�	���	���C�H�H�K�I��OK��O��XK����������!���s�H6�&I�6H=�(I,�+I,

Zerion Mini Shell 1.0