o
    hAfo                 
   @   sN  d dl mZ d dl mZ d dlmZ d dlmZ e  d dlm	Z	 d dlm
Z
 d dlmZ d dlmZ d d	lZd d	lZd d	lZd d	lZd d	lZd d	lZd d	lZd d	lZzd d
lT d d
lT dZW n   dZG dd dZY dZdZejek r~ede  dd ZG dd deZG dd deZ G dd deZ!ddddddd Z"d!d"d#Z#d	d$d%d%d&d'd(d)d*Z$d+Z%d,d-d.d/Z&d0d1 Z'G d2d3 d3eZ(d4d5 Z)d6d7 Z*d8d9 Z+G d:d; d;eZ,d<d= Z-dd?d@Z.G dAdB dBeZ/dCdDdEd/Z0dFdGdHd/Z1G dIdJ dJee/Z2dKdLdMd/Z3dNdOdPd/Z4dQdRdSd/Z5dTdUdVd/Z6dWdXdYd/Z7dZd[d\d/Z8d]d^d_d/Z9d`da Z:G dbdc dcee/Z;dddedfd/Z<dgdhdid/Z=G djdk dkee/Z>G dldm dmeZ?G dndo doeZ@G dpdq dqeZAdrds ZBdtdu ZCdvdw ZDeEdxkr%dyZFzeejGdzd	 d{d|d}g\ZHZIW n( ejJy ZK zee	eK W Y d	ZK[Knd	ZK[Kw eLy ZK zeKd	ZK[Kww d	 ZMZNeHD ]F\ZOZPeOd~krdZMqeOdkrePZNqeOdkseOdkred  qeOdkseOdkreQde  eQdejR eQd ed  qeIreddSeI d  dejTvred eU ZVdeVvr'eWeVZVdeVvr4edXeV g dZYeNrAeYdeNg7 ZYzeZeYZ[W n# eLyk ZK zeddSeY d e	eK  W Y d	ZK[Knd	ZK[Kww dZ\dZ]i Z^ze_e[ W n eLy ZK zede	eK  W Y d	ZK[Knd	ZK[Kww e Z`e  Zae! Zbg Zce ZdeDede^ g ed_ee^d D ]1Zfe  ZgeDegef edjeheg g eg_iefd D ]Zje! ZkeDekej egjihek ekjrdeg_lqƐqeMreQdemed  eNseMsejTd d ZNeseQdejnd edz eo ZpeqeFdZrepsddepjtder eAeNepZueuv  d	S d	S )    )print_function)division)execfile)standard_library)str)range)old_div)objectN)*TFc                   @   s   e Zd ZdS )FrameN)__name__
__module____qualname__ r   r   2/usr/lib/python3.10/site-packages/fetchmailconf.pyr   $       r   z1.63.5)         z5fetchmailconf: Python %s.%s.%s or later is required.
c                 C   s   t d t|  d S )Na  
Usage: fetchmailconf {[-d] [-f fetchmailrc]|-h|--help|-V|--version}
           -d      - dump configuration (for debugging)
           -f fmrc - read alternate fetchmailrc file
--help,    -h      - print this help text and quit
--version, -V      - print fetchmailconf version and quit
)printsysexit)Zstatusr   r   r   usage/   s   r   c                   @   ,   e Zd Zdd Zdd Zdd Zdd Zd	S )
Configurationc                 C   sV   d| _ d | _tjd d | _d | _t| _t| _	t| _
d | _t| _t| _g | _dt_d S )Nr   HOMEz
/.fetchids)
)poll_intervalInt)logfileString)idfiler   )
postmasterr   )
bouncemailBoolean)
spambouncer#   )
softbouncer#   
propertiesr   )syslogr#   )	invisibler#   )r   r   osenvironr    r!   TRUEr"   FALSEr$   r%   r'   r)   r(   serversr   typemapselfr   r   r   __init__=   s   
zConfiguration.__init__c                 C   s  d}| j tj kr|d }n| jr|d| jf  }| jtjkr&|d| jf  }| jtjkr4|d| jf  }| jr<|d }n|d }| jrH|d }n|d	 }| jrT|d
 }n|d }| jtjkrf|d| jf  }| j	dkrv|d t
| j	 d }| jr}|d }| jD ]}|t
| }q|S )N zset syslog
zset logfile "%s"
zset idfile "%s"
zset postmaster "%s"
zset bouncemail
zset nobouncemail
zset spambounce
zset no spambounce
zset softbounce
zset no softbounce
zset properties "%s"
r   zset daemon 
zset invisible
)r(   ConfigurationDefaultsr   r    r!   r"   r$   r%   r'   r   reprr)   r.   )r1   Z	self_reprsiter   r   r   __repr__U   s6   





zConfiguration.__repr__c                 C   6   t t| jD ]}| j| j|kr| j|=  d S qd S N)r   lenr.   pollname)r1   nameir   r   r   __delitem__u      zConfiguration.__delitem__c                 C      dt |  d S )Nz[Configuration: ]r6   r0   r   r   r   __str__{      zConfiguration.__str__N)r   r   r   r2   r8   r?   rD   r   r   r   r   r   <   s
     r   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )Serverc                 C   s   d | _ d | _t| _d| _d| _d | _t| _d| _	d| _
d| _d| _d | _g | _t| _g | _d | _d | _d | _d | _d | _d | _d | _t| _t| _g | _d| _dt_d S )Nr   autoanyi,  ZReceivedF))r<   r   )viar   )activer#   )intervalr   )protocolr   )servicer   )uidlr#   )authr   )timeoutr   )enveloper   )envskipr   )qvirtualr   )dnsr#   )	interfacer   )monitorr   )pluginr   )plugoutr   )	esmtpnamer   )esmtppasswordr   )	principalr   )
tracepollsr#   )	badheaderr#   )
ssldefaultr#   )r<   rI   r,   rJ   rK   rL   rM   r-   rN   rO   rP   rQ   rR   rS   akarT   localdomainsrU   rV   rW   rX   r[   rY   rZ   r\   r]   usersr^   rF   r/   r0   r   r   r   r2      s6   
zServer.__init__c                 C   s  | j rdnd}|d| j 7 }| jr|dt| j d  }| jtjkr)|d | j }| jrM| jrM| jt| j krMt| j rM| jtt| j  krM|d | j }| j	tj	kr\|d t
| j	 }| jtjkrk|d	 t
| j }| jtjksw| jtjkr| jr|d
 t
| j d | j }n|d
 | j }| jr|dt| j d  }| jtjkr|d | j }| jtjks| jtjkr|d }| jtjkr|t| jd }| jtjkr|t| jd }||rdnd7 }| jr|d d| j }| jr| jr|d }| jr|d }| jD ]	}|d | }q| js| jr|r|d }n|d }| jr'|d }| jr4|d t| j }| jrA|d t| j }| jrN|d t
| j }| jr[|d t
| j }| jrh|d t
| j }| jru|d t
| j }| jr|d t
| j }| js| js| js| js| jr|r|d }| jr|d }|d dkr|dd }| jD ]	}|t
| }q|d }|S )NZpollskip z via r4   z with proto z	 service z	 timeout z
 interval z
 envelope z
 qvirtual z auth z and optionsrT   rN   z
    zaka r`   ztracepolls
z interface z	 monitor z plugin z	 plugout z principal z esmtpname z esmtppassword zbad-header accept r   ) rJ   r<   rI   r   rL   ServerDefaultsrM   defaultportsianaservicesrP   r6   rK   rQ   rR   rS   rO   rT   rN   flag2strr_   joinr`   r\   rU   rV   rW   rX   r[   rY   rZ   r]   ra   )r1   Zfoldedresxr>   r   r   r   dump   s   :

(
zServer.dumpc                 C   r9   r:   )r   r;   ra   remote)r1   r=   Zuir   r   r   r?     r@   zServer.__delitem__c                 C   s
   |  tS r:   )rl   r,   r0   r   r   r   r8     s   
zServer.__repr__c                 C   s   d|  t d S )Nz	[Server: rB   )rl   r-   r0   r   r   r   rD        zServer.__str__N)r   r   r   r2   rl   r?   r8   rD   r   r   r   r   rF   ~   s    8KrF   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )Userc                 C   sL  dt jv rt jd | _ndt jv rt jd | _n	td td | jg| _d | _g | _g | _	g | _
d | _d | _d | _d | _d | _d | _t| _d| _t| _t| _t| _t| _t| _t| _t| _t| _t| _t| _t| _t| _ d| _!d| _"d| _#d| _$d	| _%d| _&d| _'d| _(d | _)d | _*d | _+d
| _,d | _-d | _.d | _/d | _0d | _1dt2_3d S )NZUSERZLOGNAMEzCan't get your username!   r3   r   i  d      T)&)rm   r   )passwordr   )smtpaddressr   )smtpnamer   )
preconnectr   )postconnectr   )mdar   )bsmtpr   )lmtpr#   )antispamr   )keepr#   )flushr#   )
limitflushr#   )fetchallr#   )rewriter#   )forcecrr#   )stripcrr#   )	pass8bitsr#   )
mimedecoder#   )
dropstatusr#   )dropdeliveredr#   )idler#   )limitr   )warningsr   )
fetchlimitr   )fetchsizelimitr   )fastuidlr   )
batchlimitr   )expunger   )sslr#   )sslkeyr   )sslcertr   )	sslcertckr#   )sslcertfiler   )sslcertpathr   )sslcommonnamer   )sslfingerprintr   r&   )4r*   r+   rm   r   r   r   
localnamesrs   	mailboxessmtphuntfetchdomainsrt   ru   rv   rw   rx   ry   r-   rz   r{   r|   r}   r~   r   r,   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   sslprotor   r   r   r   r   r'   ro   r/   r0   r   r   r   r2     sb   




zUser.__init__c                 C   sX  d}|d t | j d }| jr|d t | j d }| jr4|d }| jD ]
}|d t | }q%|d }| jtjks|| jtjks|| jtjks|| jtjks|| j	tj	ks|| j
tj
ks|| jtjks|| jtjks|| jtjks|| jtjks|| jtjks|| jtjkr|d }| jtjkr|t| jd	 }| jtjkr|t| jd
 }| jtjkr|t| jd }| jtjkr|t| jd }| j	tj	kr|t| j	d }| j
tj
kr|t| j
d }| jtjkr|t| jd }| jtjkr|t| jd }| jtjkr|t| jd }| jtjkr|t| jd }| jtjkr|t| jd }| jtjkr+|t| jd }| jtjkr;|d t | j }| jtjkrK|d t | j }| jtjkr[|d t | j }| jtjkrk|d t | j }| jtjkr{|d t | j }| jtjkr|d t | j }| jr| jtjkr|t| jd }| jr| jtjkr|d t | j }| jr| jtjkr|d t | j }| jr| jtjkr|d t | j }| jd ur| jtjkr|t| jd }| jr| jtjkr|d  t | j }| jr| jtjkr|d! t | j }| jr+| jtjkr+|d" t | j }| j r?| j tj kr?|d# t | j  }| j!tj!krO|d$ t | j! }|d% }| j"}|g krp|t#|d&  d'krp|d(t#|d&  }|g kr|t#|d&  t$kr|d(t#|d&  }|g kr|d) }|D ]}|d | }|d% }q| j%}|g kr|t#|d&  t$kr|d(t#|d&  }|g kr|d* }|D ]}|d | }|d% }q| j&r|d+ }| j&D ]	}|d,|  }q|d% }d-D ]}t'| |r	|d.|t t'| |f  }q| j(tj(kr|t| j(d/ }| j)tj)kr*|d0 | j) d% }|S )1Nz    zuser z there zwith password rc   isz herez optionsr|   r}   r~   r   r   r   r   r   r   r   r   r   z limit z
 warnings z fetchlimit z fetchsizelimit z
 fastuidl z batchlimit r   z sslkey z	 sslcert z
 sslproto r   z sslcertfile z sslcertpath z sslcommonname z sslfingerprint z	 expunge r4   rp   Z	localhostr   z    smtphost z    fetchdomains z
    folderz "%s")rt   rv   rw   rx   ry   r'   z %s %s
rz   z    antispam )*r6   rm   rs   r   r|   UserDefaultsr}   r~   r   r   r   r   r   r   r   r   r   rh   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   hostnamer   r   getattrrz   r{   )r1   rj   rk   Ztrimmedfldr   r   r   r8   k  s   
  
 

zUser.__repr__c                 C   rA   )Nz[User: rB   rC   r0   r   r   r   rD     rE   zUser.__str__N)r   r   r   r2   r8   rD   r   r   r   r   ro     s    \pro   m   n   iU        in  )pop2pop31109imapsmtpodmri  i  )r   r   r   r   r   r   r   r   )rG   POP2POP3APOPKPOPIMAPETRNODMR)rH   rs   ZgssapikerberosZsshZotpZmsnZntlmzList Selection HelpzList Selectionz>
You must select an item in the list box (by clicking on it).
)titlebannertextc                 C   s,   d}| d kr|d }| s|d }|| }|S )Nr3   rc   zno r   )valuestringrj   r   r   r   rh      s   rh   c                   @   s&   e Zd Zdd Zdd Zd	ddZdS )
LabeledEntryc                 C   s   | j || d S r:   )entrybind)r1   keyactionr   r   r   r     rn   zLabeledEntry.bindc                 C      | j   d S r:   )r   	focus_setr0   r   r   r   r        zLabeledEntry.focus_set   c                 C   sZ   t | | t| ||dd| _t| ||d| _| jddi | jdddd d S )	Nw)r   widthanchor)textvarr   sideleft1rk   r   expandfill)r   r2   LabellabelZEntryr   pack)r1   ZMasterr   r   ZlwidthZewidthr   r   r   r2     s
   zLabeledEntry.__init__N)r   )r   r   r   r   r   r2   r   r   r   r   r   
  s    r   c              	   C   s   t | }tt|d |}t||djtd t|D ]@}t |}	t|D ]/}
||
 | }|t|k rGt|	|| ||| |djtt	d q%t|	dt
djtt	d q%|	jtd q|jtd |S )Nrp   r   r   )r   variabler   commandr   r   rc   )r   state)r   r   r;   r   r   LEFTr   ZRadiobuttonTOPWDISABLED)framelegendrefZalternativesZdepthr   Zbbarr   columnZsubframerowZindr   r   r   	ButtonBar  s2   r   c                 C   s   t  }|| d  || d  t|| d d  t|}t|}t|td|_	|jt
ttd |j	j|jd |j	jtttd |j|j	jd |jttd |j	t| d	  t|d
|fdddd  |jt
d d S )Nr   r   r   setgridr   Zyscrollcommandr   r   r   r   Donec                 S      |   S r:   destroyrk   r   r   r   <lambda>>      zhelpwin.<locals>.<lambda>r   r   r   bdr   )Toplevelr   iconnamer   r   r   	ScrollbarTextr,   
textwidgetr   YESBOTHconfigsetr   yviewRIGHTinsertENDButton)ZhelpdictZh_w	textframescrollr   r   r   helpwin.  s$   r   c                 C   s>   t |d}t }t||dd  | j| | j| d S )NdataZblack)imageZbg)
PhotoImager   r   r   masterZ
iconwindow	keepaliveappend)baser   Z
icon_imageZicon_windowr   r   r   make_icon_windowA  s
   
r  c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )ListEditc                 C   s  t | | || _|| _|| _t|| _t||| jd}|d| j	 |d| j	 |j
tttd t |}t|}	t|ddd| _| jrR| jD ]	}
| jt|
 qH|j
tttd | jj|	jd	 | jj
tttd |	j| jjd
 |	j
ttd | jjttd | jd| j | jd| j t |}| jrt|d| jdj
td t|d| jdj
td |r|| _ t|dd| j!dj
td |j
td d S )N12z
<Double-1>z<Return>r   r   r   r   Zbrowse)Zheight
selectmoder   r   r   r   )r	  r   ZEdit)r   r   r   ZDeleteHelpbluer   Zfgr   r   )"r   r2   editordeletor	list_cont	StringVarnewvalr   r   	handleNewr   r   XEr   ZListbox
listwidgetr   r   r   r   r   r   r   r   r   ZSINGLEr,   
handleListr   editItem
deleteItemhelptxthelp)r1   Z	newlegendr  r  r  r  r  ZnewwinZ	listframer   r>   Zbfr   r   r   r2   M  sF   

zListEdit.__init__c                 C   s   t | j d S r:   )r   r  r0   r   r   r   r  t  r   zListEdit.helpc                 C      |    d S r:   )r  )r1   unusedr   r   r   r  w     zListEdit.handleListc                 C   s   | j  }|rF| jd| jd}|r|r#|| jd| jdvr>| jd| | jd kr5| j| | jr>| j|f  | j d d S d S )Nr   endr3   )	r  getr  indexr   r  r  r  r   )r1   r  itemZentirer   r   r   r  z  s   
"
zListEdit.handleNewc                 C   sV   | j  }|stt d S t|d }| jr'| j |}| jr)| j|f  d S d S d S Nr   )r  curselectionr   listboxhelpintr  r   r1   Zselectr!  r   r   r   r   r    s   
zListEdit.editItemc                 C   sn   | j  }|stt d S t|d }| j |}| j | | jd kr(| j|= | jd kr5| j|f  d S d S r#  )	r  r$  r   r%  r&  r   deleter  r  r'  r   r   r   r    s   


zListEdit.deleteItemN)	r   r   r   r2   r  r  r  r  r  r   r   r   r   r  K  s    'r  c                 C   s&   t | dd| d dddd}|jdkS )	NzQuit?zReally quit z without saving?questionZYesZNorp   r   r   ZbitmapZstringsdefaultr   )Dialognum)r   contextZansr   r   r   ConfirmQuit  s   

r0  OKc                 C   s   t | tdd}t||djtdd t||d| jdjtd t|d	d| jdjtd t|d
d|fdddjt	d |jt
d |S )N   reliefr   r   
   r   Zpadyr  r  r   Quitr
  c                 S   s   t | S r:   )r   r   r   r   r   r     r   z dispose_window.<locals>.<lambda>r  )r   RAISEDr   r   r   r   saver   nosaver   r  )r  r   Z	help_textZ
savelegendZdisposer   r   r   dispose_window  s&   
r;  c                   @      e Zd Zdd Zdd ZdS )MyWidgetc                 C   s   |j D ]J}|d dkrt| |d t|  n!|d dkr't| |d t|  n|d dkr7t| |d t|  tt| ||d }|rMt| |d | qd S )Nrp   r#   r   r   r   )r/   setattrZ
BooleanVarr  ZIntVarr   r   )r1   widgetclassfieldrk   sourcer   r   r   post  s   
zMyWidget.postc                 C   s4   |j D ]}tt| ||d t| |d   qd S r#  )r/   r>  r   r   )r1   r?  r@  rk   r   r   r   fetch  s   
&zMyWidget.fetchN)r   r   r   rB  rC  r   r   r   r   r=    s    r=  z"Fetchmail novice configurator helpzNovice configurator helpa  
In the `Novice Configurator Controls' panel, you can:

Press `Save' to save the new fetchmail configuration you have created.
Press `Quit' to exit without saving.
Press `Help' to bring up this help message.

In the `Novice Configuration' panels, you will set up the basic data
needed to create a simple fetchmail setup.  These include:

1. The name of the remote site you want to query.

2. Your login name on that site.

3. Your password on that site.

4. A protocol to use (POP, IMAP, ETRN, etc.)

5. A poll interval in seconds.
   If 0, fetchmail will run in the foreground once when started.
   If > 0, fetchmail will run in the background and start a new poll
   cycle after the interval has elapsed.

6. Options to fetch old messages as well as new, or to suppress
   deletion of fetched message.

The novice-configuration code will assume that you want to forward mail
to a local sendmail listener with no special options.
z"Fetchmail expert configurator helpzExpert configurator helpa/
  
In the `Expert Configurator Controls' panel, you can:

Press `Save' to save the new fetchmail configuration you have edited.
Press `Quit' to exit without saving.
Press `Help' to bring up this help message.

In the `Run Controls' panel, you can set the following options that
control how fetchmail runs:

Poll interval
        Number of seconds to wait between polls in the background.
        If zero, fetchmail will run in foreground.

Logfile
        If empty, emit progress and error messages to stderr.
        Otherwise this gives the name of the files to write to.
        This field is ignored if the "Log to syslog?" option is on.

Idfile
        If empty, store seen-message IDs in .fetchids under user's home
        directory.  If nonempty, use given file name.

Postmaster
        Who to send multidrop mail to as a last resort if no address can
        be matched.  Normally empty; in this case, fetchmail treats the
        invoking user as the address of last resort unless that user is
        root.  If that user is root, fetchmail sends to `postmaster'.

Bounces to sender?
        If this option is on (the default) error mail goes to the sender.
        Otherwise it goes to the postmaster.

Send spam bounces?
        If this option is on, spam bounces are sent to the sender or
        postmaster (depending on the "Bounces to sender?" option.  Otherwise,
        spam bounces are not sent (the default).

Use soft bounces?
        If this option is on, permanent delivery errors are treated as
        temporary, i. e. mail is kept on the upstream server. Useful
        during testing and after configuration changes, and on by
        default.
          If this option is off, permanent delivery errors delete
        undeliverable mail from the upstream.

Invisible
        If false (the default) fetchmail generates a Received line into
        each message and generates a HELO from the machine it is running on.
        If true, fetchmail generates no Received line and HELOs as if it were
        the remote site.

In the `Remote Mail Configurations' panel, you can:

1. Enter the name of a new remote mail server you want fetchmail to query.

To do this, simply enter a label for the poll configuration in the
`New Server:' box.  The label should be a DNS name of the server (unless
you are using ssh or some other tunneling method and will fill in the `via'
option on the site configuration screen).

2. Change the configuration of an existing site.

To do this, find the site's label in the listbox and double-click it.
This will take you to a site configuration dialogue.
c                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )ConfigurationEditc                 C   sP   t | | t|  i | _|| _|| _|| _|| _g | _d | _	t
tdt_d S )N)noviceexpert)r   r2   r=  
subwidgetsconfigurationoutfile	containeronexitr  modeconfigure_novice_helpconfigure_expert_helprD  mode_to_help)r1   rH  rI  r  rK  r   r   r   r2   2  s   
zConfigurationEdit.__init__c                 C   s    t || | jt | j|< d S r:   )
ServerEditeditrL  r   rG  r1   sitenamer   r   r   server_edit@  s    zConfigurationEdit.server_editc              
   C   sf   zt | j D ]}| j|   | j|= qW d S  ty2 } ztd| W Y d }~d S d }~ww )Nz<Exception discarded in ConfigurationEdit.server_delete(): {})listrG  keysrH  destruct	Exceptionr   format)r1   rS  Zuser_iter   r   r   server_deleteC  s   
zConfigurationEdit.server_deletec                 C   s  || _ t| | j | jd| j  d  | jd| j  d  | jd| j g | _	t
| t t|  | td t| d| j  d tj| j  d t| tdd	}t|d
ddjtdd t|}t|}| j dkrzt|d| jd}|jttd t|d| jd}|jttd |  |  | j dkr(t|}t|d| jtdjtt d |jt!d t|}t|d| j"tdjtt d |jt!d t|}t|d| j#tdjtt d |jt!d t|}	t|	d| j$tdjtt d t|	d| j%d}|jttd |	jt!d t|d| j&tdjtt d t|d| j'd}|jttd |jt!d t| tdd	}
t|
dddjtdd t(ddd  | j)j*D | fd!d"| fd#d"|
t+ |
jt!d d S )$Nz
fetchmail z configuratorWM_DELETE_WINDOWrH  zConfigurator z	 ControlsZSaver2  r3  zFetchmail Run Controlsr   r   r   r5  r6  rE  z	 Postmaster:14r   z     Poll interval:zBounces to sender?)r   r   r4  r  zSend spam bounces?z$Treat permanent errors as temporary?zLog to syslog?z
	 Logfile:zInvisible mode?z		 Idfile:z!Remote Mail Server ConfigurationszNew Server:c                 S      g | ]}|j qS r   )r<   .0r>   r   r   r   
<listcomp>      z*ConfigurationEdit.edit.<locals>.<listcomp>c                 S   
   | | S r:   )rT  r7   r1   r   r   r   r        
 z(ConfigurationEdit.edit.<locals>.<lambda>c                 S   rd  r:   )r[  re  r   r   r   r     rf  ),rL  r   r2   rJ  r  r   r   rL   r:  r  r  fetchmail_iconPackr   rB  r   r;  rD  rO  r8  r   r   r   r   r!   r   r  r   Checkbuttonr"   ZGROOVEr   r   r  r$   r%   r(   r   r)   r    r  rH  r.   
remotehelp)r1   rL  ZgfZdfZfflogZdeZpfZsbZsfZlfr   r   r   rQ  K  s   





zConfigurationEdit.editc                 C   s8   t | j D ]	}| j|   q| j  |   d S r:   )rU  rG  rV  rW  r  r   rK  rR  r   r   r   rW    s   
zConfigurationEdit.destructc                 C   s    t | | jd r|   d S d S )Nz configuration editor)r0  rL  rW  r0   r   r   r   r:    s   zConfigurationEdit.nosavec                 C   s  | j D ]}|  q| td d }| jstj}n;tj	| jr-t
| ddddddjdkrTzt| j| jd	  W n
 tjyC   Y nw td
}t| jd}t| |r|tjkrbt| jd |dtt tf  |t| j | jr|  |   d S d S )NrH  z$Overwrite existing run control file?z+Really overwrite existing run control file?r)  r*  rp   r+  r   ~?   r   i  z/# Configuration created %s by fetchmailconf %s
)rG  r9  rC  r   rI  r   stdoutr*   pathisfiler-  r.  renameerrorumaskopenchmodwritetimectimeVERSIONr6   rH  closerW  )r1   r>   ZfmZoldumaskr   r   r   r9    sB   




zConfigurationEdit.saveN)
r   r   r   r2   rT  r[  rQ  rW  r:  r9  r   r   r   r   rD  1  s    YrD  zRemote site helpzRemote sitesa  
When you add a site name to the list here,
you initialize an entry telling fetchmail
how to poll a new site.

When you select a sitename (by double-
clicking it, or by single-clicking to
select and then clicking the Edit button),
you will open a window to configure that
site.
zServer options helpzServer OptionsaH  
The server options screen controls fetchmail
options that apply to one of your mailservers.

Once you have a mailserver configuration set
up as you like it, you can select `OK' to
store it in the server list maintained in
the main configuration window.

If you wish to discard changes to a server
configuration, select `Quit'.
zRun Control helpRun Controlsa  
If the `Poll normally' checkbox is on, the host is polled as part of
the normal operation of fetchmail when it is run with no arguments.
If it is off, fetchmail will only query this host when it is given as
a command-line argument.

The `True name of server' box should specify the actual DNS name
to query. By default this is the same as the poll name.

Normally each host described in the file is queried once each
poll cycle. If `Cycles to skip between polls' is greater than 0,
that's the number of poll cycles that are skipped between the
times this post is actually polled.

The `Server timeout' is the number of seconds fetchmail will wait
for a reply from the mailserver before concluding it is hung and
giving up.
zProtocol and Port helpzProtocol and Porta  
These options control the remote-mail protocol
and TCP/IP service port used to query this
server.

If you click the `Probe for supported protocols'
button, fetchmail will try to find you the most
capable server on the selected host (this will
only work if you're conncted to the Internet).
The probe only checks for ordinary IMAP and POP
protocols; fortunately these are the most
frequently supported.

The `Protocol' button bar offers you a choice of
all the different protocols available.	The `auto'
protocol is the default mode; it probes the host
ports for POP3 and IMAP to see if either is
available.

Normally the TCP/IP service port to use is
dictated by the protocol choice.  The `Service'
field (only present in expert mode) lets you
set a non-standard service (port).
zSecurity option helpSecuritya  
The 'authorization mode' allows you to choose the
mode that fetchmail uses to log in to your server. You
can usually leave this at 'any', but you will have to pick
'NTLM' and 'MSN' manually for the nonce.

The 'interface' option allows you to specify a range
of IP addresses to monitor for activity.  If these
addresses are not active, fetchmail will not poll.
Specifying this may protect you from a spoofing attack
if your client machine has more than one IP gateway
address and some of the gateways are to insecure nets.

The `monitor' option, if given, specifies the only
device through which fetchmail is permitted to connect
to servers.  This option may be used to prevent
fetchmail from triggering an expensive dial-out if the
interface is not already active.

The `interface' and `monitor' options are available
only for Linux and freeBSD systems.  See the fetchmail
manual page for details on these.

The ssl option enables SSL communication with a mailserver
supporting Secure Sockets Layer. The sslkey and sslcert options
declare key and certificate files for use with SSL.
The sslcertck option enables strict checking of SSL server
certificates (and sslcertpath gives the trusted certificate
directory). The sslcommonname option helps if the server is
misconfigured and returning "Server CommonName mismatch"
warnings. With sslfingerprint, you can specify a finger-
print the server's key is checked against.
zMultidrop option helpZ	Multidropza
These options are only useful with multidrop mode.
See the manual page for extended discussion.
zUser list helpz	User lista@  
When you add a user name to the list here,
you initialize an entry telling fetchmail
to poll the site on behalf of the new user.

When you select a username (by double-
clicking it, or by single-clicking to
select and then clicking the Edit button),
you will open a window to configure the
user's options on that site.
c                 C   s^  d }d }d }g }t | |t jt jD ]}|\}}	}
}}zt  ||	|
}|d W n& t jyO } z|dt|t|	t|
| d }W Y d }~qd }~ww z.|rat	
 }|j||p]| d}n|}|| |ddd}|t j |  |}W n* t jt	jfy } z|d|d |d	 | |  d }W Y d }~qd }~ww  |||fS )
Nr2  zsocket({}, {}, {}): {})Zserver_hostnamei   zus-asciireplacez{} port {}: {}r   rp   )socketZgetaddrinfoZ	AF_UNSPECZSOCK_STREAMZ
settimeoutrr  r  rY  r6   r   Zcreate_default_contextZwrap_socketZconnectZrecvdecodeZshutdownZ	SHUT_RDWRrz  ZSSLError)Z	_hostnameportsslmodeZsock	greetlineaddresserrorsrj   ZafZsocktypeprotoZ	canonnameZsamsgr/  Zconnr   r   r   get_greetline^  sD   "

r  c                   @   s^   e Zd Zdd ZdddZdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd ZdS )rP  c                 C   s   t |  t|  || _d | _i | _g | _|jjD ]
}|j	|kr$|| _q| jd u r@t
 | _|| j_	d | j_|jj| j d S d S r:   )r   r2   r=  parentserverrG  r  rH  r.   r<   rF   rI   r  )r1   hostr  r7   r   r   r   r2     s    



zServerEdit.__init__Nc                 C   sn   t | | t|  | jd| jj  | jd| jj  | 	t
d | | jj| g | _t| t | S )NzFetchmail host r  )r   r2   rh  r   r  r   r  r<   r   rB  rF   makeWidgetsr  r  rg  r1   rL  r  r   r   r   rQ    s   

zServerEdit.editc                 C   s>   t | j D ]	}| j|   q| jj| jj= | j  d S r:   )	rU  rG  rV  rW  r  r  r<   r  r   r1   usernamer   r   r   rW    s   zServerEdit.destructc                 C      t | dr|   d S d S )Nzserver option editingr0  rW  r0   r   r   r   r:       
zServerEdit.nosavec                 C   s4   |  td | j D ]\}}|  q|   d S )Nr  )rC  rF   rG  itemsr9  rW  )r1   r  Zuserdatar   r   r   r9    s   
zServerEdit.savec                 C   s2   | j  }| jt|  |dvrt| j_d S d S )Nr   r   r   )rL   r   rM   r   rf   r   rN   r   )r1   r  r   r   r   defaultPort  s
   
zServerEdit.defaultPortc                 C   s   t || |t | j|< d S r:   )UserEditrQ  r   rG  )r1   r  rL  r   r   r   	user_edit  s   zServerEdit.user_editc                 C   s$   || j v r| j |   | j|= d S r:   )rG  rW  r  r  r   r   r   user_delete  s   
zServerEdit.user_deletec                 C   s  t | d| t}t| }d}|dkr~t|tdd}t|ddjtd t|d	| d
 | jdjtd t|d| j	djtd t
|d| d | j|jttd t
|d| j|jttd t
|d| j|jttd t|dddd djtd |jtd dg}dtv r|d dtv r|g d }dtv r|d dtv r|d  d!tv r|d" d#tv r|d$ t|tdd}t|d%djtd t|d&| j|d'| j |dkrt
|d(| j|jttd |   t|d)| jdjtd t|d*d| jdjtd t|ddd+d djtd |jtd t|tdd}	t|	d,| djtd td-d.d/ | jjD || fd0d| fd1d|	t |	jtd |jtttd2 |dkrrt| }
t|
tdd}t|d3djtd t
|d4| jd5jttd t
|d6| j d5jttd t
|d7| j!d5jttd t|d8| j"djtd t|d9djtd td:| jj#d d |d  t|d;djtd td<| jj$d d |t% |jtd t&d=v rit|
tdd}t|d>djtd t|d?| j't(d'd jtd t&d@ks t&dAks dBt)v rt
|dC| j*|jttd t&d@kst&dAksdDt)v r)t
|dE| j+|jttd dFtv r;t
|dG| j,dHjttd t
|dI| j-dHjttd t
|dJ| j.dHjttd t|dddKd djtd |jtd |
jttdL d S d S )MNzServer options for querying Z25rE  r2  r3  r{  r   r   zPoll z
 normally?r   r   zPass messages with bad headers?zTrue name of :r   zCycles to skip between polls:zServer timeout (seconds):r
  r  c                   S      t tS r:   )r   controlhelpr   r   r   r   r     r   z(ServerEdit.makeWidgets.<locals>.<lambda>r  r  rG   r   r   r   r  ZsdpsZSDPSr   r   Zetrnr   r   r   ZProtocolr3   r   zOn server TCP/IP service:z*POP3: track `seen' with client-side UIDLs?zProbe for supported protocolsc                   S   r  r:   )r   	protohelpr   r   r   r   r     r   zUser entries for z
New user: c                 S   r_  r   )rm   r`  r   r   r   rb    rc  z*ServerEdit.makeWidgets.<locals>.<listcomp>c                 S   s   | | |S r:   )r  )umsr   r   r   r     r   c                 S   rd  r:   )r  )r  r  r   r   r   r     rf  )r   r   r   zMultidrop optionszEnvelope address header:Z22zEnvelope headers to skip:zName prefix to strip:zEnable multidrop DNS lookup?zDNS aliaseszNew alias: zDomains to be considered localzNew domain: )linuxfreebsdr|  zAuthorization mode:r  r  rU   zIP range to check before poll:rV   zInterface to monitor:r   z
Principal:r  zESMTP name:zESMTP password:c                   S   r  r:   )r   sechelpr   r   r   r   r   /  r   r   )/r;  
serverhelpr   r8  r   r   r   ri  rJ   r]   r   rI   r  rK   rP   r   r   feature_optionsr  r   rL   r  rM   rN   	autoprober   r  r  ra   	suserhelpNrQ   rR   rS   rT   r_   r`   	multihelpos_typerO   authlistdictmembersrU   rV   r[   rY   rZ   )r1   r  rL  ZtopwinleftwinZ	leftwidthZctlwinZ	protolistZprotwinZuserwinrightwinZmdropwinsecwinr   r   r   r    sB   









zServerEdit.makeWidgetsc              
   C   s  | j jr	| j j}n| j j}g }d\}}d}z7dD ]2}dD ])}t| }|r.|tvr)qt| }nt| }t|||\}}	}
|
rA||
7 }|rE nq|rJ nqW n0 tjye } zdt	| }W Y d }~nd }~w t
y| } zdt	| }W Y d }~nd }~ww t }|rd|}n9|d u rd| d	 }d
t	d| }n$d}|dkr|d }d|v sd|v r|d }d|v r|d }d|v r|d }d|v r|d }d|v r|d }d|v r|d }d|v r|d }d|v r|d }d|v r|d  }d!|v r|d" }d#|v r|d$ }d%|v r|d& }d'|v r|d( }d)|v r |d* }d+|v r)|d, }d-|v r2|d. }d/|v r;|d0 }d1|v rD|d2 }d3|v rM|d4 }d5|v rV|d6 }d7|v r_|d8 }d9|v rh|d: }|d;}|d<kr||d=  d>kr|d? }d@|v r|dA }dB|v r|dC }|dkr|dD }d| dE }dF||	d< |	d= || | }| j| | jt|  || j _|| || t||dG  t||dHdI  t|dJ|fdKdLdMdN  d S )ON)NNr3   )TF)r   r   r   z:
Fetchmailconf could not resolve the hostname.
Error was:
z3
Fetchmailconf could not probe servers.
Error was:
zAutoprobe of {} failedzAutoprobe of z failedz
Fetchmailconf didn't find any mailservers active.
This could mean the host doesn't support any,
or that your Internet connection is down, or
that the host is so slow that the probe timed
out before getting a response.

r4   r   au  
It appears you have somehow found a mailserver running only POP2.
Congratulations.  Have you considered a career in archaeology?

Unfortunately, stock fetchmail binaries don't include POP2 support anymore.
Unless the first line of your fetchmail -V output includes the string "POP2",
you'll have to build it from sources yourself with the configure
switch --enable-POP2.

z1.003z1.004aJ  
This appears to be an old version of the UC Davis POP server.  These are
dangerously unreliable (among other problems, they may drop your mailbox
on the floor if your connection is interrupted during the session).

It is strongly recommended that you find a better POP3 server.	The fetchmail
FAQ includes pointers to good ones.

zcomcast.netz
The Comcast Maillennium POP3 server only returns the first 80K of a long
message retrieved with TOP. Its response to RETR is normal, so use the
`fetchall' option.

zCubic Circlea  
I see your server is running cucipop.  Better make sure the server box
isn't a SunOS 4.1.4 machine; cucipop tickles a bug in SunOS realloc()
under that version, and doesn't cope with the result gracefully.  Newer
SunOS and Solaris machines run cucipop OK.

Also, some versions of cucipop don't assert an exclusive lock on your
mailbox when it's being queried.  This means that if you have more than
one fetchmail query running against the same mailbox, bad things can happen.
zDavid POP3 Serverz~
This POP3 server is badly broken.  You should get rid of it -- and the
brain-dead Microsoft operating system it rode in on.

ZFTGatez
This POP server has a weird bug; it says OK twice in response to TOP.
Its response to RETR is normal, so use the `fetchall' option.

z
 geonet.dezx
You appear to be using geonet.	As of late 2002, the TOP command on
geonet's POP3 is broken.  Use the fetchall option.

ZOpenMaila,  
You appear to be using some version of HP OpenMail.  Many versions of
OpenMail do not process the "TOP" command correctly; the symptom is that
only the header and first line of each message is retrieved.  To work
around this bug, turn on `fetchall' on all user entries associated with
this server.

zEscape character isz
Your greeting line looks like it was written by a fetid pile of
camel dung identified to me as `popa3d written by Solar Designer'.
Beware!  The UIDL support in this thing is known to be completely broken,
and other things probably are too.

zMercuryP/NLM v1.48a&  
This is not a POP3 server.  It has delusions of being one, but after
RETR all messages are automatically marked to be deleted.  The only
way to prevent this is to issue an RSET before leaving the server.
Fetchmail does this, but we suspect this is probably broken in lots
of other ways, too.

zPOP-Maxa4  
The Mail Max POP3 server screws up on mail with attachments.  It
reports the message size with attachments included, but doesn't
download them on a RETR or TOP (this violates the IMAP RFCs).  It also
doesn't implement TOP correctly.  You should get rid of it -- and the
brain-dead NT server it rode in on.

zPOP3 Server Readyz
Some server that uses this greeting line has been observed to choke on
TOP %d 99999999.  Use the fetchall option. if necessary, to force RETR.

ZQPOPa  
This appears to be a version of Eudora qpopper.  That's good.  Fetchmail
knows all about qpopper.  However, be aware that the 2.53 version of
qpopper does something odd that causes fetchmail to hang with a socket
error on very large messages.  This is probably not a fetchmail bug, as
it has been observed with fetchpop.  The fix is to upgrade to qpopper
3.0beta or a more recent version.  Better yet, switch to IMAP.

z sprynet.coma%  
You appear to be using a SpryNet server.  In mid-1999 it was reported that
the SpryNet TOP command marks messages seen.  Therefore, for proper error
recovery in the event of a line drop, it is strongly recommended that you
turn on `fetchall' on all user entries associated with this server.

z	TEMS POP3a  
Your POP3 server has "TEMS" in its header line.  At least one such
server does not process the "TOP" command correctly; the symptom is
that fetchmail hangs when trying to retrieve mail.  To work around
this bug, turn on `fetchall' on all user entries associated with this
server.

z	 spray.sea  
Your POP3 server has "spray.se" in its header line.  In May 2000 at
least one such server did not process the "TOP" command correctly; the
symptom is that messages are treated as headerless.  To work around
this bug, turn on `fetchall' on all user entries associated with this
server.

z usa.netaY  
You appear to be using USA.NET's free mail service.  Their POP3 servers
(at least as of the 2.2 version in use mid-1998) are quite flaky, but
fetchmail can compensate.  They seem to require that fetchall be switched on
(otherwise you won't necessarily see all your mail, not even new mail).
They also botch the TOP command the fetchmail normally uses for retrieval
(it only retrieves about 10 lines rather than the number specified).
Turning on fetchall will disable the use of TOP.

Therefore, it is strongly recommended that you turn on `fetchall' on all
user entries associated with this server.

z Novonyx POP3z
Your mailserver is running Novonyx POP3.  This server, at least as of
version 2.17, seems to have problems handling and reporting seen bits.
You may have to use the fetchall option.

z	 IMS POP3a  
Some servers issuing the greeting line 'IMS POP3' have been known to
do byte-stuffing incorrectly.  This means that if a message you receive
has a . (period) at start of line, fetchmail will become confused and
probably wedge itself.	(This bug was recorded on IMS POP3 0.86.)

Z	GroupWisea  
The Novell GroupWise IMAP server would be better named GroupFoolish;
it is (according to the designer of IMAP) unusably broken.  Among
other things, it doesn't include a required content length in its
BODY[TEXT] response.<p>

Fetchmail works around this problem, but we strongly recommend voting
with your dollars for a server that isn't brain-dead.  If you stick
with code as shoddy as GroupWise seems to be, you will probably pay
for it with other problems.<p>

ZInterChangea  

The InterChange IMAP server at release levels below 3.61.08 screws up
on mail with attachments.  It doesn't fetch them if you give it a
BODY[TEXT] request, though it does if you request RFC822.TEXT.
According to the IMAP RFCs and their maintainer these should be
equivalent -- and we can't drop the BODY[TEXT] form because M$
Exchange (quite legally under RFC2062) rejectsit.  The InterChange
folks claim to have fixed this bug in 3.61.08.

ZImaila  
We've seen a bug report indicating that this IMAP server (at least as of
version 5.0.7) returns an invalid body size for messages with MIME
attachments; the effect is to drop the attachments on the floor.  We
recommend you upgrade to a non-broken IMAP server.

zDomino IMAP4a]  
Your IMAP server appears to be Lotus Domino.  This server, at least up
to version 4.6.2a, has a bug in its generation of MIME boundaries (see
the details in the fetchmail FAQ).  As a result, even MIME aware MUAs
will see attachments as part of the message text.  If your Domino server's
POP3 facility is enabled, we recommend you fall back on it.

>r   rp   z
It looks like you could use APOP on this server and avoid sending it your
password in clear.  You should talk to the mailserver administrator about
this.

ZIMAP2bisa  
IMAP2bis servers have a minor problem; they can't peek at messages without
marking them seen.  If you take a line hit during the retrieval, the
interrupted message may get left on the server, marked seen.

To work around this, it is recommended that you set the `fetchall'
option on all user entries associated with this server, so any stuck
mail will be retrieved next time around.

To fix this bug, upgrade to an IMAP4 server.  The fetchmail FAQ includes
a pointer to an open-source implementation.

Z	IMAP4rev1z
I see an IMAP4rev1 server.  Excellent.	This is (a) the best kind of
remote-mail server, and (b) the one the fetchmail author uses.	Fetchmail
has therefore been extremely well tested with this class of server.

zB
Fetchmail doesn't know anything special about this server type.

z
 succeededz,The {} server at {} port {} (SSL {}) said:

r   X  r   r   r   c                 S   r   r:   r   r   r   r   r   r     r   z&ServerEdit.autoprobe.<locals>.<lambda>r   r   )r  rI   r<   rf   sslservicesrg   r  r~  Zgaierrorr   OSErrorr   rY  ri   findrL   r   rM   r^   r   r   r   r   Messager   )r1   Zrealhostr  r  rL   ZconfirmrM   r  r  r  Z
new_errorsrZ  Zconfwinr   r   Z	closebrakr   r   r   r  4  s   

		



	
















zServerEdit.autoprober:   )r   r   r   r2   rQ  rW  r:  r9  r  r  r  r  r  r   r   r   r   rP    s    
qrP  zUser option helpzUser optionsaI  
You may use this panel to set options
that may differ between individual
users on your site.

Once you have a user configuration set
up as you like it, you can select `OK' to
store it in the user list maintained in
the site configuration window.

If you wish to discard the changes you have
made to user options, select `Quit'.
zLocal name helpLocal namesa  
The local name(s) in a user entry are the
people on the client machine who should
receive mail from the poll described.

Note: if a user entry has more than one
local name, messages will be retrieved
in multidrop mode.  This complicates
the configuration issues; see the manual
page section on multidrop mode.

Warning: Be careful with local names
such as foo@bar.com, as that can cause
the mail to be sent to foo@bar.com instead
of sending it to your local system.
c                   @   s>   e Zd Zdd ZdddZdd Zdd	 Zd
d Zdd ZdS )r  c                 C   s   t |  t|  || _d | _g | _|jjD ]
}|j|kr!|| _q| jd u rDt	 | _|| j_|g| j_
|jj| j_|jj| j d S d S r:   )r   r2   r=  r  userr  r  ra   rm   ro   r   r^   r   r  )r1   r  r  r  r   r   r   r2     s    




zUserEdit.__init__Nc                 C   s~   t | | t|  | jd| jj d | jj	j
  | jd| jj  | td | || jj	j
 g | _t| t | S )NzFetchmail user 
 querying r  )r   r2   rh  r   r  r   r  rm   r  r  r<   r   rB  ro   r  r  r  rg  r  r   r   r   rQ    s   

zUserEdit.editc                 C   s,   | j j| jjv r| jj| j j= | j  d S r:   )r  rm   r  rG  r  r   r0   r   r   r   rW    s   zUserEdit.destructc                 C   r  )Nzuser option editingr  r0   r   r   r   r:    r  zUserEdit.nosavec                 C   s\   d}| j jD ]}|d|v  }q|dks t| ddddddjdkr,| td	 |   d S d S )
Nr   @zReally accept an embedded '@' ?zLocal names with an embedded '@', such as in foo@bar might result in your mail being sent to foo@bar.com instead of your local system.
 Are you sure you want a local user name with an '@' in it?r)  r*  rp   r+  r  )r  r   r-  r.  rC  ro   rW  )r1   okrk   r   r   r   r9    s   	zUserEdit.savec                 C   sX  t | d| jj d | t |dkrt| }n| }t|tdd}t|ddjtd t	|d	| j
d
jttd |jttd dtv sFdtv rt|tdd}t|d| jdjttd t	|d| jdjttd t	|d| jdjttd t|d| jdjttd t	|d| jdjttd t	|d| jdjttd t	|d| jdjttd t	|d| jdjttd |jttd t|tdd}t|ddjtd td| jjd d |t |jttd |dkrt|tdd}t|ddjtd t|ddjtd td| jjd d |d  t|ddjtd td| jjd d |d  t	|d| jd jttd t	|d!| jd jttd t	|d"| jd jttd t	|d#| j d jttd t	|d$| j!d jttd t	|d%| j"d jttd t	|d&| j#d jttd t	|d'| j$d jttd t|d(| j%djttd |jttd |dkr|jt&ttd) t| }n| }t|tdd}	t|	d*djtd t|	d+| j'djtt(d, t|	d-| j)djtt(d, |dkrTt|	d.| j*djtt(d, t|	d/| j+djtt(d, t|	d0| j,djtt(d, t|	d1| j-djtt(d, t|	d2| j.djtt(d, t|	d3| j/djtt(d, t|	d4| j0djtt(d, t|	d5| j1djtt(d, t|	d6| j2djtt(d, |	jtd7 |dkrt|tdd}
t|
d8djtd t	|
d9| j3d:jttd t	|
d;| j4d:jttd t	|
d<| j5d:jttd t	|
d=| j6d:jttd | j7j8j9d>vrt	|
d?| j:d:jttd t	|
d@| j;d:jttd | j7j8j9d>vrt	|
dA| j<d:jttd t|
dB| j=djtt(d, |
jtd7 | j7j8j9dCkrt|tdd}t|dDdjtd tdE| jj>d d |d  |jttd |dkr&|jt&d d S |   d S )FNzUser options for r  rE  r2  r3  ZAuthenticationr   r   z	Password:r  r   )r   r   r   zUse SSL?r  zSSL key:r^  zSSL certificate:zCheck server SSL certificate?zSSL trust bundle:zSSL trust directory:zSSL CommonName:zSSL key fingerprint:r  z
New name: zForwarding OptionszListeners to forward tozNew listener:z&Domains to fetch from (ODMR/ETRN only)zDomains:zUse domain on RCPT TO line:Z26zSet fixed RCPT TO address:zConnection setup command:zConnection wrapup command:zLocal delivery agent (MDA):zBSMTP output file:zListener spam-block codes:zPass-through properties:z	Use LMTP?r  zProcessing Optionsz+Suppress deletion of messages after readingr   z!Fetch old messages as well as newz$Flush seen messages before retrievalz)Flush oversized messages before retrievalz*Rewrite To/Cc/Bcc messages to enable replyzForce CR/LF at end of each linezStrip CR from end of each linez&Pass 8 bits even though SMTP says 7BITz%Undo MIME armoring on header and bodyz)Drop Status lines from forwarded messagesz/Drop Delivered-To lines from forwarded messagesr  zResource LimitszMessage size limit:Z30zSize warning interval:zMax messages to fetch per poll:z+Max message sizes to fetch per transaction:)r   r   zUse fast UIDL:z!Max messages to forward per poll:zInterval between expunges:z Idle after each poll (IMAP only)r   zRemote folders (IMAP only)zNew folder:)?r;  r  rm   userhelpr   r8  r   r   r   r   rs   r  r  r  r  ri  r   r   r   r   r   r   r   r   r  r   	localhelpr   r   rt   ru   rv   rw   rx   ry   r{   r'   rz   r   r|   r   r   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r  r  rL   r   r   r   r   r   )r1   rL  Z
servernamer  r  ZsslwinnamesZtargwinr  ZoptwinZlimwinZfoldwinr   r   r   r    s  







zUserEdit.makeWidgetsr:   )	r   r   r   r2   rQ  rW  r:  r9  r  r   r   r   r   r    s    
r  c                   @   r   )
Configuratorc                 C   s   t | | || _|| _|| _| jd | jd t	|  g | _
t| t t| dddjtd t| dd| jd  t| d	ddjtd t| d
d| jd  t| dddjtd t| dd| jd  |d| j d S )Nzfetchmail configuratorz
Use `Novice Configuration' for basic fetchmail setup;
with this, you can easily set up a single-drop connection
to one remote mail server.
r  r  r   zNovice Configurationr  r  zl
Use `Expert Configuration' for advanced fetchmail setup,
including multiple-site or multidrop connections.
zExpert Configurationz[
Or you can just select `Quit' to leave the configurator now and
return to the main panel.
r7  r\  )r   r2   rI  rK  r  r  r   r   rh  r   r  r  rg  r  r   r   r   rE  rF  leaverL   )r1   rI  r  rK  r  r   r   r   r2   ~  sD   

zConfigurator.__init__c                 C   (   | j   tt| jt | jd d S )NrE  r  r   rD  FetchmailrcrI  r   rK  rQ  r0   r   r   r   rE       
zConfigurator.novicec                 C   r  )NrF  r  r0   r   r   r   rF    r  zConfigurator.expertc                 C   s   | j   |   d S r:   )r  r   rK  r0   r   r   r   r    s   
zConfigurator.leaveN)r   r   r   r2   rE  rF  r  r   r   r   r   r  }  s
    !r  c                   @   r<  )	RunWindowc                 C   s  t | | || _| jd | jd t|  t| d| ddjt	dd g | _
t| t t |}t|}t|td| _|jt	ttd | jj|jd	 | jjtttd |j| jjd
 |jttd t| jdd| jd  |   tjtjd d tjd  tjd< t |d d}	 |! }|sn| j"t#| |   q|$ }| j"t#d |d ur|dk r| j"t#d%|  n| j"t#d%|d?  | j&t# d S )Nzfetchmail run windowzRunning r   r]  r5  r6  r   r   r   r   r   r7  r  r  r   r  PATHz 2>&1 </dev/nullrrp   zDone.
z Fetchmail killed with signal {}.z%Fetchmail exited with return code {}.   )'r   r2   r  r   r   rh  r   r   r   r   r  r  rg  r   r   r,   r   r   r   r   r   r   r   r   r  updater*   ro  dirnamer   argvr+   popenreadliner   r   rz  rY  Zsee)r1   r   r  r   r   Zchild_stdoutZchZretr   r   r   r2     sN   

&zRunWindow.__init__c                 C   r   r:   )r  r   r0   r   r   r   r    r   zRunWindow.leaveN)r   r   r   r2   r  r   r   r   r   r    s    -r  c                   @   s6   e Zd ZdddZdd Zdd Zdd	 Zd
d ZdS )
MainWindowNc                 C   s*  t | | || _| jd | jd t|  t| dt	 d t
 ddjtdd g | _t| t d| _t| d	d
djtd t| dd| jd| _| j  t| dd
djtd t| dd| jd  t| dd
djtd t| dd| jd  t| dd
djtd t| dd| jd  d S )Nzfetchmail launcherzFetchmailconf z
running on r   r]  r5  r6  r   z
Use `Configure fetchmail' to tell fetchmail about the remote
servers it should poll (the host name, your username there,
whether to use POP or IMAP, and so forth).
r  r  r   zConfigure fetchmailr  r  zr
Use `Run fetchmail' to run fetchmail with debugging enabled.
This is a good way to test out a new configuration.
zRun fetchmail (verbose)zo
Use `Run fetchmail' to run fetchmail in foreground.
Progress  messages will be shown, but not debug messages.
zRun fetchmail (normal)z9
Or you can just select `Quit' to exit the launcher now.
r7  )r   r2   rI  r  r   r   rh  r   r   ry  r   r   r   r  r  rg  debugr  r   	configureconfigbuttontestrunr  )r1   rI  r  r   r   r   r2     sZ   


zMainWindow.__init__c                 C   s,   | j jtd t| jt | fdd|  d S )Nr   c                 S   s   | j jtdS )Nr  )r  r  ZNORMALr0   r   r   r   r     s    z&MainWindow.configure.<locals>.<lambda>)r  r  r   r  rI  r   r0   r   r   r   r    s
   

zMainWindow.configurec                 C   $   d}t r
|d t  }t|t  d S )Nzfetchmail -N -d0 --nosyslog -v -f rcfiler  r   r1   cmdr   r   r   r       zMainWindow.testc                 C   r  )Nzfetchmail -N -d0r  r  r  r   r   r   r    r  zMainWindow.runc                 C   r  r:   )quitr0   r   r   r   r    r  zMainWindow.leaver:   )r   r   r   r2   r  r  r  r  r   r   r   r   r    s    
-r  c                 C   s$   g }| D ]}||v r| | q|S r:   r  Zlist1Zlist2rj   rk   r   r   r   	intersect$     
r  c                 C   s$   g }| D ]}||vr| | q|S r:   r  r  r   r   r   setdiff,  r  r  c           	      C   s  t | D ]}|tvrt| qd}tt | j |}|  tt | |}|  t||}d|v r=|d t	|t	|krtt
d t||}|r^t
d| jj d t|  t||}|rmt
dt|  td d S t | D ]
}t| |||  qzd S )N)rU   rV   rY   rZ   r   r   r   r   r   r   r   r   Zshowdotsr^   r/   z/Fields don't match what fetchmailconf expected:zNot matched in class `z' signature: z Not matched in dictionary keys: rp   )rU  rV  r  r  r  __dict__sortr  removetupler   	__class__r   r6   r   r   r>  )	ZtoclassZfromdictr   ZoptionalZ	class_sig	dict_keyscommonZdiffrk   r   r   r   copy_instance4  s0   




r  __main__a	  
R0lGODdhPAAoAPcAAP///wgICBAQEISEhIyMjJSUlKWlpa2trbW1tcbGxs7Ozufn5+/v7//39yEY
GNa9tUoxKZyEe1o5KTEQAN7OxpyMhIRjUvfn3pxSKYQ5EO/Wxv/WvWtSQrVzSmtCKWspAMatnP/e
xu+1jIxSKaV7Wt6ca5xSGK2EY8aUa72MY86UY617UsaMWrV7SpRjOaVrOZRaKYxSIXNCGGs5EIRC
CJR7Y/+UMdbOxnNrY97Ove/Wvd7GrZyEa961jL2Ua9alc86ca7WEUntSKcaMSqVjGNZ7GGM5CNa1
jPfOnN6tc3taMffeve/WtWtaQv/OjGtSMYRzWv/erda1hM6te7WUY62MWs61jP/vzv/ntda9jL2l
czEhAO/n1oyEc//elDEpGEo5EOfexpyUe+/epefevffvxnNrQpyUStbWzsbGvZyclN7ezmNjWv//
5/f33qWllNbWve/vzv//1ufnve/vvf//xvf3vefnrf//taWlc0pKMf//pbW1Y///jKWlWq2tWsbG
Y///c97eUvf3Ut7nc+/3a87We8bOjOfv1u/37/f//621tb3Gxtbn52Nra87n53uUlJTv/6W9xuf3
/8bW3iExOXu11tbv/5TW/4TO/63e/zmt/1KUxlK1/2u9/wCM/73GzrXG1gBKjACE/87e72NzhCkx
OaXO92OMtUql/xCE/wApUtbe57W9xnN7hHut52Ot/xBSnABKnABavQB7/2ul7zF71gBr77XO73Oc
1lqc9yFSlBApSimE/wAYOQApY0J7zlKM5wAxhABS1gBj/6W95wAhWgA5nAAYSgBS7wBS/wBK9wAp
jABC5wBK/wApnABC/wApxgAhtYSMtQAQYwAp/3OE74SMxgAYxlpjvWNr70pS/wgQ3sbGzs7O1qWl
3qWl70pKe0JC/yEhlCkp/wgI/wAAEAAAIQAAKQAAOQAASgAAUgAAYwAAawAAlAAAnAAApQAArQAA
zgAA1gAA5wAA9wAA/0pC/xgQ52Na9ykhe4R7zikhYxgQSjEpQgAAACwAAAAAPAAoAAAI/wABCBxI
sKDBgwgTKiRIYKHDhxARIvgXsaLFhGgEUBSYoKPHjyBDihxJkuS/kwNLqlzJcuTJjQBaypxpEiVH
mjhxvkyZs2fLnTd9ehxAtKjRo0ZrwhTasUsENhYHKOUpk1E3j11mxCBiQVLEBlJd2owp9iVRjwUs
zMCQ5IcLD4saPVxjIKxIoGTvvqSoyFEFGTBeqEhyxAoSFR/USGKVcEGBAwDshsSr1OYTEyhQpJiS
ZcoUKWOQtJDRJFSaggzUGBgoGSTlsjahlPCRIkWVKT16THHRIoqIISBIEUgAYIGBhgRbf3ytFygU
FZp9UDmxQkkMCRwyZKDBQy4aApABhP8XqNwj88l7BVpQYZtF5iArWgwAgGZBq24HU7OeGhQ90PVA
aKZZCiiUMJ9ArSTEwGqR8ZeXfzbV0MIIMQTBwoUdxDDfAm8sZFyDZVEF4UYSKBEBD0+k6IEFPMxH
3FzldXSea+kBgANJSOWIlIMhXZXAXv+c1WM3PuJEpH8iuhbAkv+MdENPRHaTRkdF/jiWSKCAwlKW
VbbkY5Q0LgUSKExgoYBKCjCxARpdltQNKHaUoYAddnR53lVRnJLKBWh4RIEGCZx5FSOv1OLNDUVe
deZHaWiZAB35fIOGNtbEUeV5oGAByzPOrBPFGt3kwEgxITACSg5oLGGLMg60oQAjaNz/oAAcN4Ai
a0c3kHFDK3jYsw4g9sRzBgPLXdkRrBrQ8gsWQUxCCRZX9IJNBQ1s8IgCdeBCzBYN6IBIN2TUsQYd
dXhDBxdzlAHOHHKEcocZdWwDjx8MTCmjsR2FMAstw1RyiSzHqPLALaOwk8QmzCzDCSi0xJKMMk4E
Yw8389iTDT32GAKOPf7YY0Aa9tATyD3w/EGsefgmgEYUtPiChLKWQDMBJtEUgYkzH2RiTgGfTMCI
Mlu0Yc85hNiDziH2tMqOGL72QY47gshLb7Fi4roELcjoQIsxWpDwQyfS2OCJMkLI4YUmyhgxSTVg
CP2FHPZ80UDcieBjStNPD5LPOyZT/y0iHGiMwswexDSzRiRq6KIMJBc4M8skwKAyChia2KPH3P24
YU8/lFhOTj152OPOHuXMU4g48vCRiN/9rZGLMdS4csUu1JzDgxuipOMDHMKsAwEnq/ByzTrrZMNO
OtO0k84+7KjzBjzplMJOOOOoo8846/ATxqJWinkkGUyEkMAaIezABQM3bMAEK1xEsUMDGjARRxhY
xEGGHfPjEcccca6BRxhyuEMY7FCHMNDhf9140r2qRiVvdENQ3liUArzREW/0qRsRVIAGFfBADnLw
gUSiYASJpMEHhilJTEnhAlGoQqYAZQ1AiqEMZ0jDGtqQImhwwA13yMMevoQAGvGhEAWHGMOAAAA7
rp   zdf:hVr  versionz-dz-fz-hz--helpz-Vz	--versionzfetchmailconf %szRunning on pythona-  
Copyright (C) 1997 - 2003 Eric S. Raymond
Copyright (C) 2005 - 2021 Matthias Andree
fetchmailconf comes with ABSOLUTELY NO WARRANTY.  This is free software, you are
welcome to redistribute it under certain conditions.  Please see the file
COPYING in the source or documentation directory for details.zExtra arguments: 'z' ''ZDISPLAYz!fetchmailconf must be run under X.z^Cannot qualify my own hostname, "{}".
Fix /etc/hosts, see man 5 hosts, or add the host to DNS.)Z	fetchmailz--configdumpz
--nosyslogzException caught while running rc   z: r3   r   z.Can't parse output of fetchmail --configdump:
r.   ra   z-This is a dump of the configuration we read:
r   z/.fetchmailrczPPython's tk (tkinter) module is missing. Please install it to use fetchmailconf.)filer   ZwmZ	iconphotoz-default)r1  )wZ
__future__r   r   Zpast.builtinsr   Zfuturer   Zinstall_aliasesbuiltinsr   r   Z
past.utilsr   r	   r   rw  r*   r~  ZgetoptZtempfiler   
subprocessZtkinterZtkinter.dialogZhave_tkr   ry  ZMIN_PYversion_infor   r   r   rF   ro   rg   r  rf   r  r%  rh   r   r   r   r  r  r0  r;  r=  rM  rN  rD  rj  r  r  r  r  r  r  r  rP  r  r  r  r  r  r  r  r  r  r   rg  r  ZoptionsZ	argumentsZGetoptErrorrZ  rX  rl   r  Zswitchvalr   r  ri   r+   Zgethostnamer   ZgetfqdnrY  r  Zcheck_outputZ
configdumpr  r  Zfetchmailrcexecr5   re   r   r  r  r.   r  ZNewsiter  ra   r  ZNewuserr^   r6   stderrZTkr  r   Zfetchmail_icon_PIZcallZ_wrootZmainloopr   r   r   r   <module>   s  
B  V
	

S
	"G "&	!     L03D
:)$






,






 