%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/hplip/fax/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/hplip/fax/__pycache__/cdmfax.cpython-312.pyc

�

=	f�L����ddlmZddlmZddlZddlZddlZddlZddlm	Z	m
Z
mZddlZddl
Z
ddlZddlZddlmcmZddl�ddl�ddl�ddlmZmZmZmZmZddlm
Z
ddl�ddlZddlZddlZddlZddl�ddl Z ddl!Z!dd	lmZmZdd
lm"Z"m
Z
mZm#Z#m$Z$m%Z%ddl&m'Z'ddl Z ddl!Z!ddlZddlZddl(m)Z)d
Z*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3Gd�de4�Z5Gd�de6�Z7y)�)�division)�NONEN)�BytesIO�
to_bytes_utf8�
to_unicode)�*)�device�utils�codes�dime�status)r�)r	r
)�PY3rr�to_string_latin�to_string_utf8�	xStringIO)�http_client)�cupsz/cdm/oauth2/v1/tokenz/cdm/faxModem/v1/configurationz�%s %s HTTP/1.1
Content-Type: application/json
User-Agent: hplip
Accept: */*
Cache-Control: no-cache
Host:%s
Connection: keep-alive
Content-Length: %s

z�%s %s HTTP/1.1
Content-Type: application/json
User-Agent: hplip
Accept: */*
Cache-Control: no-cache
Host:%s
Connection: keep-alive
Content-Length: %s
Authorization: Bearer %s

i�������i�i�c��eZdZdddedfd�Zd�Zd�Zdd�Zd�Zdd�Z	dd	�Z
d
�Zd�Ze
ee�Zd�Zd
�Ze
ee�Zd�Z			dd�Zy)�CDMFaxDeviceNFc���tj||||||�d|_d|_d|_||_||_|jdk(r|j|_	yd|_	y)N��net�	localhost)
�	FaxDevice�__init__�token�send_fax_thread�upload_log_thread�
device_uri�printer_name�bus�host�	http_host)�selfr#r$�callback�fax_type�disable_dbuss      �/usr/share/hplip/fax/cdmfax.pyrzCDMFaxDevice.__init__Rsg��
	���4��'�#�X�'�	)���
�#���!%���$���(����8�8�u��!�Y�Y�D�N�(�D�N�c�2�|jdtk(ryy)Nzwifi-configTF)�mq�WIFI_CONFIG_CDM_AUTH)r(s r,�isAuthRequiredzCDMFaxDevice.isAuthRequiredes���7�7�=�!�%9�9��r-c��tj�}	|j|j|d�|j�y#t$rt
j
d�Y�1wxYw#|j�wxYw)NrzUnable to read LEDM Channel)�ior�readLEDMAllData�readEWS_LEDM�Error�log�debug�	closeLEDM)r(�responses  r,�__flushThePortzCDMFaxDevice.__flushThePortksa���:�:�<��	�� � ��!2�!2�H�a�@�
�N�N����	5��I�I�3�4�	5��
�N�N��s#�A�A%�"A(�$A%�%A(�(A:c��|dk(rt|�}nt|�}|dk(r2|jt|||j||jfz�n&|jt
|||j|fz�|dk7r|j|�t
�}	|j|j|�|jd�tj|�}|j�|j�}|j�}	||	fS#t$r(|j!�t"j%d�YywxYw)NTrzUnable to read EWS_LEDM Channel)�len�
writeEWS_LEDM�REQ_WITH_TOKENr'r �REQ_NO_TOKENr�readLEDMDatar5�seekr�HTTPResponse�begin�getcode�readr6�
closeEWS_LEDMr7r8)
r(�request_type�url�	data_json�	WithToken�
contentLen�replyr:�respcode�datas
          r,�
__usb_reqeustzCDMFaxDevice.__usb_reqeustws$������S��J��Y��J�������~� ,�c�4�>�>�:�t�z�z�Z� [�
\�
���|� ,�c�4�>�>�:�N� O�
P�������y�)����
	9����d�/�/��7��J�J�q�M�"�/�/��6�H��N�N���'�'�)�H��=�=�?�D��T�>�!���	9���� ��I�I�7�8�	9�s�A5D�.E�Ec�z�i}d|d<||d<||d<tj|�}|jdt|�\}}|tk(st
j
d|z�|dfStj|j��}tjtj|��}|d|_|S)N�password�
grant_type�username�POSTz?Request Failed With Response Code %d, enter correct credentialsr�access_token)�json�dumps�_CDMFaxDevice__do_request�CDM_AUTH_REQ�HTTP_OKr7r8�loads�strip�ast�literal_evalr )r(�unamerRrOrNs     r,�getCDMTokenzCDMFaxDevice.getCDMToken�s�����'��\�� ��Z��#��Z���z�z�$����*�*�6�<��F���$��7�"��I�I�Q�T\�\�
^��R�<���:�:�d�j�j�l�+�D��#�#�D�J�J�t�$4�5�D��n�-�D�J��Or-c���	|jdk(r|j||||�\}}||fS|j||||�\}}||fS#tj	d�YyxYw)NrzIO Error�i�r)r%�_CDMFaxDevice__network_reqeust�_CDMFaxDevice__usb_reqeustr7r8)r(rHrIrOrKrNs      r,�__do_requestzCDMFaxDevice.__do_request�sw��
	"��x�x�5� �!%�!7�!7� �#�t�Y�"8���$���~�%�!%�!3�!3� �#�t�Y�"8���$���~�%��	"��I�I�j�!��s�)A�A�A c���ddl}ddl}ddddd�}|j|d<|dk(rd	|jz|d
<	|jj|j|j
���}|dk7r|j||||��n|j|||�
�|j�}	|	j}
|	j�}|
|fS#tjd�YyxYw)Nrzapplication/json�hplipzno-cachez
keep-alive)zContent-Typez
User-Agentz
Cache-Control�
Connection�HostTz	Bearer %s�
Authorization)�context)�methodrI�body�headers)rmrIroz!Error while connecting the devicerc)
�http.client�sslr&r �client�HTTPSConnection�_create_unverified_context�requestr7r8�getresponser
rF)r(rHrIrOrK�httprq�header�
connectionr:rNs           r,�__network_reqeustzCDMFaxDevice.__network_reqeust�s�����"4�G�#-�\�K������v�����&1�D�J�J�&>�F�?�#�	����4�4��	�	�3�#A�#A�#C�5�E�J��t�|��"�"�,�'*��v�#�G��"�"�,�'*�F�#�<��)�)�+���?�?���}�}�����~���	��I�I�9�:��s�A$C�C$c��d}i}i}t|�|d<||d<tj|�}tj	|�	|jdt|d��\}}d}|S#tj	d�Y|SxYw)NF�	faxNumber�analogFaxSetup�PATCHT�rKzSetPhoneNum response is )�strrWrXr7r8rY�CDM_FAX_MODEM_CONF)r(�num�rtnrO�
dataFaxNumrNs      r,�setPhoneNumzCDMFaxDevice.setPhoneNum�s��������
�"%�c�(�
�;��!+��
���z�z�$����	�	�$��	<�!�.�.��+�T�T�/�C�N�H�d��C��
��	<��I�I�0�(�;��
�s�A%�%Bc���	tj|j|j�}tj|�|j
d�jdd�S#YyxYw)Nrzprinter-fax-modem-numberztel:)�cupsext�getFaxModemAttributesr#r$r7�dbg�get�replace�r(�fax_modem_detailss  r,�getPhoneNumzCDMFaxDevice.getPhoneNum�s`��	� '� =� =�����!2�!2�!4���G�G�%�&�"�%�%�&@�A�J�J�6�SU�V�V��	��s�?A"�"A&c���d}i}i}t|�|d<||d<tj|�}	|jdt|d��\}}d}|S#t
j
d�Y|SxYw)NF�companyNamer}r~TrzsetStationName response is )r�rWrXrYr�r7r8)r(�namer�rO�dataComNamerNs      r,�setStationNamezCDMFaxDevice.setStationName�s���������%(��Y��M�"�!,��
���z�z�$���	?�!�.�.��+�T�T�/�C�N�H�d��C��
��	?��I�I�3�X�>��
�s�A�A+c��	tj|j|j�}tj|�|j
d�S#YyxYw)Nrzprinter-fax-modem-name)r�r�r#r$r7r�r�r�s  r,�getStationNamezCDMFaxDevice.getStationName�sR��	� '� =� =�����!2�!2�!4���G�G�%�&�!�$�$�%=�>�>��	��s�?A�Ac�f�tj�}d|d|d|d|d|d|dfz}y)	Nz%4d-%02d-%02dT%02d:%02d:%02drr����T)�time�	localtime)r(�t�date_bufs   r,�setDateAndTimezCDMFaxDevice.setDateAndTimesE���N�N���1�
�a�D�!�A�$��!��a��d�A�a�D�!�A�$�50�0��r-c
���|j�sTt||j|j|j||||||||	�|_|j
j
�yy)NTF)�isSendFaxActive�CDMFaxSendThread�servicer#r$r!�start)
r(�phone_num_list�
fax_file_list�
cover_message�cover_re�
cover_func�preserve_formattingr$�update_queue�event_queues
          r,�	sendFaxeszCDMFaxDevice.sendFaxes
sd���#�#�%�#3�D�$�,�,����Y]�Yj�Yj�4B�M�4A�8�Z�4G�4@�4?�$A�D� �
� � �&�&�(��r-)NF)rrNFrNN)�__name__�
__module__�__qualname__�
FAX_TYPE_NONErr1�_CDMFaxDevice__flushThePortrerarYrdr�r��property�	phone_numr�r��station_namer�r��r-r,rrPs{��"&�T��'�#�)�&�	�9�<�&��6� W���k�2�I�� ?��N�N�;�L��SU�KM�15�r-rc��eZdZ		dd�Zd�Zy)r�Nc
���tj||||||||	|
|||�||_||_|jdk(rd|j
jz|_nd|_t|�y)Nrz%s:8080zlocalhost:8080)	�
FaxSendThreadrr#r$r%�devr&r'�print)
r(r�r�r#r$r�r�r�r�r�r�r�r�s
             r,rzCDMFaxSendThread.__init__#sn��	���t�S�'�>�=�,�h�
�DW�+�\�;�	H�%���(����7�7�e��&������6�D�N�-�D�N�
�m�r-c��d}d}d}d}d}d}d}d}d	}	d
}
d}d}
d
}d}
d}|j�}|}t}g|_d}||k7�r�|j�r|}tjd|z�||k(r1tj
d�|jtddf�|
}�n/||k(r1tjd�|jtddf�|
}�n�||k(r-tj
d�|j|ddf�|
}�n�||k(r1tj
d�|jtddf�|
}�n�||k(r�tjddz�	|jj|_
tjd|jz�|jj|_tjd|jz�|}�n�||k(r+tjddz�|j#|�}�n�||k(rJtjddz�|jdd|_t'|j(�|_|}�nv||k(rmtjddz�|	}	t-|�}tjd|dz�|jt.d|df�|jdd}�n||	k(r+tjd!dz�|j3�}�n�||
k(rJtjd"dz�|j5|�}tj
|j6��n�||k(r+tjd#dz�|j5|�}�nU||k(�r�tjd$dz�|}d}d}d}d}d}d}d}d}d	}d
}d%}d&} |}!|!|k7�r|j�rtj
d'�|}!tjd(||!fz�|!|k(rd&} |}!|}�n=|!|k(rtj
d)�d&} |}!|}�n|!|k(rtj
d*�d&} |}!|}n�|!|k(rtjd+�d&} |}!|}n�|!|k(rtjd,dz�|}!n�|!|k(r>d-}"t9j:|j<|j>|j6|"�}#|}!nv|!|k(r|}!nn|!|k(r5tjd.dz�#dkDrtAjB|#�|}!n4|!|k(r/tjd/dz�tjd0�|}!|!|k7r���n�||
k(r}tjd1dz�|jDrWtjd2|j6z�	tGjH|j6�tjd3�|}||k7r���yy#t $rtj
d�|}Y��%wxYw#t0$r|}tjd �Y���wxYw#tJ$rtjd4�Y�ywxYw)5Nr�
����(�2�<�F�P�Z�d�n�x�zSTATE=(%d, 0, 0)zAborted by user.rzSuccess.zError, aborting.zDevice busy, aborting.z%s State: Get sender infoz********************zSender name=%sz
Sender fax=%szCDM ipp request failed!z!%s State: Pre-render non-G4 filesz%s State: Get total page countz%s State: Next recipientzProcessing for recipient %sr�zLast recipient.z%s State: Render cover pagez%s State: Handle single filez%s State: Merge multiple filesz%s State: Send fax�FzFax send aborted.zSTATE=(%d, %d, 0)zFax send error.zFax device busy.zFax send success.z%s State: Open device�faxz%s State: CancelJobz%s State: Close sessionzClosing session...z%s State: CleanupzRemoving merged file: %s�Removedz	Not found)&�next_recipient_gen�STATUS_ERROR�rendered_file_list�check_for_cancelr7r8�error�write_queue�STATUS_IDLE�STATUS_COMPLETED�STATUS_BUSYr�r��sender_namer��
sender_faxr6�
pre_render�recipient_file_listr=r��job_total_pages�next�STATUS_SENDING_TO_RECIPIENT�
StopIteration�
cover_page�merge_cdm_fax_files�fr��
sendFaxOutJobr#r$r�	cancelJob�remove_temp_file�os�remove�OSError)$r(�
STATE_DONE�
STATE_ABORTED�
STATE_SUCCESS�
STATE_BUSY�STATE_READ_SENDER_INFO�STATE_PRERENDER�STATE_COUNT_PAGES�STATE_NEXT_RECIPIENT�STATE_COVER_PAGE�STATE_SINGLE_FILE�STATE_MERGE_FILES�STATE_SEND_FAX�
STATE_CLEANUP�STATE_ERROR�next_recipient�state�error_state�	num_tries�	recipientr��FAX_SEND_STATE_DONE�FAX_SEND_STATE_ABORT�FAX_SEND_STATE_ERROR�FAX_SEND_STATE_BUSY�FAX_SEND_STATE_SUCCESS�FAX_SEND_STATE_DEVICE_OPEN�FAX_SEND_STATE_BEGINJOB�FAX_SEND_STATE_DOWNLOADPAGES�FAX_SEND_STATE_ENDJOB�FAX_SEND_STATE_CANCELJOB�FAX_SEND_STATE_CLOSE_SESSION�
monitor_state�fax_send_state�faxnum�aJobIDs$                                    r,�runzCDMFaxSendThread.run3s5���
��
��
��
�!#������!�������������
����0�0�2��&��"��"$����	��z�!��$�$�&�%���I�I�(�5�0�1��
�%��	�	�,�-�� � �+�q�"�!5�6�%���-�'��	�	�*�%�� � �"2�A�r�!:�;�%���+�%��	�	�,�-�� � �+�q�"�!5�6�%���*�$��	�	�2�3�� � �+�q�"�!5�6�%���0�0��	�	�5��@�A�(�'+�x�x�'<�'<�D�$��I�I�.��1A�1A�A�B�&*�h�h�&8�&8�D�O��I�I�o����?�@�(���/�)��	�	�=��H�I����(9�:���+�+��	�	�:�f�E�F�+/�+B�+B�1�+E��(�'*�4�+=�+=�'>��$�,���.�.��	�	�4��?�@�(��� $�^� 4�I��I�I�;�i��>O�O�P��$�$�&A�1�i�PV�FW�%X�Y�'+�&=�&=�a�&@�#��*�*��	�	�7�6�B�C����	�2���+�+��	�	�8�F�C�D��0�0��@���	�	�$�&�&�!��+�+��	�	�:�f�E�F��0�0��@���.�(��	�	�.�&�9�:�,��&'�#�')�$�')�$�&(�#�)+�&�-/�*�*,�'�/1�,�(*�%�+-�(�/2�,� %�
�!;��$�(;�;��,�,�.��	�	�"5�6�)=���I�I�1�^�^�4T�T�U�%�)=�=�(-�
�)A�� -��'�+?�?��	�	�"3�4�(-�
�)E�� +��'�+>�>��	�	�"4�5�(-�
�)E�� *��'�+A�A��	�	�"5�6�(-�
�)E�� 4��'�+E�E��	�	�"9�V�"D�E�)@��'�+B�B�!*�5�!1��!(�!6�!6�t���t�GX�GX�Y]�Y_�Y_�`f�!g��)>��'�+@�@�)?��'�+C�C��	�	�"7�6�"B�C�!�A�:��>�>�&�1�)E��'�+G�G��	�	�";�v�"F�G��	�	�"6�7�)<��k%�(;�;�n�-�'��	�	�-��8�9��(�(��I�I�8�4�6�6�A�B�/��	�	�$�&�&�)��	�	�)�,�#��U�z�!��L�(��I�I�7�8�'�E�(��0%��)�E��I�I�/�0����R#�/��	�	�+�.�/�s8�"A:W�?AX�4X,� X�X� X)�(X)�,Y
�Y
)rrNFNN)r�r�r�rr
r�r-r,r�r�"s��UZ�04�� C#r-r�)8�
__future__r�picklerr��sysr�r��base.sixextrrr�re�	threading�struct�xml.parsers.expat�parsers�expat�stat�base.g�
base.codes�baser	r
rrr
r�r3�binascii�xml�stringrWr^rrrr�base.sixext.movesr�prntrrZr�r@r?�HTTP_UNAUTHORIZEDr[�
HTTP_ACCEPTED�HTTP_CREATED�
HTTP_ERROR�HTTP_SERVICE_UNAVALIABLErrr�r�r�r-r,�<module>r#s���, ����	��:�:�	��
��!�!����3�3�%���	�����
��b�b�)��
�
���&��5��H��f����

���
���
�
���M�9�M�dT#�}�T#r-

Zerion Mini Shell 1.0