§
    ŽpmaZ  ã                   óB   — d Z ddlmZ ddlmZmZ  G d„ de¦  «        ZdS )a6  
Gmail IMAP repository support
Copyright (C) 2008-2016 Riccardo Murri <riccardo.murri@gmail.com> &
contributors

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
é    )ÚIMAPRepository)ÚfolderÚOfflineImapErrorc                   ób   ‡ — e Zd ZdZd„ Zˆ fd„Zˆ fd„Zˆ fd„Zd„ Zd„ Z	dd	„Z
d
„ Zd„ Zd„ Zˆ xZS )ÚGmailRepositorya-  Gmail IMAP repository.

    This class just has default settings for GMail's IMAP service. So
    you can do 'type = Gmail' instead of 'type = IMAP' and skip
    specifying the hostname, port etc. See
    http://mail.google.com/support/bin/answer.py?answer=78799&topic=12814
    for the values we use.c                 ó2   — t          j        | ||¦  «         dS )z$Initialize a GmailRepository object.N)r   Ú__init__)ÚselfÚ	reposnameÚaccounts      ú7/usr/share/offlineimap3/offlineimap/repository/Gmail.pyr	   zGmailRepository.__init__!   s   € åÔ  i°Ñ9Ô9Ð9Ð9Ð9ó    c                 ó‚   •— 	 t          ¦   «                              ¦   «         S # t          $ r d| _        | j        cY S w xY w)zœReturn the server name to connect to.

        We first check the usual IMAP settings, and then fall back to
        imap.gmail.com if nothing is specified.zimap.gmail.com)ÚsuperÚgethostr   Ú_host)r
   Ú	__class__s    €r   r   zGmailRepository.gethost%   sN   ø€ ð
	Ý‘7”7—?’?Ñ$Ô$Ð$øÝð 	ð 	ð 	ð *ˆDŒJØ”:ÐÐÐð	øøøs   ƒ# £>½>c                 ó„   •— t          ¦   «                              ¦   «         }|€d}|                      |¦  «         | j        S )zÈReturn the OAuth URL to request tokens from.

        We first check the usual OAuth settings, and then fall back to
        https://accounts.google.com/o/oauth2/token if nothing is
        specified.Nz*https://accounts.google.com/o/oauth2/token)r   Úgetoauth2_request_urlÚsetoauth2_request_urlÚoauth2_request_url)r
   Úurlr   s     €r   r   z%GmailRepository.getoauth2_request_url3   sA   ø€ õ ‰gŒg×+Ò+Ñ-Ô-ˆØˆ;à>ˆCà×"Ò" 3Ñ'Ô'Ð'àÔ&Ð&r   c                 óP   •— t          ¦   «                              ¦   «         }|�|S dS )z¨Return the port number to connect to.

        This Gmail implementation first checks for the usual IMAP settings
        and falls back to 993 if nothing is specified.Niá  )r   Úgetport)r
   Úportr   s     €r   r   zGmailRepository.getportC   s(   ø€ õ ‰wŒw�ŠÑ Ô ˆàÐØˆKàˆsr   c                 ó:   — |                       dd ¦  «        }|€dS |S )NÚsslT)Úgetconfboolean)r
   r   s     r   ÚgetsslzGmailRepository.getsslP   s(   € Ø×!Ò! %¨Ñ.Ô.ˆàˆ;ð �4àˆ
r   c                 ó   — d S ©N© ©r
   s    r   Úgetpreauthtunnelz GmailRepository.getpreauthtunnel[   s   € Øˆtr   Tc                 óL   —  |                       ¦   «         | j        || |¦  «        S r!   )ÚgetfoldertypeÚ
imapserver)r
   Ú
foldernameÚdecodes      r   Ú	getfolderzGmailRepository.getfolder^   s-   € Ø#ˆt×!Ò!Ñ#Ô# D¤O°ZØ$(¨&ñ2ô 2ð 	2r   c                 ó$   — t           j        j        S r!   )r   ÚGmailÚGmailFolderr#   s    r   r&   zGmailRepository.getfoldertypeb   s   € ÝŒ|Ô'Ð'r   c                 ó.   — |                       dd¦  «        S )z4
        Where deleted mail should be moved
        Útrashfolderz[Gmail]/Trash©Úgetconfr#   s    r   ÚgettrashfolderzGmailRepository.gettrashfoldere   s   € ð �|Š|˜M¨?Ñ;Ô;Ð;r   c                 ó.   — |                       dd¦  «        S )zî
        Depending on the IMAP settings (Settings -> Forwarding and
        POP/IMAP -> IMAP Access -> "When I mark a message in IMAP as
        deleted") GMail might also deletes messages upon EXPUNGE in
        the Spam folder.
        Ú
spamfolderz[Gmail]/Spamr0   r#   s    r   ÚgetspamfolderzGmailRepository.getspamfolderk   s   € ð �|Š|˜L¨.Ñ9Ô9Ð9r   )T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r$   r*   r&   r2   r5   Ú__classcell__)r   s   @r   r   r      sâ   ø€ € € € € ðð ð:ð :ð :ðð ð ð ð ð'ð 'ð 'ð 'ð 'ð ð ð ð ð ð	ð 	ð 	ðð ð ð2ð 2ð 2ð 2ð(ð (ð (ð<ð <ð <ð:ð :ð :ð :ð :ð :ð :r   r   N)r9   Úofflineimap.repository.IMAPr   Úofflineimapr   r   r   r"   r   r   ú<module>r=      sy   ððð ð( 7Ð 6Ð 6Ð 6Ð 6Ð 6Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0ðY:ð Y:ð Y:ð Y:ð Y:�nñ Y:ô Y:ð Y:ð Y:ð Y:r   