§
    cÌc5d  ã                   óL  — d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlZddlm	Z
mZmZmZmZmZmZ  G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d	„ d
ej        ¦  «        Z G d„ d¦  «        Z ej        eee         f         ¦   «         Z G d„ de¦  «        Ze                     deej        ¬¦  «          G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Ze                     deej        ¬¦  «          G d„ de¦  «        Ze                     deej        ¬¦  «          G d„ de¦  «        Z e                     de e j        ¬¦  «          G d„ de¦  «        Z!e                     d e!e!j        ¬¦  «          G d!„ d"e¦  «        Z"e                     d#e"e"j        ¬¦  «          G d$„ d%e¦  «        Z#e                     d&e#e#j        ¬¦  «          G d'„ d(e¦  «        Z$e                     d)e$e$j        ¬¦  «          G d*„ d+e¦  «        Z%e                     d,e%e%j        ¬¦  «          G d-„ d.e¦  «        Z&e                     d/e&e&j        ¬¦  «          G d0„ d1e¦  «        Z'e                     d2e'e'j        ¬¦  «         d2e_(         e
j)        d3ed4d5¬6¦  «        Z*dS )7é    N)ÚTypeé   )ÚconfigÚemail_messageÚerrorsÚ	msgeditorÚosutilsÚurlutilsÚregistryc                   ó   — e Zd ZdZd„ ZdS )ÚMailClientNotFoundzQUnable to find mail client with the following names: %(mail_command_list_string)sc                 ót   — d                      |¦  «        }t          j                             | ||¬¦  «         d S )Nz, )Úmail_command_listÚmail_command_list_string)Újoinr   ÚBzrErrorÚ__init__)Úselfr   r   s      ú4/usr/lib/python3/dist-packages/breezy/mail_client.pyr   zMailClientNotFound.__init__(   sG   € Ø#'§9¢9Ð->Ñ#?Ô#?Ð ÝŒ× Ò ØÐ$5Ø%=ð 	!ñ 	?ô 	?ð 	?ð 	?ð 	?ó    N)Ú__name__Ú
__module__Ú__qualname__Ú_fmtr   © r   r   r   r   #   s*   € € € € € ð(€Dð?ð ?ð ?ð ?ð ?r   r   c                   ó   — e Zd ZdZdS )ÚNoMessageSuppliedzNo message supplied.N©r   r   r   r   r   r   r   r   r   /   s   € € € € € à!€D€D€Dr   r   c                   ó   — e Zd ZdZdS )ÚNoMailAddressSpecifiedz8No mail-to address (--mail-to) or output (-o) specified.Nr   r   r   r   r    r    4   s   € € € € € àE€D€D€Dr   r    c                   ó4   — e Zd ZdZd„ Z	 dd„Z	 	 dd„Zd„ ZdS )Ú
MailClientz7A mail client that can send messages with attachements.c                 ó   — || _         d S ©N)r   )r   r   s     r   r   zMailClient.__init__<   s   € ØˆŒˆˆr   Nc	                 ó   — t           ‚)a  Compose (and possibly send) an email message

        Must be implemented by subclasses.

        :param prompt: A message to tell the user what to do.  Supported by
            the Editor client, but ignored by others
        :param to: The address to send the message to
        :param subject: The contents of the subject line
        :param attachment: An email attachment, as a bytestring
        :param mime_subtype: The attachment is assumed to be a subtype of
            Text.  This allows the precise subtype to be specified, e.g.
            "plain", "x-patch", etc.
        :param extension: The file extension associated with the attachment
            type, e.g. ".patch"
        :param basename: The name to use for the attachment, e.g.
            "send-nick-3252"
        ©ÚNotImplementedError©	r   ÚpromptÚtoÚsubjectÚ
attachmentÚmime_subtypeÚ	extensionÚbasenameÚbodys	            r   ÚcomposezMailClient.compose?   s
   € õ& "Ð!r   c           
      ón   — |                       d|||¦  «        }|                      ||||dd||¦  «         dS )as  Compose (and possibly send) a merge request

        :param to: The address to send the request to
        :param subject: The subject line to use for the request
        :param directive: A merge directive representing the merge request, as
            a bytestring.
        :param basename: The name to use for the attachment, e.g.
            "send-nick-3252"
        zPlease describe these changes:zx-patchz.patchN)Ú_get_merge_promptr1   )r   r*   r+   Ú	directiver/   r0   r)   s          r   Úcompose_merge_requestz MailClient.compose_merge_requestT   sT   € ð ×'Ò'Ð(HÈ"Ø(/°ñ<ô <ˆà�Š�V˜R ¨)Ø ¨(°Dñ	:ô 	:ð 	:ð 	:ð 	:r   c                 ó   — dS )a"  Generate a prompt string.  Overridden by Editor.

        :param prompt: A string suggesting what user should do
        :param to: The address the mail will be sent to
        :param subject: The subject line of the mail
        :param attachment: The attachment that will be used
        Ú r   ©r   r)   r*   r+   r,   s        r   r3   zMailClient._get_merge_promptd   s	   € ð ˆrr   ©NN)r   r   r   Ú__doc__r   r1   r5   r3   r   r   r   r"   r"   9   so   € € € € € ØAÐAðð ð ð 04ð"ð "ð "ð "ð* FJØ#'ð:ð :ð :ð :ð ð ð ð ð r   r"   c                   ó&   — e Zd ZdZdZd„ Z	 dd„ZdS )ÚEditorz/DIY mail client that uses commit message editorTc           
      óD   — |›d|›d|›d|                      dd¦  «        ›�S )z See MailClient._get_merge_promptz

To: z

Subject: z

zutf-8Úreplace)Údecoder8   s        r   r3   zEditor._get_merge_promptw   s9   € ð
 ˜˜    G G GØ#×*Ò*¨7°IÑ>Ô>Ð>ð	@ð 	Ar   Nc	           	      ó   — |st          ¦   «         ‚t          j        ||¬¦  «        }|dk    rt          ¦   «         ‚t          j                             | j        | j                             d¦  «        |||||¬¦  «         dS )úSee MailClient.compose)Ústart_messager7   Úemail)Úattachment_mime_subtypeN)	r    r   Úedit_commit_messager   r   ÚEmailMessageÚsendr   Úgetr(   s	            r   r1   zEditor.compose   s•   € ð ð 	+Ý(Ñ*Ô*Ð*ÝÔ,¨VÀ4ÐHÑHÔHˆØ�2Š:ˆ:Ý#Ñ%Ô%Ð%ÝÔ"×'Ò'¨¬Ø(,¬¯ª¸Ñ(@Ô(@Ø(*Ø(/Ø(,Ø(2Ø@Lð 	(ñ 	Nô 	Nð 	Nð 	Nð 	Nr   r9   )r   r   r   r:   Úsupports_bodyr3   r1   r   r   r   r<   r<   r   sO   € € € € € ØC€Gà€MðAð Að Að 04ðNð Nð Nð Nð Nð Nr   r<   Úeditor)Úhelpc                   ó>   — e Zd ZdZd„ Z	 d	d„Z	 d	d„Zd„ Zd„ Zd„ Z	dS )
ÚBodyExternalMailClientTc                 ó`   ‡— t           j        dk    rddlŠˆfd„| j        D ¦   «         S | j        S )z:Provide a list of commands that may invoke the mail clientÚwin32r   Nc                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS r   )Úget_app_path)Ú.0ÚiÚ
win32utilss     €r   ú
<listcomp>z?BodyExternalMailClient._get_client_commands.<locals>.<listcomp>œ   s'   ø€ ÐNÐNÐN°1�J×+Ò+¨AÑ.Ô.ÐNÐNÐNr   )ÚsysÚplatformrT   Ú_client_commands)r   rT   s    @r   Ú_get_client_commandsz+BodyExternalMailClient._get_client_commands˜   sB   ø€ åŒ<˜7Ò"Ð"ØÐÐÐØNÐNÐNÐN¸Ô8MÐNÑNÔNÐNàÔ(Ð(r   Nc	                 ó  — |€d}t          j        d¬¦  «        }	t          j        |	||z   ¦  «        }
t	          |
d¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   |�d|i}ni } | j        ||||
||fi |¤Ž dS )zfSee MailClient.compose.

        Writes the attachment to a temporary file, invokes _compose.
        Nr,   z	bzr-mail-)ÚprefixÚwbr0   )ÚtempfileÚmkdtempr	   ÚpathjoinÚopenÚwriteÚ_compose)r   r)   r*   r+   r,   r-   r.   r/   r0   ÚpathnameÚattach_pathÚoutfileÚkwargss                r   r1   zBodyExternalMailClient.compose    sý   € ð ÐØ#ˆHÝÔ#¨;Ð7Ñ7Ô7ˆÝÔ& x°¸IÑ1EÑFÔFˆÝ�+˜tÑ$Ô$ð 	&¨Ø�MŠM˜*Ñ%Ô%Ð%ð	&ð 	&ð 	&ñ 	&ô 	&ð 	&ð 	&ð 	&ð 	&ð 	&ð 	&øøøð 	&ð 	&ð 	&ð 	&àÐØ˜d�^ˆFˆFàˆFØˆŒ�f˜b '¨;¸Øð	+ð 	+Ø#)ð	+ð 	+ð 	+ð 	+ð 	+s   ÁA$Á$A(Á+A(c	                 ót  — |                       ¦   «         D ]�}	|                      |	d¦  «        g}
|�d|i}ni }|�||d<   |
                      | j        |||fi |¤Ž¦  «         	 t	          j        |
¦  «          dS # t          $ r }|j        t          j        k    r‚ Y d}~Œ‰d}~ww xY wt          | j
        ¦  «        ‚)aM  Invoke a mail client as a commandline process.

        Overridden by MAPIClient.
        :param to: The address to send the mail to
        :param subject: The subject line for the mail
        :param pathname: The path to the attachment
        :param mime_subtype: The attachment is assumed to have a major type of
            "text", but the precise subtype can be specified here
        :param extension: A file extension (including period) associated with
            the attachment type.
        :param body: Optional body text.
        :param from_: Optional From: header.
        Ú
executableNr0   Úfrom_)rY   Ú_encode_pathÚextendÚ_get_compose_commandlineÚ
subprocessÚcallÚOSErrorÚerrnoÚENOENTr   rX   )r   r)   r*   r+   rd   r-   r.   r0   ri   ÚnameÚcmdlinerf   Úes                r   rb   zBodyExternalMailClient._compose³   s  € ð ×-Ò-Ñ/Ô/ð 	<ð 	<ˆDØ×(Ò(¨¨|Ñ<Ô<Ð=ˆGØÐØ  $˜��à�ØÐ Ø"'��w‘Ø�NŠNÐ8˜4Ô8¸¸WØ9DðCð Cà;AðCð Cñ Dô Dð DðÝ” Ñ(Ô(Ð(ð
 ��øõ	 ð ð ð Ø”7�eœlÒ*Ð*Øð +Ð*Ð*Ð*Ð*øøøøðøøøõ % TÔ%:Ñ;Ô;Ð;s   Á"A9Á9
B#ÂBÂB#c                 ó   — t           ‚)a  Determine the commandline to use for composing a message

        Implemented by various subclasses
        :param to: The address to send the mail to
        :param subject: The subject line for the mail
        :param attach_path: The path to the attachment
        r&   )r   r*   r+   rd   r0   s        r   rl   z/BodyExternalMailClient._get_compose_commandline×   s
   € õ "Ð!r   c                 ó   — |S )a
  Encode possible unicode string argument to 8-bit string
        in user_encoding. Unencodable characters will be replaced
        with '?'.

        :param  u:  possible unicode string.
        :return:    encoded string if u is unicode, u itself otherwise.
        r   )r   Úus     r   Ú_encode_safez#BodyExternalMailClient._encode_safeá   s	   € ð ˆr   c                 ó   — |S )a2  Encode unicode path in user encoding.

        :param  path:   possible unicode path.
        :param  kind:   path kind ('executable' or 'attachment').
        :return:        encoded path if path is unicode,
                        path itself otherwise.
        :raise:         UnableEncodePath.
        r   )r   ÚpathÚkinds      r   rj   z#BodyExternalMailClient._encode_pathë   s	   € ð ˆr   r9   )
r   r   r   rI   rY   r1   rb   rl   rx   rj   r   r   r   rM   rM   ”   sˆ   € € € € € à€Mð)ð )ð )ð 04ð+ð +ð +ð +ð( .2ð"<ð "<ð "<ð "<ðH"ð "ð "ðð ð ð	ð 	ð 	ð 	ð 	r   rM   c                   ó   — e Zd ZdZdZdS )ÚExternalMailClientzAn external mail client.FN)r   r   r   r:   rI   r   r   r   r}   r}   ÷   s   € € € € € Ø,€Gà€M€M€Mr   r}   c                   ó    — e Zd ZdZdgZdd„ZdS )Ú	EvolutionzEvolution mail client.Ú	evolutionNc                 ó  — i }|�||d<   |�||d<   |�||d<   d„ t          |                     ¦   «         ¦  «        D ¦   «         }d                     |                      |pd¦  «        d                     |¦  «        ¦  «        gS )	ú/See ExternalMailClient._get_compose_commandlineNr+   Úattachr0   c                 ód   — g | ]-\  }}d                       |t          j        |¦  «        ¦  «        ‘Œ.S )z{}={})Úformatr
   Úescape©rR   ÚkÚvs      r   rU   z6Evolution._get_compose_commandline.<locals>.<listcomp>  s@   € ð 9ð 9ð 9Á&À1Àa˜Ÿš q­(¬/¸!Ñ*<Ô*<Ñ=Ô=ð 9ð 9ð 9r   úmailto:{}?{}r7   ú&)ÚsortedÚitemsr…   rx   r   ©r   r*   r+   rd   r0   Úmessage_optionsÚoptions_lists          r   rl   z"Evolution._get_compose_commandline  s©   € àˆØÐØ)0ˆO˜IÑ&ØÐ"Ø(3ˆO˜HÑ%ØÐØ&*ˆO˜FÑ#ð9ð 9Ý˜×4Ò4Ñ6Ô6Ñ7Ô7ð9ñ 9ô 9ˆà×%Ò% d×&7Ò&7¸¸¸bÑ&AÔ&AØ"%§(¢(¨<Ñ"8Ô"8ñ:ô :ð ;ð 	;r   r$   ©r   r   r   r:   rX   rl   r   r   r   r   r   ý   s5   € € € € € Ø*€Gà#�}Ðð;ð ;ð ;ð ;ð ;ð ;r   r   r€   c                   ó    — e Zd ZdZdgZdd„ZdS )ÚMuttzMutt mail client.ÚmuttNc                 óø  — g }|�*|                      d|                      |¦  «        g¦  «         |�+|                      d|                      |d¦  «        g¦  «         |�pt          j        ddd¬¦  «        | _        | j                             |¦  «         | j                             ¦   «          |                      d	| j        j        g¦  «         |�*|                      d
|                      |¦  «        g¦  «         |S )r‚   Nú-sz-ar,   z
mutt-body-z.txtzw+)r[   ÚsuffixÚmodez-iz--)	rk   rx   rj   r]   ÚNamedTemporaryFileÚ
_temp_filera   Úflushrr   )r   r*   r+   rd   r0   r�   s         r   rl   zMutt._get_compose_commandline  s  € àˆØÐØ×"Ò"Ø�t×(Ò(¨Ñ1Ô1Ð2ñ4ô 4ð 4àÐ"Ø×"Ò"Ø�t×(Ò(¨°lÑCÔCÐDñFô Fð FàÐõ 'Ô9Ø#¨F¸ð?ñ ?ô ?ˆDŒOàŒO×!Ò! $Ñ'Ô'Ð'ØŒO×!Ò!Ñ#Ô#Ð#Ø×"Ò" D¨$¬/Ô*>Ð#?Ñ@Ô@Ð@Øˆ>Ø×"Ò" D¨$×*;Ò*;¸BÑ*?Ô*?Ð#@ÑAÔAÐAØÐr   r$   r‘   r   r   r   r“   r“     s5   € € € € € Ø%€Gà�xÐðð ð ð ð ð r   r“   r”   c                   ó"   — e Zd ZdZg d¢Zdd„ZdS )ÚThunderbirda  Mozilla Thunderbird (or Icedove)

    Note that Thunderbird 1.5 is buggy and does not support setting
    "to" simultaneously with including a attachment.

    There is a workaround if no attachment is present, but we always need to
    send attachments.
    )Úthunderbirdzmozilla-thunderbirdÚicedovezD/Applications/Mozilla/Thunderbird.app/Contents/MacOS/thunderbird-binz</Applications/Thunderbird.app/Contents/MacOS/thunderbird-binNc                 óª  — i }|�|                       |¦  «        |d<   |�|                       |¦  «        |d<   |�t          j        |¦  «        |d<   |�,dt          j        |                       |¦  «        ¦  «        z  g}ng }|                     d„ t          |                     ¦   «         ¦  «        D ¦   «         ¦  «         dd                     |¦  «        gS )	r‚   Nr*   r+   r,   zbody=%sc                 ó@   — g | ]\  }}d                       ||¦  «        ‘ŒS )z{}='{}')r…   r‡   s      r   rU   z8Thunderbird._get_compose_commandline.<locals>.<listcomp>R  s8   € ð >ð >ð >¹¸¸1˜Y×-Ò-¨a°Ñ3Ô3ð >ð >ð >r   z-composeú,)rx   r
   Úlocal_path_to_urlÚquoterk   rŒ   r�   r   rŽ   s          r   rl   z$Thunderbird._get_compose_commandlineC  sü   € àˆØˆ>Ø$(×$5Ò$5°bÑ$9Ô$9ˆO˜DÑ!ØÐØ)-×):Ò):¸7Ñ)CÔ)CˆO˜IÑ&ØÐ"Ý,4Ô,FØñ-ô -ˆO˜LÑ)àÐØ%Ý$œN¨4×+<Ò+<¸TÑ+BÔ+BÑCÔCñDð EˆLˆLð ˆLØ×Òð >ð >Ý# O×$9Ò$9Ñ$;Ô$;Ñ<Ô<ð>ñ >ô >ñ 	?ô 	?ð 	?à˜CŸHšH \Ñ2Ô2Ð3Ð3r   r$   r‘   r   r   r   r�   r�   4  sD   € € € € € ð€GðHð Hð HÐð
4ð 4ð 4ð 4ð 4ð 4r   r�   rž   c                   ó   — e Zd ZdZdgZd„ ZdS )ÚKMailzKDE mail client.Úkmailc                 ó  — g }|�*|                      d|                      |¦  «        g¦  «         |�+|                      d|                      |d¦  «        g¦  «         |�)|                      |                      |¦  «        g¦  «         |S )r‚   Nr–   ú--attachr,   )rk   rx   rj   )r   r*   r+   rd   r�   s        r   rl   zKMail._get_compose_commandline`  s�   € àˆØÐØ×"Ò" D¨$×*;Ò*;¸GÑ*DÔ*DÐ#EÑFÔFÐFØÐ"Ø×"Ò"Ø˜T×.Ò.¨{¸LÑIÔIÐJñLô Lð Làˆ>Ø×"Ò" D×$5Ò$5°bÑ$9Ô$9Ð#:Ñ;Ô;Ð;ØÐr   Nr‘   r   r   r   r¦   r¦   [  s0   € € € € € Ø$€Gà�yÐð
ð 
ð 
ð 
ð 
r   r¦   r§   c                   ó<   ‡ — e Zd ZdZdZdgZ	 	 dd„Z	 dˆ fd„	Zˆ xZS )ÚClawszClaws mail client.Tz
claws-mailNc                 óX  — g }|�*|                      dt          j        |¦  «        z   ¦  «         |�=|                      dt          j        |                      |¦  «        ¦  «        z   ¦  «         |�=|                      dt          j        |                      |¦  «        ¦  «        z   ¦  «         |€t	          ¦   «         ‚d                     |                      |¦  «        d                     |¦  «        ¦  «        }d|g}|�+|                     d|                      |d	¦  «        g¦  «         |S )
r‚   Nzfrom=zsubject=zbody=rŠ   r‹   z	--composer©   r,   )	Úappendr
   r¤   rx   r    r…   r   rk   rj   )r   r*   r+   rd   r0   ri   Úcompose_urlr�   s           r   rl   zClaws._get_compose_commandlinex  sH  € ð ˆØÐØ×Ò˜w­¬¸Ñ)>Ô)>Ñ>Ñ?Ô?Ð?ØÐð ×ÒØ�Xœ^¨D×,=Ò,=¸gÑ,FÔ,FÑGÔGÑGñIô Ið IàÐØ×ÒØ�(œ.¨×):Ò):¸4Ñ)@Ô)@ÑAÔAÑAñCô Cð Cð ˆ:Ý(Ñ*Ô*Ð*Ø$×+Ò+Ø×Ò˜bÑ!Ô! 3§8¢8¨KÑ#8Ô#8ñ:ô :ˆð '¨Ð4ˆØÐ"Ø×"Ò"Ø˜T×.Ò.¨{¸LÑIÔIÐJñLô Lð LàÐr   c	           
      ó�   •— |€| j                              d¦  «        }t          ¦   «                              ||||||||¦  «         dS )zSee ExternalMailClient._composeNrC   )r   rH   Úsuperrb   )
r   r)   r*   r+   rd   r-   r.   r0   ri   Ú	__class__s
            €r   rb   zClaws._compose’  sY   ø€ ð ˆ=Ø”K—O’O GÑ,Ô,ˆEÝ‰Œ×Ò˜  W¨kØ$0°)¸TÀ5ñ	Jô 	Jð 	Jð 	Jð 	Jr   r9   )	r   r   r   r:   rI   rX   rl   rb   Ú__classcell__©r±   s   @r   r«   r«   q  sx   ø€ € € € € Ø&€Gà€Mà$�~ÐàFJØ'+ðð ð ð ð6 .2ðJð Jð Jð Jð Jð Jð Jð Jð Jð Jr   r«   Úclawsc                   ó    — e Zd ZdZdgZdd„ZdS )ÚXDGEmailz6xdg-email attempts to invoke the preferred mail clientú	xdg-emailNc                 ó\  — |st          ¦   «         ‚|                      |¦  «        g}|�*|                     d|                      |¦  «        g¦  «         |�+|                     d|                      |d¦  «        g¦  «         |�*|                     d|                      |¦  «        g¦  «         |S )r‚   Nz	--subjectr©   r,   z--body)r    rx   rk   rj   )r   r*   r+   rd   r0   Úcommandlines         r   rl   z!XDGEmail._get_compose_commandline¤  sÈ   € àð 	+Ý(Ñ*Ô*Ð*Ø×(Ò(¨Ñ,Ô,Ð-ˆØÐØ×Ò ¨T×->Ò->¸wÑ-GÔ-GÐHÑIÔIÐIØÐ"Ø×Ò 
Ø $× 1Ò 1°+¸|Ñ LÔ Lð Nñ Oô Oð OàÐØ×Ò ¨$×*;Ò*;¸DÑ*AÔ*AÐBÑCÔCÐCØÐr   r$   r‘   r   r   r   r¶   r¶   Ÿ  s5   € € € € € ØJ€Gà#�}Ððð ð ð ð ð r   r¶   r·   c                   ó4   ‡ — e Zd ZdZdgZˆ fd„Zd„ Zd„ Zˆ xZS )Ú	EmacsMaila«  Call emacsclient to have a mail buffer.

    This only work for emacs >= 22.1 due to recent -e/--eval support.

    The good news is that this implementation will work with all mail
    agents registered against ``mail-user-agent``. So there is no need
    to instantiate ExternalMailClient for each and every GNU Emacs
    MUA.

    Users just have to ensure that ``mail-user-agent`` is set according
    to their tastes.
    Úemacsclientc                 óX   •— t          ¦   «                              |¦  «         d | _        d S r$   )r°   r   Úelisp_tmp_file)r   r   r±   s     €r   r   zEmacsMail.__init__Ç  s)   ø€ Ý‰Œ×Ò˜Ñ Ô Ð Ø"ˆÔÐÐr   c                 óÄ   — d}t          j        dd¬¦  «        \  }}	 t          j        ||¦  «         t          j        |¦  «         n# t          j        |¦  «         w xY w|S )a  Write our wrapper function into a temporary file.

        This temporary file will be loaded at runtime in
        _get_compose_commandline function.

        This function does not remove the file.  That's a wanted
        behaviour since _get_compose_commandline won't run the send
        mail function directly but return the eligible command line.
        Removing our temporary file here would prevent our sendmail
        function to work.  (The file is deleted by some elisp code
        after being read by Emacs.)
        s¡  (defun bzr-add-mime-att (file)
  "Attach FILE to a mail buffer as a MIME attachment."
  (let ((agent mail-user-agent))
    (if (and file (file-exists-p file))
        (cond
         ((eq agent 'sendmail-user-agent)
          (progn
            (mail-text)
            (newline)
            (if (functionp 'etach-attach)
              (etach-attach file)
              (mail-attach-file file))))
         ((or (eq agent 'message-user-agent)
              (eq agent 'gnus-user-agent)
              (eq agent 'mh-e-user-agent))
          (progn
            (mml-attach-file file "text/x-patch" "BZR merge" "inline")))
         ((eq agent 'mew-user-agent)
          (progn
            (mew-draft-prepare-attachments)
            (mew-attach-link file (file-name-nondirectory file))
            (let* ((nums (mew-syntax-nums))
                   (syntax (mew-syntax-get-entry mew-encode-syntax nums)))
              (mew-syntax-set-cd syntax "BZR merge")
              (mew-encode-syntax-print mew-encode-syntax))
            (mew-header-goto-body)))
         (t
          (message "Unhandled MUA, report it on bazaar@lists.canonical.com")))
      (error "File %s does not exist." file))))
zemacs-bzr-send-z.el©r[   r—   )r]   ÚmkstempÚosra   Úclose)r   Ú_defunÚfdÚ	temp_files       r   Ú_prepare_send_functionz EmacsMail._prepare_send_functionË  sj   € ðˆõ> !Ô(Ð0AØ05ð7ñ 7ô 7‰ˆˆIð	ÝŒH�R˜Ñ Ô Ð åŒH�R‰LŒLˆLˆLø�BŒH�R‰LŒLˆLˆLøøøØÐs   �A ÁAc                 ó   — dg}d}d}|�,d|                       |¦  «                             dd¦  «        z  }|�,d|                       |¦  «                             dd¦  «        z  }d                     ||¦  «        }|                     |¦  «         |�}|                      ¦   «         }|| _        d|z  }	d|                      |d	¦  «        z  }
d
|z  }|                     |	¦  «         |                     |
¦  «         |                     |¦  «         |S )Nz--evalÚnilz"%s"ú"ú\"z(compose-mail {} {})z(load "%s")z(bzr-add-mime-att "%s")r,   z(delete-file "%s"))rx   r>   r…   r­   rÇ   r¾   rj   )r   r*   r+   rd   r¹   Ú_toÚ_subjectÚmail_cmdÚelispÚlmmformÚmmformÚrmforms               r   rl   z"EmacsMail._get_compose_commandline   s1  € Ø�jˆàˆØˆàˆ>Ø˜d×/Ò/°Ñ3Ô3×;Ò;¸CÀÑGÔGÑGˆCØÐØ Ø×)Ò)¨'Ñ2Ô2×:Ò:¸3ÀÑFÔFñGˆHð *×0Ò0°°hÑ?Ô?ˆØ×Ò˜8Ñ$Ô$Ð$ð Ð"à×/Ò/Ñ1Ô1ˆEØ"'ˆDÔØ# eÑ+ˆGØ.Ø×!Ò! +¨|Ñ<Ô<ñ=ˆFà)¨EÑ1ˆFØ×Ò˜wÑ'Ô'Ð'Ø×Ò˜vÑ&Ô&Ð&Ø×Ò˜vÑ&Ô&Ð&àÐr   )	r   r   r   r:   rX   r   rÇ   rl   r²   r³   s   @r   r»   r»   ·  sh   ø€ € € € € ð€Gð &�Ðð#ð #ð #ð #ð #ð3ð 3ð 3ðj ð  ð  ð  ð  ð  ð  r   r»   r¼   c                   ó   — e Zd ZdZ	 dd„ZdS )Ú
MAPIClientz0Default Windows mail client launched using MAPI.Nc                 óÒ   — ddl m} 	 |                     |pd|pd|pd|¦  «         dS # |j        $ r4}	|	j        |j        k    rt          d|	j        fz  g¦  «        ‚Y d}	~	dS d}	~	ww xY w)zrSee ExternalMailClient._compose.

        This implementation uses MAPI via the simplemapi ctypes wrapper
        r   )Ú
simplemapir7   z%MAPI supported mail client (error %d)N)ÚutilrÖ   ÚSendMailÚ	MAPIErrorÚcodeÚMAPI_USER_ABORTr   )
r   r)   r*   r+   rd   r-   r.   r0   rÖ   rt   s
             r   rb   zMAPIClient._compose*  sÊ   € ð 	%Ð$Ð$Ð$Ð$Ð$ð	FØ×Ò   b¨'¨-°R¸¸ÀØ +ñ-ô -ð -ð -ð -øàÔ#ð 	Fð 	Fð 	FØŒv˜Ô3Ò3Ð3Ý(ð +8Ø;<¼6¸)ñ+Dð *Eñ Fô Fð Fð 4Ð3Ð3Ð3Ð3Ð3øøøøð	Føøøs   ˆ( ¨
A&²)A!Á!A&r$   )r   r   r   r:   rb   r   r   r   rÔ   rÔ   '  s8   € € € € € ØD€Gð "&ðFð Fð Fð Fð Fð Fr   rÔ   Úmapic                   ó$   — e Zd ZdZdgZ	 	 dd„ZdS )ÚMailAppan  Use MacOS X's Mail.app for sending email messages.

    Although it would be nice to use appscript, it's not installed
    with the shipped Python installations.  We instead build an
    AppleScript and invoke the script using osascript(1).  We don't
    use the _encode_safe() routines as it's not clear what encoding
    osascript expects the script to be in.
    Ú	osascriptNc                 ót  — t          j        dd¬¦  «        \  }| _        	 t          j        |d¦  «         t          j        |d¦  «         t          j        |d¦  «         |�t          j        |d|z  ¦  «         |�,t          j        |d	|                     d
d¦  «        z  ¦  «         |�,t          j        |d|                     d
d¦  «        z  ¦  «         |�@t          j        |d|                     d
d¦  «                             dd¦  «        z  ¦  «         |�,t          j        |d|                      |d¦  «        z  ¦  «         t          j        |d¦  «         t          j        |d¦  «         t          j        |d¦  «         t          j        |¦  «         n# t          j        |¦  «         w xY w| j        gS )r‚   z	bzr-send-z.scptrÀ   ztell application "Mail"
z,set newMessage to make new outgoing message
ztell newMessage
Nz5make new to recipient with properties {address:"%s"}
zset sender to "%s"
rÊ   rË   zset subject to "%s"
zset content to "%s\n
"
ú
z\nzatell content to make new attachment with properties {file name:"%s"} at after the last paragraph
r,   zset visible to true
z	end tell
)r]   rÁ   rÆ   rÂ   ra   r>   rj   rÃ   )r   r*   r+   rd   r0   ri   rÅ   s          r   rl   z MailApp._get_compose_commandlineJ  sê  € õ &Ô-°[Ø5<ð>ñ >ô >ÑˆˆDŒNð#	ÝŒH�RÐ4Ñ5Ô5Ð5ÝŒH�RÐHÑIÔIÐIÝŒH�RÐ,Ñ-Ô-Ð-Øˆ~Ý”˜ð -Ø/1ñ2ñ 3ô 3ð 3àÐ å”˜Ð3Ø Ÿ=š=¨¨eÑ4Ô4ñ5ñ 6ô 6ð 6àÐ"Ý”˜Ð4Ø"Ÿ?š?¨3°Ñ6Ô6ñ7ñ 8ô 8ð 8àÐõ
 ”˜Ð9ØŸš c¨5Ñ1Ô1×9Ò9¸$ÀÑFÔFñGñ Hô Hð Hð Ð&õ
 ”˜ð :ð  ×,Ò,¨[¸,ÑGÔGñHñ Iô Ið Iõ ŒH�RÐ0Ñ1Ô1Ð1ÝŒH�R˜Ñ&Ô&Ð&ÝŒH�R˜Ñ&Ô&Ð&åŒH�R‰LŒLˆLˆLø�BŒH�R‰LŒLˆLˆLøøøØ”ÐÐs    E$F ÆF/r9   r‘   r   r   r   rÞ   rÞ   >  s?   € € € € € ð€Gð $�}ÐàFJØ'+ð* ð * ð * ð * ð * ð * r   rÞ   zmail.appc                   ó2   — e Zd ZdZdZd„ Z	 dd„Z	 	 dd„ZdS )ÚDefaultMailz[Default mail handling.  Tries XDGEmail (or MAPIClient on Windows),
    falls back to EditorTc                 óx   — t          j        ¦   «         rt          | j        ¦  «        S t	          | j        ¦  «        S )z5Determine the preferred mail client for this platform)r	   Úsupports_mapirÔ   r   r¶   )r   s    r   Ú_mail_clientzDefaultMail._mail_client�  s3   € åÔ Ñ"Ô"ð 	)Ý˜dœkÑ*Ô*Ð*å˜DœKÑ(Ô(Ð(r   Nc	           
      óÚ   — 	 |                       ¦   «                              ||||||||¦  «        S # t          $ r0 t          | j        ¦  «                             |||||||¦  «        cY S w xY w)rA   )ræ   r1   r   r<   r   r(   s	            r   r1   zDefaultMail.composeˆ  s¢   € ð	PØ×$Ò$Ñ&Ô&×.Ò.¨v°r¸7Ø/9¸<Ø/8¸(ÀDñJô Jð Jøõ "ð 	Pð 	Pð 	PÝ˜$œ+Ñ&Ô&×.Ò.Ø˜˜G Z°¸yÈ$ñPô Pð Pð Pð Pð	Pøøøs   ‚-0 °7A*Á)A*c                 óÔ   — 	 |                       ¦   «                              |||||¬¦  «        S # t          $ r/ t          | j        ¦  «                             |||||¬¦  «        cY S w xY w)z$See MailClient.compose_merge_request)r/   r0   )ræ   r5   r   r<   r   )r   r*   r+   r4   r/   r0   s         r   r5   z!DefaultMail.compose_merge_request“  sŸ   € ð	FØ×$Ò$Ñ&Ô&×<Ò<Ø�G˜Y°Àð =ñ Fô Fð Føå!ð 	Fð 	Fð 	FÝ˜$œ+Ñ&Ô&×<Ò<Ø�G˜Y°Àð =ñ Fô Fð Fð Fð Fð	Føøøs   ‚+. ®6A'Á&A'r9   )r   r   r   r:   rI   ræ   r1   r5   r   r   r   rã   rã   {  sr   € € € € € ð€Gð €Mð)ð )ð )ð 04ð	Pð 	Pð 	Pð 	Pð FJØ#'ðFð Fð Fð Fð Fð Fr   rã   ÚdefaultÚmail_clientzE-mail client to use.Úerror)rK   Úinvalid)+rp   rÂ   rm   rV   r]   Útypingr   Úbreezyr7   r   Ú_mod_configr   r   r   r	   r
   r   r   r   r   r    r"   ÚRegistryÚstrÚmail_client_registryr<   Úregisterr:   rM   r}   r   r“   r�   r¦   r«   r¶   r»   rÔ   rÞ   rã   Údefault_keyÚRegistryOptionÚopt_mail_clientr   r   r   ú<module>r÷      sÖ  ðð" €€€Ø 	€	€	€	Ø Ð Ð Ð Ø 
€
€
€
Ø €€€Ø Ð Ð Ð Ð Ð à €€€ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð	?ð 	?ð 	?ð 	?ð 	?˜œñ 	?ô 	?ð 	?ð"ð "ð "ð "ð "˜œñ "ô "ð "ð
Fð Fð Fð Fð F˜Vœ_ñ Fô Fð Fð
3ð 3ð 3ð 3ð 3ñ 3ô 3ð 3ðl @�xÔ(¨¨d°:Ô.>Ð)>Ô?ÑAÔAÐ ðNð Nð Nð Nð NˆZñ Nô Nð Nð< × Ò ˜h¨Ø#)¤>ð ñ 3ô 3ð 3ð`ð `ð `ð `ð `˜Zñ `ô `ð `ðFð ð ð ð Ð/ñ ô ð ð;ð ;ð ;ð ;ð ;Ð&ñ ;ô ;ð ;ð( × Ò ˜k¨9Ø#,Ô#4ð ñ 6ô 6ð 6ðð ð ð ð Ð!ñ ô ð ð6 × Ò ˜f dØ#'¤<ð ñ 1ô 1ð 1ð 4ð  4ð  4ð  4ð  4Ð(ñ  4ô  4ð  4ðF × Ò ˜m¨[Ø#.Ô#6ð ñ 8ô 8ð 8ðð ð ð ð Ðñ ô ð ð$ × Ò ˜g uØ#(¤=ð ñ 2ô 2ð 2ð'Jð 'Jð 'Jð 'Jð 'JÐñ 'Jô 'Jð 'JðT × Ò ˜g uØ#(¤=ð ñ 2ô 2ð 2ðð ð ð ð Ð%ñ ô ð ð( × Ò ˜k¨8Ø#+Ô#3ð ñ 5ô 5ð 5ðið ið ið ið iÐ"ñ iô ið iðX × Ò ˜m¨YØ#,Ô#4ð ñ 6ô 6ð 6ðFð Fð Fð Fð FÐ'ñ Fô Fð Fð& × Ò ˜f jØ#-Ô#5ð ñ 7ô 7ð 7ð6 ð 6 ð 6 ð 6 ð 6 Ð$ñ 6 ô 6 ð 6 ðr × Ò ˜j¨'Ø#*¤?ð ñ 4ô 4ð 4ð Fð  Fð  Fð  Fð  F�*ñ  Fô  Fð  FðF × Ò ˜i¨Ø#.Ô#6ð ñ 8ô 8ð 8à#,Ð Ô  à,�+Ô,ØÐ'Ð.EØðñ ô €€€r   