]>
code.delx.au - offlineimap/blob - offlineimap/repository/Gmail.py
1 # Gmail IMAP repository support
2 # Copyright (C) 2008 Riccardo Murri <riccardo.murri@gmail.com>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 from IMAP
import IMAPRepository
19 from offlineimap
import folder
, imaputil
20 from offlineimap
.imapserver
import IMAPServer
22 class GmailRepository(IMAPRepository
):
23 """Gmail IMAP repository.
25 Uses hard-coded host name and port, see:
26 http://mail.google.com/support/bin/answer.py?answer=78799&topic=12814
29 #: Gmail IMAP server hostname
30 HOSTNAME
= "imap.gmail.com"
32 #: Gmail IMAP server port
35 def __init__(self
, reposname
, account
):
36 """Initialize a GmailRepository object."""
37 account
.getconfig().set('Repository ' + reposname
,
38 'remotehost', GmailRepository
.HOSTNAME
)
39 account
.getconfig().set('Repository ' + reposname
,
40 'remoteport', GmailRepository
.PORT
)
41 account
.getconfig().set('Repository ' + reposname
,
43 IMAPRepository
.__init
__(self
, reposname
, account
)
46 return GmailRepository
.HOSTNAME
49 return GmailRepository
.PORT
54 def getpreauthtunnel(self
):
57 def getfolder(self
, foldername
):
58 return self
.getfoldertype()(self
.imapserver
, foldername
,
59 self
.nametrans(foldername
),
60 self
.accountname
, self
)
62 def getfoldertype(self
):
63 return folder
.Gmail
.GmailFolder
65 def getrealdelete(self
, foldername
):
66 # XXX: `foldername` is currently ignored - the `realdelete`
67 # setting is repository-wide
68 return self
.getconfboolean('realdelete', 0)
70 def gettrashfolder(self
, foldername
):
71 #: Where deleted mail should be moved
72 return self
.getconf('trashfolder','[Gmail]/Trash')
74 def getspamfolder(self
):
75 #: Gmail also deletes messages upon EXPUNGE in the Spam folder
76 return self
.getconf('spamfolder','[Gmail]/Spam')