Commit Graph

39 Commits

Author SHA1 Message Date
Nicolas Sebrecht fc61c6fd30 Gmail: allow parenthesis in labels
Reported-by Heinrich Hartmann <Heinrich@HeinrichHartmann.com>
Tested-by Heinrich Hartmann <Heinrich@HeinrichHartmann.com>
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/545
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-18 02:10:56 +02:00
Nicolas Sebrecht 5836970d51 utf8foldernames: fix missing decode argument
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/502
Tested-by: https://github.com/pprw
Reviewed-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-29 00:45:32 +02:00
Nicolas Sebrecht 19442d0010 folder: Gmail: fix copyright header
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-08-15 01:24:23 +02:00
Nicolas Sebrecht a5d9edc560 folder: Gmail: remove dead code
The support for the realdelete configuration option was removed because this
could lead to data loss.

See 51728ed to know more.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-08-15 01:19:56 +02:00
lkcl dab5737265 learn repository retrycount configuration option
Allow retrying the download of messages more than twice.

Signed-off-by: Luke Kenneth Casson Leighton <lkcl@lkcl.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-12-19 12:55:55 +01:00
Nicolas Sebrecht 59b712ecbc remove dead code: the description of the passes is never used
Some minor style fixes.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-18 18:41:41 +02:00
Nicolas Sebrecht 7945e10a76 correctly reraise errors with six
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:56:14 +02:00
Nicolas Sebrecht 548a6a57f1 folder: Gmail: use consistent copyright line
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-28 02:29:30 +02:00
Łukasz Żarnowiecki 0addcbabf0 py3: raise exceptions using six module
There is no other way to make Python2 and Python3 happy, because syntax
raise E, V, T is incompatible with the latter.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 01:49:09 +02:00
Łukasz Żarnowiecki 068ac7c410 Replace calls to long with int calls
long was removed from Python3

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-10 02:53:09 +02:00
Nicolas Sebrecht 657f258196 folder: properly factorize initialization and dropping of self.message
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-09 18:12:18 +02:00
Valentin Lab f2ca4217c6 fix: broken retry loop would break connection management
The retry loop would release connection that would get
re-released upon ``finally`` clause. In consequence, an
exception would be cast.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-26 17:11:59 +01:00
Janna Martl 8096f6cd5b maxage: fix timezone issues, remove IMAP-IMAP support, add startdate option
1. When using maxage, local and remote messagelists are supposed to only
contain messages from at most maxage days ago. But local and remote used
different timezones to calculate what "maxage days ago" means, resulting
in removals on one side. Now, we ask the local folder for maxage days'
worth of mail, find the lowest UID, and then ask the remote folder for
all UID's starting with that lowest one.

2. maxage was fundamentally wrong in the IMAP-IMAP case: it assumed that
remote messages have UIDs in the same order as their local counterparts,
which could be false, e.g. when messages are copied in quick succession.
So, remove support for maxage in the IMAP-IMAP case.

3. Add startdate option for IMAP-IMAP syncs: use messages from the given
repository starting at startdate, and all messages from the other
repository. In the first sync, the other repository must be empty.

4. Allow maxage to be specified either as number of days to sync (as
previously) or as a fixed date.

Signed-off-by: Janna Martl <janna.martl109@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-07 11:54:35 +02:00
Nicolas Sebrecht 461554b7b1 more style consistency
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-10 17:25:00 +01:00
Eygene Ryabinkin e7fabf9e57 Properly re-raise exception to save original tracebacks
We usually mutate some exceptions to OfflineImapError() and it is
a whole lot better if such exception will show up with the original
traceback, so all valid occurrences of such mutations were transformed
to the 3-tuple form of "raise".  Had also added coding guidelines
document where this re-raise strategy is documented.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2015-01-12 17:51:21 +03:00
Abdo Roig-Maranges 2a5ef8c2ef Delete gmail labels header before adding a new one
This fixes a bug in which a message ended up with multiple gmail labels
header (X-Keywords or so). Fix fix it by removing all labels headers
before adding the updated one.

Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
2014-11-20 14:16:48 +01:00
Abdo Roig-Maranges fc4c7549d6 Do not ignore gmail labels if header appears multiple times
There should be just one header storing gmail labels, but due to a bug,
multiple X-Keywords (or equivalent) headers may be found on the local
messages.

Now we, when extracting the labels from a message, we read all label
headers, instead of just the first one.

This has the consequence that some old labels stored locally in a second
X-Keywords (or third...) header, which effectively was rendered
invisible to offlineimap until now, may pop back up again and be pushed
to gmail. No labels will be removed by the changes in this commit,
though.

Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
2014-11-20 14:15:59 +01:00
Eygene Ryabinkin 7df765cfdb Properly manipulate contents of messagelist for folder
Create initializer function that puts default values to all fields
of message list item.  Fix all code that directly assigns some hash
to the elements of messagelist: for direct assignments only initializer
is now permitted, all other modification are done in-place.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-08-03 16:47:26 +04:00
Eygene Ryabinkin e8db1217d4 Fix improper header separator for X-OfflineIMAP header
For servers without UIDPLUS we are inserting additional header
just after transformation '\n' -> CRLF was done.  addmessageheaders()
was written to work with just '\n' as the separator, so X-OfflineIMAP
header wasn't preceeded by the CRLF, but just by '\n'.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-06-01 22:12:26 +04:00
Abdo Roig-Maranges 8c43e52173 Fix multiple typos in var, function and exception names
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 18:29:47 +04:00
Abdo Roig-Maranges 8dd6f7893c Add import for OfflineImapError
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 18:29:47 +04:00
Abdo Roig-Maranges 09556d645e Adapt plain status folder to gmail labels stuff
* Implements Status Folder format v2, with a mechanism to upgrade an
    old statusfolder.

  * Do not warn about Gmail and GmailMaildir needing sqlite backend
    anymore.

  * Clean repository.LocalStatus reusing some code from
    folder.LocalStatus.

  * Change field separator in the plaintext file from ':' to '|'. Now
    the local status stores gmail labels. If they contain field
    separator character (formerly ':'), they get messed up. The new
    character '|' is less likely to appear in a label.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-06 23:37:11 +04:00
Abdó Roig-Maranges 789e047734 Extend handling of GMail labels header
Format headers X-Label and Keywords as a space separated list and all
other ones as comma-separated entities.  This makes OfflineIMAP label
handling to be compatible with some user agents that recognise these
headers.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-06 23:37:03 +04:00
Abdó Roig-Maranges 0e4afa9132 Make GmailFolder sync GMail labels
When synclabels config flag is set to "yes" for the GMail repo,
offlineimap fetches the message labels along with the messages, and
embeds them into the body under the header X-Keywords (or whatever
'labelsheader' was set to), as a comma separated list.

It also adds an extra pass to savemessageto, that performs label
synchronization on existing messages from GMail to local, the same way
it is done with flags.

We also introduce GmailMaildir repository that adds functionality to
change message labels.  It keeps track of messages modification time,
so one can quickly detect when the labels may have changed.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-06 23:36:06 +04:00
Sebastian Spaeth b33f2452f0 Use "from . import" for relative imports
Will fail in python3 otherwise.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-06 17:41:43 +01:00
Sebastian Spaeth 51728ed815 Remove Gmail realdelete option
It can lead to potential dataloss (see recent commit log where I added a
scary warning about it to offlineimap.conf).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-04 21:08:44 +01:00
Sebastian Spaeth 0d3303ec12 Remove visiblename as parameter to IMAPFolder creation
IMAPFolder has the repository and foldername values so it can get the
transposed (aka visiblename) of a folder itself just fine. There is no
need to pass it in as an separate parameter.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-09-16 12:54:29 +02:00
Sebastian Spaeth 410e2d35e9 Set accountname in BaseFolder, and don't pass it in initialization
We passed in the accountname to all derivatives of BaseFolder, such as
IMAPFolder(...,repository,...,accountname), although it is perfectly
possible to get the accountname from the Repository(). So remove this
unneeded parameter. Each backend had to define getaccountname() (although
the function is hardly used and most accessed .accountname directly).

On the other hand BaseFolder was using getaccountname but it never defined
the function. So make the sane thing, remove all definitions from backends
and define accountname() once in Basefolder. It was made a property and not
just a (public) attribute, so it will show up in our developer
documentation as public API.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-09-16 12:54:12 +02:00
Sebastian Spaeth c93cd9bb1a BaseFolder(): Save name and repository
As all Folders share these parameters, we can safely handle them in
BaseFolder. This makes sense, as BaseFolder has a getname() function
that returns self.name but nothing actually set self.name.

It also saves a few lines of code.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-09-16 12:54:12 +02:00
Sebastian Spaeth 0a25408199 Rework undocumented listjoin to create UID sequences
This function was badly named and completely undocumented. Rework it to
avoid copying the full UID list using an iterator. Make it possible to
hand it a list of UIDs as strings rather than implicitely relying on the
fact that they are numeric already. Document the code.

The behavior off the function itself remained otherwise unchanged.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-08-23 20:55:28 +02:00
Sebastian Spaeth 466ded04d9 Make flags a set rather than a list
As this is essentially what it is, a set of values. This allows as
to do set arithmetics to see, e.g. the intersection of 2 flag sets
rather than clunkily having to do:

for flag in newflags:
  if flag not in oldflags:
    oldflags.append(flag)

Also some more code documenting.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-08-19 18:56:10 +02:00
Sebastian Spaeth 306f584c86 Remove custom Gmail/folder/processmessagesflags()
This function was overridden as the IMAP version apparently had been
using imapobj.myrights() at some point in time, which was not
implemented in the Gmail version. However, IMAP is not using myrights()
anymore, and as that is an extension that needs to be advertised in
CAPABILITIES we should not unconditionally use it anyway.

So remove the function that is identical to it's ancestor's
function.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-08-14 17:14:35 +02:00
Ethan Glasser-Camp e2354fd37c Remove some unneeded imports
Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-03-14 19:51:52 +01:00
Sebastian 2fd57b4f2b Remove unneeded imports of UIBase
Code was broken, as these backends import UIBase (which had been moved).
However, they don't use it, so we can just delete the import.
Sorry, I failed to find those earlier somehow.

Signed-off-by: Sebastian <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-02-09 19:32:59 +01:00
John Goerzen 1f8024a70e [imaplib2 removal] Revert "Implementation of IMAP IDLE"
This reverts commit 3847d0ba9d.
2009-08-12 14:49:58 -05:00
James Bunton 3847d0ba9d Implementation of IMAP IDLE
- Use a newer version of imaplib
 - Hijack the keepalive process to send IDLE instead of NOOP
2009-02-10 11:27:48 +11:00
Henning Glawe 140be81efd make the trash and spam folder names in Gmail accounts configurable 2008-08-13 00:03:13 -05:00
John Goerzen db805043f2 Attempt to fix a crashing bug in Gmail driver
refs deb#469598

Bug report received in Debian.  User is having occasional trouble with Gmail
driver crashing, indicates problem may have started after switching to Gmail.

Gmail driver merged to tree in 81b86fb74 on 2008-01-03 and recently released
in beta tarballs.

BT shows:

  File "/var/lib/python-support/python2.4/offlineimap/folder/Gmail.py", line 102, in processmessagesflags
    attributehash = imaputil.flags2hash(imaputil.imapsplit(result)[1])
  File "/var/lib/python-support/python2.4/offlineimap/imaputil.py", line 88, in imapsplit
    for i in range(len(imapstring)):
TypeError: len() of unsized object

imap debug log shows:

imap:   29:58.16 > BEAL75 UID STORE 4887 +FLAGS (\Deleted)
imap:   29:58.47 < BEAL75 OK Success
imap:   29:58.47        matched r'(?P<tag>BEAL\d+) (?P<type>[A-Z]+) (?P<data>.*)' => ('BEAL75', 'OK', 'Success')
imap: imapsplit() called with input: None
imap: imapsplit() got a non-string input; working around.

looking at code for Gmail.py processmessagesflags, comments from Ricardo
indicate it was copied from the same function in folder/IMAP.py.

However, folder/IMAP.py has checks for this, added 2002-07-12 in
5342dacc & 817a10ce.  Suspect that Gmail author believed those checks
superfluous for Gmail.

Copied checks from folder/IMAP.py to folder/Gmail.py.
2008-03-08 07:47:53 -06:00
Riccardo Murri 81b86fb74c Add Gmail IMAP special support.
New repository/folder classes to support "real deletion" of messages
thorugh Gmail's IMAP interface: to really delete a message in Gmail,
one has to move it to the Trash folder, rather than EXPUNGE it.
2008-01-03 04:56:55 +01:00