/head: changeset 18

Updated.
This commit is contained in:
jgoerzen 2002-06-20 08:40:29 +01:00
parent b179602b31
commit 3c199703c2
6 changed files with 101 additions and 9 deletions

56
head/offlineimap.conf Normal file
View File

@ -0,0 +1,56 @@
# Sample configuration file
# Copyright (C) 2002 John Goerzen
# <jgoerzen@complete.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[general]
# This specifies where imapsync is to store its metadata.
# This directory will be created if it does not already exist.
metadata = ~/.imapsync
# This variable specifies which accounts are defined. Separate them
# with commas. Account names should be alphanumeric only.
# You will need to specify one section per account below. You may
# not use "general" for an account name.
#
accounts = Test
# This is an account definition clause.
[Test]
# Specify the remote hostname.
remotehost = imap.postoffice.net
# Whether or not to use SSL.
ssl = yes
# Specify the port. If not specified, use a default port.
# remoteport = 993
# Specify the remote user name.
remoteuser = jgoerzen//quovix.com
# Specify the remote password. If not specified, you will be
# prompted.
# remotepass = fake
# Specify local repository.
localfolders = ~/Test

View File

@ -31,14 +31,14 @@ class IMAPFolder(BaseFolder):
def getuidvalidity(self):
x = self.imapobj.status(self.getfullname(), ('UIDVALIDITY'))[1][0]
uidstring = imaputil.imapsplit(x)[1]
return int(imaputil.flagsplit(x)[1])
return long(imaputil.flagsplit(uidstring)[1])
def cachemessagelist(self):
assert(self.imapobj.select(self.getfullname())[0] == 'OK')
self.messagelist = {}
response = self.imapobj.status(self.getfullname(), ('MESSAGES'))[1][0]
result = imaputil.imapsplit(response)[1]
maxmsgid = int(imaputil.flags2hash(result)['MESSAGES'])
maxmsgid = long(imaputil.flags2hash(result)['MESSAGES'])
# Now, get the flags and UIDs for these.
response = self.imapobj.fetch('1:%d' % maxmsgid, '(FLAGS UID)')[1]
@ -46,5 +46,12 @@ class IMAPFolder(BaseFolder):
# Discard the message number.
messagestr = imaputil.imapsplit(messagestr)[1]
options = imaputil.flags2hash(messagestr)
uid = long(options['UID'])
flags = imaputil.flagsimap2maildir(options['FLAGS'])
self.messagelist[uid] = {'uid': uid, 'flags': flags}
def getmessagelist(self):
return self.messagelist

View File

@ -35,7 +35,7 @@ class MaildirFolder(BaseFolder):
if not os.path.exists(self.uidfilename):
return None
file = open(self.uidfilename, "rt")
retval = int(file.readline().strip())
retval = long(file.readline().strip())
file.close()
return retval
@ -75,7 +75,7 @@ class MaildirFolder(BaseFolder):
uid = nouidcounter
nouidcounter -= 1
else:
uid = int(uidmatch.group(1))
uid = long(uidmatch.group(1))
flagmatch = re.search(':.*2,([A-Z]+)')
flags = []
if flagmatch:
@ -107,7 +107,7 @@ class MaildirFolder(BaseFolder):
if attempts > 15:
raise IOError, "Couldn't write to file %s" % messagename
messagename = '%d.%d.%s,U=%d' % \
(int(time.time()),
(long(time.time()),
os.getpid(),
socket.gethostname(),
uid)

View File

@ -58,6 +58,8 @@ class IMAPServer:
if self.delim == None:
self.delim, self.root = \
imaputil.imapsplit(imapobj.list('""', '""')[1][0])[1:]
self.delim = imaputil.dequote(self.delim)
self.root = imaputil.dequote(self.root)
return imapobj

View File

@ -66,7 +66,7 @@ def imapsplit(string):
workstr = workstr[len(parenlist):]
retval.append(parenlist)
elif workstr[0] == '"':
quotelist = re.search('^("([^"]|\\")*")', workstr).group(1)
quotelist = re.search('^("(?:[^"]|\\\\")*")', workstr).group(1)
workstr = workstr[len(quotelist):]
retval.append(quotelist)
else:
@ -75,3 +75,30 @@ def imapsplit(string):
retval.append(unq)
return retval
def flagsimap2maildir(string):
flagmap = {'\\Seen': 'S',
'\\Answered': 'R',
'\\Flagged': 'F',
'\\Deleted': 'T',
'\\Draft': 'D'}
retval = []
imapflaglist = flagsplit(string)
for imapflag in imapflaglist:
if flagmap.has_key(imapflag):
retval.append(flagmap[imapflag])
retval.sort()
return retval
def flagsmaildir2imap(list):
flagmap = {'S': '\\Seen',
'R': '\\Answered',
'F': '\\Flagged',
'T': '\\Deleted',
'D': '\\Draft'}
retval = []
for mdflag in list:
if flagmap.has_key(mdflag):
retval.append(flagmap[mdflag])
retval.sort()
return retval

View File

@ -31,13 +31,13 @@ class IMAPRepository(BaseRepository):
return self.imapserver.delim
def getfolder(self, foldername):
return folder.IMAP.IMAPFolder(self.imapserver, name)
return folder.IMAP.IMAPFolder(self.imapserver, foldername)
def getfolders(self):
if self.folders != None:
return self.folders
retval = []
for string in self.imapobj.list(self.imapserver.root)[1]:
for string in self.imapobj.list()[1]:
flags, delim, name = imaputil.imapsplit(string)
if '\\Noselect' in imaputil.flagsplit(flags):
continue