%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__/authconn.cpython-312.pyc

�

HffK���ddlZddlZddlZddlZddlZddlmZejdd�ddlmZejdd�ddlm	Z	ddl
Z
ddl�ddl�ddl
Z
e
jejej �	�d
�Zej$d�Gd�d
e	j&�ZGd�d�Ze�ZGd�d�Zedk(ryej2�ddlmZed�eed��j;�Zed�ejAd�e!eejDd��j;��yy)�N)�GLib�Gdkz3.0)r�Gtk)r)�*)�domain�	localedirc��|S�N�)�xs �,/usr/share/system-config-printer/authconn.py�<lambda>r#s��q��z1.9.60c��eZdZed�ed�ed�d�Zddejjejejjejejjfddfd�Z
d�Zd	�Zd
�Zd�Zd�Zy)
�
AuthDialogz	Username:z	Password:zDomain:)�username�passwordrNFc	�$�|�td�}|�ddg}tjj|||||�||_|jtjj�|jd�|jd�tjjdd�}|jd�tj�}|jtjtjj �|j#dd�|j%|ddd�tj&jdd�}	tj(�|_|	j%|j*ddd�t-|�}
tj.�}|j1|
�|j3d	�|j5d�|j7d�g|_t;|
�D]�}||}
tj(t|j<j?|
|
���
�}|j#dd�|jA|d|dd�tjB�}|jE|
dk7�|jA|d|dd�|j8jG|���|j8|
dz
jId
�|	j%|ddd�|j%|	ddd�|jJj%|ddd�|rTtjLjOtd��}|jQd�|	j%|ddd�||_)|jJjU�y)N�Authenticationrr�F�gr�)�labelg�?�TzRemember password)+�_r�Dialog�__init__�auth_info_required�set_default_response�ResponseType�OK�set_border_width�
set_resizable�HBox�new�Image�set_from_stock�STOCK_DIALOG_AUTHENTICATION�IconSize�DIALOG�
set_alignment�
pack_start�VBox�Label�prompt_label�len�Grid�
insert_row�
insert_column�set_row_spacing�set_column_spacing�field_entry�range�
AUTH_FIELD�get�attach�Entry�set_visibility�append�set_activates_default�vbox�CheckButton�new_with_label�
set_active�remember_checkbox�show_all)�self�title�parent�flags�buttonsr�allow_remember�hbox�imager?�
num_fields�grid�i�fieldr�entry�cbs                 r
rzAuthDialog.__init__+s����=��&�'�E��%�",�j�!9���
�
���T�5�&�%��A�"4����!�!�3�#3�#3�#6�#6�7����q�!����E�"��x�x�|�|�U�B�'�����q�!��	�	���
���c�=�=�!�l�l�1�1�	3�
���S�#�&������u�a�0��x�x�|�|�U�B�'���I�I�L�������*�*�E�5�!�<��,�-�
��x�x�z�����
�#����1�����a� �����#�����
�#�	,�A�&�q�)�E��I�I�Q�t���':�':�E�5�'I�%J�K�E�����C�(��K�K���1�a��+��I�I�L�E�� � �%�:�"5�6��K�K���1�a��+����#�#�U�+�	,�	
����a��(�>�>��E�����u�e�Q�/�����u�e�Q�/��	�	���d�E�5�!�4�����/�/��3F�1G�H�B��M�M�5�!��O�O�R���q�1�%'�D�"��	�	���rc���|jjd|zdz�|jjd�|jjdd�|jj	d�y)N�"<span weight="bold" size="larger">z</span>Tr)r/�
set_markup�set_use_markupr+�
set_line_wrap�rE�prompts  r
�
set_promptzAuthDialog.set_promptdsg�����$�$�&J�&,�'-�/8�'9�	:����(�(�$�/����'�'��A�.����'�'��.rc��tt|j��D]#}|j|j||��%yr
)r7r0r6�set_text)rE�	auth_inforOs   r
�
set_auth_infozAuthDialog.set_auth_infoks>����T�-�-�.�/�	8�A����Q��(�(�)�A�,�7�	8rc�\�|jD�cgc]}|j���c}Scc}wr
)r6�get_text)rErs  r
�
get_auth_infozAuthDialog.get_auth_infoos"��'+�'7�'7�8�!��
�
�
�8�8��8s�)c�V�	|jj�S#t$rYywxYw)NF)rC�
get_active�AttributeError�rEs r
�get_remember_passwordz AuthDialog.get_remember_passwordrs.��	��)�)�4�4�7�7���	��	�s��	(�(c�t�|jj|�}|j|j�yr
)r�indexr6�
grab_focus)rErPrOs   r
�field_grab_focuszAuthDialog.field_grab_focusxs/���#�#�)�)�5�1�������&�&�)r)�__name__�
__module__�__qualname__�N_r8r�DialogFlags�MODAL�STOCK_CANCELr �CANCEL�STOCK_OKr!rrZr^rarfrjrrr
rr&s����{�O��{�O��Y�-�)�J�#�4����-�-��+�+�S�-=�-=�-D�-D��<�<��)9�)9�)<�)<�>�%)�!&�7�r/�8�9��*rrc�*�eZdZd�Zdd�Zdd�Zdd�Zy)�_AuthInfoCachec�"�t�|_yr
)�dict�credsres r
rz_AuthInfoCache.__init__�s���V��
rNc�.�|�d}||j||f<y�Niw)rx)rE�data�host�ports    r
�cache_auth_infoz_AuthInfoCache.cache_auth_info�s���<��D�"&��
�
�D��;�rc�L�|�d}	|j||fS#t$rYywxYwrz�rx�KeyError�rEr|r}s   r
�lookup_auth_infoz_AuthInfoCache.lookup_auth_info�s6���<��D�	��:�:�t�D�k�*�*���	��	�s��	#�#c�J�|�d}	|j||f=y#t$rYywxYwrzr�r�s   r
�remove_auth_infoz_AuthInfoCache.remove_auth_info�s3���<��D�	��
�
�D��;�'���	��	�s��	"�")NN)rkrlrmrr~r�r�rrr
rurus���'��rruc��eZdZ		dd�Zd�Zd�Zd�Zd�Zd�Zdd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�
ConnectionNc��|�tj|�|�tj|�|�tj|�d|_||_||_tj�|_tj�|_
tj�|_tj�|_d|_g|_||_t%j&�|_|j+�y)N�T)�cups�	setServer�setPort�
setEncryption�
_use_password�_parent�_try_as_root�getUser�	_use_user�	getServer�_server�getPort�_port�
getEncryption�_encryption�_prompt_allowed�_operation_stack�_lock�	threading�Event�
_gui_event�_connect)rErG�try_as_root�lockr|r}�
encryptions       r
rzConnection.__init__�s������N�N�D�!����L�L�$���!����
�+�������'����������~�~�(����\�\�^��
��-�-�0���#��� "�����
�#�/�/�,����
�
�rc�Z�t|�d|���|jj|�y)Nz: Operation += )�
debugprintr�r=)rE�	operations  r
�_begin_operationzConnection._begin_operation�s#���T�9�=�>����$�$�i�0rc�T�td|z�|jj�y)Nz%s: Operation ended)r�r��popres r
�_end_operationzConnection._end_operation�s"���)�D�0�1����!�!�$rc��|jSr
�r�res r
�_get_prompt_allowedzConnection._get_prompt_allowed�s���#�#�#rc��||_yr
r�)rE�alloweds  r
�_set_prompt_allowedzConnection._set_prompt_allowed�s
��&��rc��||_yr
)r�)rE�whethers  r
�	_set_lockzConnection._set_lock�s	����
rc	�~�tj|j�|xr<|jddk(xs|jdk(xrt	j
�dk7|_|jrtj}ntj}||j|j|j��|_|jr%|jj|j�|j|_td|jz�t!|jj"�}t!|jj$�}t'|j�D]N}|ddk(r�t)|j|�}t!|�||fvr�2t+|||j-||���Py)Nr�/�	localhost)r|r}r�zConnected as user %sr)r��setUserr�r��os�getuid�_use_pk�cupspkr�r�r��_connection�
set_parentr��_userr��type�getPrinters�
addPrinter�dir�getattr�setattr�
_make_binding)rE�allow_pk�
create_object�methodtype_lambda�methodtype_real�fname�fns       r
r�zConnection._connect�sh�����d�n�n�%� �.����a��C�/�N�4�<�<�;�3N�.��I�I�L�A�-�	
���<�<�"�-�-�M� �O�O�M�(�t�|�|�15���7;�7G�7G�I����<�<����'�'����5��^�^��
��*�T�Z�Z�7�8� �$�"2�"2�">�">�?���� 0� 0� ;� ;�<���$�*�*�+�	B�E��Q�x�3����$�*�*�E�2�B���9�!2�O� D�D���T�5�$�"4�"4�e�R�"@�A�
	Brc�J�t|jtj�Sr
)�
isinstancer�r�r�res r
�
_using_polkitzConnection._using_polkit�s���4�+�+�V�->�->�?�?rc��������fd�S)Nc�2���j��g|��i|��Sr
)�	_authloop)�args�kwdsr�r�rEs  ���r
rz*Connection._make_binding.<locals>.<lambda>�s���^�T�^�^�U�B�%N��%N��%N�rr)rEr�r�s```r
r�zConnection._make_binding�s	���N�Nrc��d|_|j�s|jdd�|j}d}		|j	�dk(r	S||jk7r"t|j|�}|j}t
j|j�|j|i|��}|dk(r)|ik(r$t
jtjd��	|S#tj$�r}|j\}}	|jr$|	dk(rt
jdtd���|js]|tjk(s&|tj k(s|tj"k(r$|j%|tj k(��nR|js�|tj&k(r�t)d	�t)|	�|j*rV|j,j/�t1j2d
|j4|	�|j,j7�n|j5|	�|j8t:j<j>k(r*t)d�d}|xjd
zc_d|_ nYd|_�|jr+|jBst
jdtd���t)|�dtE|	�����Yd}~nad}~wtjF$rH}|j\}
|js#|j%|
tjHk(�n�Yd}~nd}~wwxYw�� )
Nr�	signatureFT�adminGetServerSettingsr��pkcancelzOperation canceledzGot IPP_SERVICE_UNAVAILABLErzretrying operation...z: )%�_passesr�r�r��_perform_authenticationr�r�r�r��__call__�IPPError�IPP_NOT_AUTHORIZEDr�r�r�_cancel�
IPP_FORBIDDEN�IPP_AUTHENTICATION_CANCELED�_failed�IPP_SERVICE_UNAVAILABLEr�r�r��clearr�timeout_add�_ask_retry_server_error�wait�_retry_responserr r!�_has_failed�_cannot_auth�repr�	HTTPError�HTTP_FORBIDDEN)rEr�r�r�r��c�retry�result�e�m�ss           r
r�zConnection._authloop�s�������!�!�#��H�H�[�$�'��������9
��/�/�2�a�7��r�
�o��(�(�(� �$�"2�"2�E�:�B��(�(�A����d�n�n�-�$����t�4�t�4���4�4���|�"�m�m�T�-D�-D�b�I�I��R�
��Q�=�=� 
������A��<�<�A��O��-�-��A�.B�,C�D�D��|�|��d�.E�.E�)E�)*�d�.@�.@�)@�)*�d�.N�.N�)N��L�L�!�t�'9�'9�"9�:����!�t�/K�/K�*K�� =�>���N��z�z����-�-�0��(�(�!�T�-I�-I�1�M����,�,�/��4�4�a�8��+�+�s�/?�/?�/B�/B�B�"�$;�<� $������)��+/��(�'+�����|�|�D�,=�,=�"�m�m�Q��2F�0G�H�H��A�t�Q�x� 8�9�����>�>�
��v�v����|�|��L�L�!�t�':�':�":�;��<��
��ks+�C#�BC#�#M�7G:K6�6M�>M�Mc�b�|jrtj�	td�|jdz}t
j|jddtjjtjj|��}|jtd�|z�|jtjtj j"td�tj j$�|j'tj j$�|jr1|j)d|j*�tj,�y|j/�|_|j3�y#t
$rtd�}Y��pwxYw)	NzCUPS server error (%s)rzCUPS server errorT)�
transient_for�modal�destroy_with_parent�message_typerI�textz3There was an error during the CUPS operation: '%s'.�Retry�response)r�r�
threads_enterrr��
IndexErrorr�
MessageDialogr��MessageType�ERROR�ButtonsType�NONE�format_secondary_text�add_buttonsrqr rrr!r�connect�_on_retry_server_error_response�
threads_leave�runr��destroy)rE�message�msg�ds    r
r�z"Connection._ask_retry_server_error0s@���:�:���� �	)��-�.��1F�1F�q�1I�I�C�
���T�\�\�%)�t�,/�O�O�,A�,A�'*���';�';�$'�	
)��	
����$;�"<�>E�"F�	G�	�
�
�s�'�'��)9�)9�)@�)@���z�3�#3�#3�#6�#6�	8�	���� 0� 0� 3� 3�4��:�:�
�I�I�z�4�#G�#G�H���� �#$�5�5�8�D� �
�I�I�L��'�	)��'�(�C�	)�s�F�F.�-F.c�f�||_|j�|jj�yr
)r�rr��set�rE�dialogr�s   r
rz*Connection._on_retry_server_error_responseKs$��'������������rc� �d|_||_y)NT)r��
_forbidden)rE�	forbiddens  r
r�zConnection._failedPs�����#��rc�~�td�|js|jryd|_||_|jS)NzGot password callbackr�T)r�r��_auth_called�_promptr�rXs  r
�_password_callbackzConnection._password_callbackTs8���+�,��<�<�4�,�,�� �������!�!�!rc��|xjdz
c_tj|j|j��}|�$|ddk7s|j
r|\|_|_~td|jz�|jdk(rUd|_	d|_
d|_d|_d|_
d|_tj |j"�td�ytd|jz�|jstd	�yd|_	|jd
k\rf|j
rZ|j$dk7rK|jddk(s|jr-td�d|_d|_	|j'd�
�y|j.std�d|_y|jstd�d|_d|_
yd|_|jrq|j0rU|j2j5�t7j8d|j:�|j2j=�n|j;�|j0rU|j2j5�t7j8d|j>�|j2j=�n|j?�|jrtd�ytj@|j�td�	|j'd�
�y#t($r%tj*tj,d��wxYw#t($r%tj*tj,d��wxYw)Nr�r|r}r�rootzAuthentication pass: %dFz%Authentication: password callback setz
Forbidden: %sz$Authentication: Operation successfulrr�zAuthentication: Try as root)r�z server-error-service-unavailablez%Authentication: prompting not allowedTzAuthentication: giving up�	cancelled���zAuthentication: Reconnect)!r��global_authinfocacher�r�r�r�r�r�r�r�rrr�r��
_dialog_shownr��
setPasswordCBrr�r��RuntimeErrorr�r�r�r�r�r�rr��_show_not_authorized_dialogr��#_perform_authentication_with_dialogr�)rErxs  r
r�z"Connection._perform_authentication]s���������$�5�5�D�L�L�t�z�z�5�Z�����a��F�"�d�&7�&7�7<�4����!3���-����<�=��<�<�1�� %�D��#�D�O� %�D�� �D�L� %�D��!&�D������ 7� 7�8��?�@���O�d�o�o�5�6����
�>�?��!����<�<�1���!�!��
�
�f�$����a��C�'�4�?�?��9�:�!'���$)��!�M��M�M�E�M�2�
��#�#��?�@��D�L��� � ��3�4��D�L� $�D���"�������z�z����%�%�(�� � �!�T�%E�%E�F����$�$�'��0�0�3��:�:��O�O�!�!�$����a��!I�!I�J��O�O� � �#��4�4�7��<�<���$�����d�n�n�%��/�0�	E��M�M�E�M�*�
��c$�M��-�-��)E�)E�)K�M�M�M��Z�	E��-�-��!=�!=�!C�E�
E�	E�s�<L�M�.M
�.M>c�r�|jrtj�tj|j
ddtjjtjj��}|jtd��|jdtd�zdztd�z�|jrQ|jd|j�|j�|j!�tj"�y|j%�|j'�y)NT)r�r�r�r�rIzNot authorizedrTz	</span>

zThe password may be incorrect.r�)r�rr�rr�r�r�r�r��CLOSE�	set_titlerrUr�"_on_not_authorized_dialog_responserD�show_nowrrr)rEr	s  r
rz&Connection._show_not_authorized_dialog�s����:�:���� ����T�\�\�%)�t�,/�O�O�,A�,A�'*���'<�'<�
>��	
���Q�'�(�)�	���:��(�)�*�,9�:��8�9�:�	;��:�:�
�I�I�z�4�#J�#J�K�
�J�J�M�
�J�J�M���� �
�E�E�H�
�I�I�Lrc�X�|jj�|j�yr
)r�rrrs   r
r#z-Connection._on_not_authorized_dialog_response�s�����������rc���|jrtj�t|j�dkDr4	td�|jdz}t||j��}nt|j��}|jd�|jddg�|jd�|jd�|j�|j�d|_|jr1|j!d	|j"�tj$�y|j'�}|j#||�y#t$rtd�}Y��wxYw)
NrzAuthentication (%s)r)rFrG)rGr�rTr�)r�rr�r0r�rr�rr�rZr^rj�set_keep_aboverDr$rr�_on_authentication_responserr)rErFr	r�s    r
rz.Connection._perform_authentication_with_dialog�s���:�:���� ���%�%�&��*�
,��0�1�D�4I�4I�!�4L�L���%�#'�<�<�1�A��4�<�<�0�A�	���b��	���"�b��"�	���J�'�	���$��	�
�
�
�	�
�
�
�!����:�:�
�I�I�z�4�#C�#C�D���� ��u�u�x�H��,�,�a��:��)�
,��*�+��
,�s�E�E(�'E(c��|j�\}|_|dk7r||_tj	|j|jf|j
|j��|j�|tjjk(s|tjjk(rd|_|jr|jj�yy)Nr�rT)rar�r�rr~r�r�rrr rr�DELETE_EVENTr�r�r�r)rEr
r��users    r
r(z&Connection._on_authentication_response�s���%+�%9�%9�%<�"��t�!��2�:�!�D�N��,�,�t�~�~�/3�/A�/A�/C�37�<�<�37�:�:�	-�	?�	������(�(�/�/�/���(�(�5�5�5��D�L��:�:��O�O���"�r)NTFNNN)T)F)rkrlrmrr�r�r�r�r�r�r�r�r�r�rr�rr�rr#rr(rrr
r�r��sn��<A�37��.1�%�$�'��B�<@�O�D�L�6�
$�"�d�L�(�;�<#rr��__main__)�TimedOperationTr
)r��	Connected)z/admin/conf/cupsd.confz/dev/stdout)#r��configr�r��gi�
gi.repositoryr�require_versionrrr��errordialogs�debug�gettext�install�PACKAGErrn�requirerrrurr�rk�threads_init�timedopsr-�
set_debuggingrr�r�r��print�getFilerrr
�<module>r>s#��(�
��
�	������5�%� ������5�%� ��	��������v�~�~��1A�1A�B�������X��T*����T*�r��8&�(��k#�k#�Z�z���C����'��4���
��1�5�5�8�A�����K�K���	�.�!�)�)� /�0�03���8�r

Zerion Mini Shell 1.0