Commit Graph

1826 Commits

Author SHA1 Message Date
Giel van Schijndel
b6ede627a9 SQLite: make postponing transaction committing possible.
This should significantly improve performance when used to write large
amounts of messages.

This feature is enabled through the fsync configuration option.

Code refactorize around fsync.

This addresses #390 (although it doesn't necessarily fix all instances
of that problem yet).

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/390
Originally-written-by: Giel van Schijndel <me@mortis.eu>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-28 20:31:57 +02:00
Nicolas Sebrecht
41c9694488 UIDMaps: ensure we don't update the map file in dry run mode
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/380
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-24 20:03:44 +02:00
Nicolas Sebrecht
2ac68d82aa UIDMaps: prevent from leaving a truncated map file
If the map file is not properly written (e.g. due to unexpected kill)
offlineimap might wrongly consider some UIDs to have been deleted from the local
side which could lead to data loss.

Use a temporary map file rather than writing to the map file directly.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/380
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-24 20:02:53 +02:00
Ilias Tsitsimpis
0a635bd236 Fix flickering in Blinkenlights UI
Do not call resizeterm(), unless is_term_resized() returns True. This
breaks the busy-loop where resizeterm() pushes a KEY_RESIZE onto the
FIFO causing the screen to be redrawn indefinitely (Issue #290).

Also, clear and refresh the main window after it has been resized. This
hopefully fixes the problem where Blinkenlights UI becomes unreadable
after terminal resize (Issue #160).

Closes #160: blinkenlights display is broken
Closes #290: ncurses flicker with blinkenlights UI
Bug-Debian: https://bugs.debian.org/671087
Bug-Debian: https://bugs.debian.org/809676
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-20 14:11:51 +02:00
Nicolas Sebrecht
5d705f26e2 UIDMaps: reorder imports
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-18 14:58:02 +02:00
Nicolas Sebrecht
097d1e07fa folder: IMAP: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-18 13:56:35 +02:00
Nicolas Sebrecht
b81cb6f5e2 v7.0.8
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-08 10:10:56 +02:00
Ilias Tsitsimpis
e8b79c6bff Import ui before threadutil to resolve circular dependency
The `threadutil` module depends on the `ui` module, which cycle depends
on `threadutil` through the `Curses` module.

The `ui` module had been loaded before the `threadutil` module, breaking
the above circular dependency, but this was changed in a recent code
refactoring, preventing the `Curses` module from being loaded with the
following exception:

  File "./offlineimap.py", line 23, in <module>
    from offlineimap import OfflineImap
  File "offlineimap/offlineimap/__init__.py", line 20, in <module>
    from offlineimap.init import OfflineImap
  File "offlineimap/offlineimap/init.py", line 30, in <module>
    from offlineimap import globals, threadutil, accounts, folder, mbnames
  File "offlineimap/offlineimap/threadutil.py", line 25, in <module>
    from offlineimap.ui import getglobalui
  File "offlineimap/offlineimap/ui/__init__.py", line 28, in <module>
    from offlineimap.ui import Curses
  File "offlineimap/offlineimap/ui/Curses.py", line 27, in <module>
    from offlineimap.threadutil import ExitNotifyThread
ImportError: cannot import name ExitNotifyThread

Fix the above error by ensuring that the `ui` module gets loaded before
the `threadutil` module. Please note that the above fix is temporary,
and we should refactor the modules to not have circular dependencies.

Bug-Debian: https://bugs.debian.org/839862
Reported-by: Neil McGovern <neilm@debian.org>
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-10-07 08:47:21 +02:00
Stéphane Albert
57e6eda617 Fix implicit call to unicode() from UI functions
BaseFolder now exposes an __unicode__ method so that function needing
unicode transcoding don't crash due to ascii encoding errors.

Signed-off-by: Stéphane Albert <sheeprine@oh.its.fake.nullplace.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-23 17:40:44 +02:00
Nicolas Sebrecht
c0f4fa44eb imapserver: minor code cleaning: reorder methods
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-23 16:27:22 +02:00
Nicolas Sebrecht
e57b499145 v7.0.7
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-21 04:03:25 +02:00
Nicolas Sebrecht
3d3e66fbb2 ensure logs are in bytes for PLAIN authentication
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-21 03:54:41 +02:00
Nicolas Sebrecht
95c82b91be minor: utils: distro: fix copyright line
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-21 00:51:42 +02:00
Espen Henriksen
4ee1518b64 Add gentoo cert path for OS-DEFAULT
Signed-off-by: Espen Henriksen <dev@henriksen.is>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-21 00:41:20 +02:00
Nicolas Sebrecht
c287ecb7cc set singlethreadperfolder configuration option when in idle mode
Git-reference: https://github.com/OfflineIMAP/offlineimap/issues/376
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-20 02:36:56 +02:00
Nicolas Sebrecht
bd4b968f1d repository: IMAP: cache the idle folders in memory
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-20 02:36:56 +02:00
Nicolas Sebrecht
dbcfc0b173 idle: protect all calls to imapobj.noop() (coonection might be dropped)
Some code refactoring.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-13 04:41:31 +02:00
Nicolas Sebrecht
41764a0ec6 mbnames: add info output messages in dry run mode
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-26 01:44:15 +02:00
Nicolas Sebrecht
520e99d8b6 mbnames: remove non-required argument
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-26 01:38:03 +02:00
Nicolas Sebrecht
38c6785636 XOAUTH2: raise error if string 'error' is in the response
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/374
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-23 01:19:30 +02:00
Nicolas Sebrecht
59d254c783 v7.0.6
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-21 20:43:03 +02:00
Nicolas Sebrecht
71d86b6d47 XOAUTH2: improve error message while trying to get access token
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/338
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-21 20:30:19 +02:00
Nicolas Sebrecht
1884fd7ef6 show python version for -V CLI option
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-15 04:53:23 +02:00
Nicolas Sebrecht
9c386154bb XOAUTH2: correctly strip values for evaluated credentials
Don't use lambda anymore as default value.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:33:37 +02:00
Nicolas Sebrecht
13043b5877 XOAUTH2: strip newlines of the returned values for the eval configuration options
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:17:09 +02:00
Nicolas Sebrecht
00e6627299 XOAUTH2: function was changed to not have argument
Fix the default lambda.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:13:25 +02:00
Nicolas Sebrecht
b4fe69028b XOAUTH2: let the user call the evaluated functions in the configuration
Don't pass the account name to the function returned by eval. This allows the
user to define his own arguments.

This fix the code according to the documentation provided in offlineimap.conf.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/372
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 22:35:09 +02:00
James E. Blair
560363ef73 learn singlethreadperfolder configuration option
To further ensure that messages are synchronized strictly in UID
order, this option can be set to cause only one thread to be used
to synchronise an individual folder, though other folders may
be synchronized simultaneously by other threads.

Signed-off-by: James E. Blair <corvus@gnu.org>
Based-on-patch-by: James E. Blair <corvus@gnu.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 02:20:51 +02:00
James E. Blair
a5ea1827fb folder: Base: sort message UID list
Return a sorted list of UIDs in getmessageuidlist.

Some MUAs (and their users) like to display messages in UID order
(or "order received").  If offlineimap is used in IMAP<->IMAP mode,
then the order messages are received by the second IMAP server will
be different because offlineimap iterates over a UID list produced
from the keys of a dictionary, which is unsorted.

This change sorts that list of UIDs so that both IMAP servers will
have their messages in the same order (except those times where
messages are appended to folders on both repositories between
syncs).

Signed-off-by: James E. Blair <corvus@gnu.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 01:56:13 +02:00
Nicolas Sebrecht
d263af91e0 Maildir: add missing exception instance "as e" in except clause
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-13 16:28:32 +02:00
Nicolas Sebrecht
f62f5b5656 v7.0.5
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-10 15:03:17 +02:00
Wieland Hoffmann
ad2070f0d4 Remove an unused import
Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-09 22:40:45 +02:00
Nicolas Sebrecht
473be4c66f folder: Base: minor fix style
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-09 17:36:26 +02:00
Nicolas Sebrecht
6b313aabd3 don't delete messages in local cache in dry-run mode
This makes dry-run consitent when called more than once.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/370
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-09 15:02:03 +02:00
Łukasz Żarnowiecki
f634546980 explicitly set __hash__ of Base class to None
This suppressing the warning generated when running offlineimap on
python2 with -3 switch:

  offlineimap/folder/Base.py:29: DeprecationWarning: Overriding __eq__
  blocks inheritance of __hash__ in 3.x

Since this object is mutable it should not be hashable.

From Python documentation[1]:

  A class that overrides __eq__() and does not define __hash__() will
  have its __hash__() implicitly set to None.

Therefore old behaviour is preserved.

[1] https://docs.python.org/3/reference/datamodel.html

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-06 01:32:26 +02:00
Łukasz Żarnowiecki
48611398e0 imapserver: change lambdas with map to list comprehension
It is more readable and returns a list.

This continues work done in 19c4330.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-05 00:06:26 +02:00
Nicolas Sebrecht
cbd1a8929a folder: IMAP: change raw assert to OfflineImapError
There is not reason to block remainings actions on first error on UID STORE.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-04 02:21:22 +02:00
Christopher League
c7434ea46c Fix typo in format string in machineui
This was causing the error message "not all arguments converted during
string formatting." Specifically:

```
% offlineimap -u machineui
OfflineIMAP 7.0.4
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
msg:protocol:MainThread:7.2.0
msg:initbanner:MainThread:OfflineIMAP+7.0.4%0A++Licensed+under+the+GNU+GPL+v2+or+any+later+version+%28with+an+OpenSSL+exception%29
msg:registerthread:Account+sync+MYHOST:MYHOST
msg:acct:Account+sync+MYHOST:MYHOST
error::Account+sync+MYHOST:ERROR%3A+While+attempting+to+sync+account+%27MYHOST%27%0A++not+all+arguments+converted+during+string+formatting
msg:acctdone:Account+sync+MYHOST:MYHOST
msg:threadExited:MainThread:Account+sync+MYHOST
msg:unregisterthread:MainThread:Account+sync+MYHOST
msg:terminate:MainThread:0%0A%0A
```

Signed-off-by: Christopher League <league@contrapunctus.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-04 02:20:10 +02:00
Nicolas Sebrecht
fc54fe52a0 folder: IMAP: add 'imap' debug output before calling FETCH
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-03 01:25:39 +02:00
Nicolas Sebrecht
91f13e9b03 v7.0.4
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-02 20:26:49 +02:00
Nicolas Sebrecht
b19eaebad1 ConfigHelperMixin must be new-style class to not break inheritance
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/363
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-30 04:26:25 +02:00
Nicolas Sebrecht
e460228bfc v7.0.3
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-30 01:56:10 +02:00
Nicolas Sebrecht
203c28f21f add the repository name when connecting
Otherwise, it might be impossible to know which account is connecting when more
than one is syncing.

Code style.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-30 01:44:27 +02:00
Nicolas Sebrecht
9aa5afa951 XOAUTH2: fix the *_eval configuration options
They introduce a regression not allowing to discard the XOAUTH2 method when
expected.

The default lambda did not take the "account_name" argument.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/362
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-29 16:38:58 +02:00
Nicolas Sebrecht
b4e33eeac4 XOAUTH2: use one "public" attribute everywhere for self.oauth2_request_url
Improve documentation.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 18:35:33 +02:00
Nicolas Sebrecht
be285e522d IMAP: don't take junk data for valid mail content
OfflineIMAP frequently delivers mail files to the Maildir consisting exclusively
of a single ASCII digit in IDLE mode. IMAPFolder.getmessage expects 'data' to be
of the form

  [(fetch-info, message-body)]

However, the imapobj.uid call in getmessage returns a list of *all* pending
untagged FETCH responses.  If any message flags were changed in the selected
IMAP folder since the last command (by another client or another thread in
OfflineIMAP itself), the IMAP server will issue unsolicited FETCH responses
indicating these flag changes (RFC3501, section 7).  When this happens, 'data'
will look like, for example

  ['1231 (FLAGS (\\Seen) UID 5300)',
   '1238 (FLAGS (\\Seen) UID 5318)',
   ('1242 (UID 5325 BODY[] {7976}', message-body)]

Unfortunately, getmessage retrieves the message body as data[0][1], which in
this example is just the string "2", and this is what gets stored in the mail
file.

Multi-threaded OfflineIMAP with IDLE or holdconnectionopen is particularly
susceptible to this problem because flag changes synced back to the IMAP server
on one thread will appear as unsolicited FETCH responses on another thread if it
happens to have the same folder selected.  This can also happen without IDLE or
holdconnectionopen or even in single-threaded OfflineIMAP with concurrent access
from other IMAP clients (webmail clients, etc.), though the window for the bug
is much smaller.

Ideally, either imaplib2 or getmessage would parse the fetch responses to find
the response for the requested UID.  However, since IMAP only specifies
unilateral FETCH responses for flag changes, it's almost certainly safe to
simply find the element of 'data' that is a tuple (perhaps aborting if there is
more than one tuple) and use that.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/162
Based-on-patch-by: Austin Clements <amdragon@MIT.EDU>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 07:18:23 +02:00
Nicolas Sebrecht
0ef11a8392 folder/IMAP: code style
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 06:51:47 +02:00
Nicolas Sebrecht
0b824bdc49 offlineimap.conf: allow non-spaces in the account list
Commit c992f58530 pretends to fix this bug it doesn't.

Regression introduced in v7.0.0.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/355
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 04:06:52 +02:00
Nicolas Sebrecht
88e8a4895e minor code enhancements
- More class inherit from object.
- Initialize all attributes.
- Code style.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 00:42:35 +02:00
Nicolas Sebrecht
7fe90b8e0d properly ignore folders with invalid characters (sep) in their name
Commit 6b28071b0f makes the check once nametrans is applied. This is wrong
because separators are valid characters in names returned by nametrans. E.g:

  "Sent" -> "[Gmail]/Sent"

Make the check against the raw name of the folder, instead.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/353
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 18:45:18 +02:00
Nicolas Sebrecht
ce1de85157 v7.0.2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 16:38:55 +02:00
Philipp Meier
560d631706 GmailMaildir: don't add a tuple to syncmessagesto_passes
Regression introduced by 59b712ecbc.

Fix-found-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Philipp Meier <github@philipp.meier.name>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 16:29:34 +02:00
Nicolas Sebrecht
b521b98d99 offlineimap.conf: learn to evaluate oauth2 related options
Introduce:
- oauth2_client_id_eval
- oauth2_client_secret_eval
- oauth2_access_token_eval
- oauth2_refresh_token_eval

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/307
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 04:25:18 +02:00
Ævar Arnfjörð Bjarmason
a1efae0703 Remove double import of "six"
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 03:19:14 +02:00
Nicolas Sebrecht
65295b01ef v7.0.1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 08:53:18 +02:00
Nicolas Sebrecht
2f060aa269 Merge tag 'v6.7.0.3' into next
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 08:47:19 +02:00
Nicolas Sebrecht
ecef22a16c v6.7.0.3
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 08:46:22 +02:00
Nicolas Sebrecht
77a6f9a7ba LocalStatusSQLite: code refactoring around database lock
Backported-from: 05e5b9c6bb
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 02:58:09 +02:00
Nicolas Sebrecht
05e5b9c6bb LocalStatusSQLite: code refactoring around database lock
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 02:56:36 +02:00
Nicolas Sebrecht
038a433f69 backport: sqlite: properly serialize operations on the databases
1. There is one database per folder and sqlite requires to serialize the
writings. Instead of locking at LocalStatusSQLiteFolder object level, introduce
a new DatabaseFileLock object which is shared across threads. This fixes the
concurrent writes issues that some users might experience by duplications or
flags restored to the previous state.

2. Close the database only when we are sure no other threads will use the
connection on a *per-file* basis. Previous fix 677afb8d8f is wrong
because the same lock is shared for all the databases.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 02:00:17 +02:00
Nicolas Sebrecht
3c42913120 sqlite: properly serialize operations on the databases
1. There is one database per folder and sqlite requires to serialize the
writings. Instead of locking at LocalStatusSQLiteFolder instance level,
introduce a new DatabaseFileLock object which is shared across threads. This
fixes the concurrent writes issues that some users might experience by
duplications or flags restored to the previous state.

2. Close the database only when we are sure no other threads will use the
connection on a *per-file* basis. Previous fix 677afb8d8f is wrong
because the same lock is shared for all the database files.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-26 01:57:25 +02:00
Nicolas Sebrecht
5aa2a883f0 local status: deletemessagelist: remove broken code
This did not work and is not usefull since the purge() method was introduced in
1410a391bc. Actually, the purge() does what deletemessagelist() was supposed to
achieve.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-25 15:06:39 +02:00
Nicolas Sebrecht
fbc3b15888 IMAP/IMAP: fix import issue about UIDMaps
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-25 05:26:57 +02:00
Nicolas Sebrecht
03859e89c3 improve error message when ssl_version must be set due to the tls_level
Improve the ssl documentation.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-25 03:29:25 +02:00
Nicolas Sebrecht
c992f58530 offlineimap.conf: allow non-spaces in the account list
Regression introduced in v7.0.0.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/355
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-24 19:39:43 +02:00
Nicolas Sebrecht
284c66b04a v7.0.0
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 16:56:43 +02:00
Nicolas Sebrecht
41fdd4ee78 v6.7.0.2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 16:34:04 +02:00
Nicolas Sebrecht
e753766284 sqlite: close the database when no more threads need access
It's required to have more than one connection to the database for the
maxconnections configuration option to work with threads. However,
connection.close() is closing all the connections. Only close the connection
when no more thread need it.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 16:30:38 +02:00
Nicolas Sebrecht
677afb8d8f sqlite: close the database when no more threads need access
It's required to have more than one connection to the database for the
maxconnections configuration option to work with threads. However,
connection.close() is closing all the connections. Only close the connection
when no more thread need it.

Backported-from: 856b74407bd7f634cae5a8c2d9b84e13d14c12d2
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 09:19:09 +02:00
Nicolas Sebrecht
034c55a278 --info: allow user to enter a password
Change from basic UI to ttyui.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/352
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-22 01:44:38 +02: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
80dcf76414 fix attribute name _utime_from_header
Code style.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-16 21:25:14 +02:00
Nicolas Sebrecht
59f5da5e9e Maildir: OfflineImapError is missing the severity argument
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/350
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-16 18:02:01 +02:00
Nicolas Sebrecht
1a96d588d5 fix: configparser does not know about python types like u""
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/347
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-13 14:02:25 +02:00
Nicolas Sebrecht
742e53a4b4 v7.0.0-rc5
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-12 16:15:33 +02:00
Nicolas Sebrecht
ff0c1a2efc --help: make it clear --delete-folder is for the remote repository
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-09 02:11:36 +02:00
Nicolas Sebrecht
3f059c638a --help: move -V option up
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-09 01:28:51 +02:00
Nicolas Sebrecht
2e81331a3c learn --delete-folder CLI option
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-08 21:34:25 +02:00
Nicolas Sebrecht
bb8e03bced init: factorize code to get active accounts
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-08 21:34:25 +02:00
Nicolas Sebrecht
d2dbe2c544 mbnames: enable action at correct time
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-08 21:31:30 +02:00
Nicolas Sebrecht
175479d919 mbnames: fix the filename extension for the intermediate files
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-06 01:15:33 +02:00
Nicolas Sebrecht
b3209e38c0 mbnames: output message on errors while reading intermediate files
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-06 00:38:43 +02:00
Nicolas Sebrecht
218b3802c0 v7.0.0-rc4
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-04 04:05:37 +02:00
Nicolas Sebrecht
44a8cf3feb threadutil: use 'with' statements for lock
Improve code for waiting the accountThreads.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:03:14 +02:00
Nicolas Sebrecht
29e06a60f9 learn to not download UIDs defined by the user
Allow users to workaround offending emails that offlineimap can't download.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht
f0096391fc folder: IMAP: fix wrong comment
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht
1086d0dd69 minor: improve "Copy message" output
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht
f4210dc11c folder: IMAP: improve style of comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht
296c8a6146 UIDMaps: correctly protect from concurrent writes
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:00:21 +02:00
Nicolas Sebrecht
cd43cd5b3b UIDMaps: code cleanups and improvements
- Use more 'with' statements.
- Remove dead code: 'dolock' was never used.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:00:21 +02:00
Nicolas Sebrecht
c32b409413 UIDMaps: fix copyright line and re-order imports
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:58:45 +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
69c0080323 learn --mbnames-prune CLI option
This is usefull to remove dangling entries for removed accounts or if mbnames is
not enabled anymore.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:54:41 +02:00
Nicolas Sebrecht
4ef05fe6e1 minor: init: re-order imports
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:54:13 +02:00
Nicolas Sebrecht
932e826d7c folder: Maildir: add comments about FMD5 issues
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:53:45 +02:00
Nicolas Sebrecht
6b28071b0f don't sync folders with local separator characters in their names
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/148
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:52:34 +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
Nicolas Sebrecht
38f28d15aa v7.0.0-rc3
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-27 15:47:26 +02:00
Nicolas Sebrecht
1da5bd938c folder: Base: fix line continuation
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-27 15:27:11 +02:00
Nicolas Sebrecht
65d4c94f07 don't try to copy messages with UID == 0
Output a warning so that we can dig into this. For now, the patch doesn't fix
the root cause. If the server returns UID 0 as valid UID number, this must be
ignored as soon as possible.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/336
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-27 15:13:03 +02:00
Nicolas Sebrecht
9a7603af37 minor: folder: Base: improve style and comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-27 15:03:27 +02:00
Nicolas Sebrecht
e8509a04e6 remove dead code
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:09:03 +02:00
Nicolas Sebrecht
cf5698b6a6 repository: IMAP: minor improvements
Make it clear what value is the default.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:02:28 +02:00
Nicolas Sebrecht
ac2a547ec4 learn to disable STARTTLS
Some servers might have this feature broken.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/207
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:01:01 +02:00
Nicolas Sebrecht
1410a391bc avoid removing of data when user removed a maildir
When a maildir is removed it must be considered new for the sync. However, the
local cache of the folder remains. This means the sync of the folder removes all
the missing emails.

Avoid loosing of data for users not aware of the local cache by removing any
pre-existing status cache of a folder when we actually want to create the
database.

Improve style.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/333
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:00:23 +02:00
Nicolas Sebrecht
08e17de7e2 require usernames and passwords to be UTF-8 encoded
- Learn to support UTF-8 characters where it was not supported for usernames and
  passwords (but for netrc).
- Fix the types in the code for both py2 and py3: we now expect unicode for
  usernames and passwords.

Unicode (UTF-8) is required only for variables with non-ASCII characters.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 16:57:22 +02:00
Nicolas Sebrecht
092264c8e7 fix: when called with -a, mbnames must not erase entries of other accounts
Make mbnames to work with intermediate files, one per account, in the JSON
format. The mbnames target is built from those intermediate files.

Github-Fix: https://github.com/OfflineIMAP/offlineimap/issues/66
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-25 17:33:42 +02:00
Nicolas Sebrecht
3a5becf6a7 bump from imaplib2 v2.53 to v2.55
- Expose more literals.
- Fix a type to bytes.
- Fix comment.

Changes submitted upstream by Łukasz and me.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-11 11:08:02 +02:00
Nicolas Sebrecht
e3fe848c6b minor code cleanups
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 19:03:02 +02:00
Nicolas Sebrecht
7fcd160911 GmailMaildir: quick mode is not compatible with utime_from_header
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 19:02:04 +02:00
Nicolas Sebrecht
8c9f63a9b5 repository/IMAP: add minor comment
Some minor cleanups on whitespaces.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 16:01:58 +02:00
Nicolas Sebrecht
8cca78b265 v6.7.0.1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 02:02:32 +02:00
Nicolas Sebrecht
3f70d9ef37 sqlite: open database when we use it rather than at instantiation time
Backported from 8e995a69bfa003ab822b55731429d84b3bc5626f.

We currently close the database as soon as possible while we handle the status
backend but this is still too early because autorefresh induces looping on this
code block.

Instead of delaying the closing outside of the loop, it's easier to delay the
opening as late as possible (inside the loop). The downside is that the database
is opened/closed more than once when autorefresh is enabled. The good news is
that this make the code much easier.

Fixes regression introduces by 6fb5700.

Reported-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 01:59:39 +02:00
Nicolas Sebrecht
b840e66d59 SQLite: close db when done
Backported from 6fb5700f94.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 01:59:14 +02:00
Nicolas Sebrecht
effe1d85a8 LocalStatusSQLite: remove dead code: sqlite import fails early
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-07 17:46:18 +02:00
Nicolas Sebrecht
a41fecd057 learn -V CLI option
Help users to get the versions while reporting bugs.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-07 00:36:57 +02:00
Nicolas Sebrecht
19ac578a50 sqlite was made mandatory: import error can fail at import time
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-06 15:18:29 +02:00
Nicolas Sebrecht
fd0198027a --info displays the imaplib2 version and whether it's the bundled or system one
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 15:23:53 +02:00
Nicolas Sebrecht
9902a116c0 init: improve style of code comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 15:23:51 +02:00
Nicolas Sebrecht
703ac7718d v7.0.0-rc2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 12:45:45 +02:00
Nicolas Sebrecht
acc9c3cf49 introduce a virtual imaplib2
The virtual imaplib2 first try to import imaplib2 when provided by the system.
If not provided or if the version is not supported, fallback on the bundled
imaplib2 version.

Distribution maintainers can now easily remove the bundled imaplib2 version if
they want to get it packaged outside of offlineimap.

We still want to provide imaplib2 by default because:
- this library is neither in Python core nor packaged by a lot of distributions;
- users expect to be able to run offlineimap by just downloading the tarball or
  after a git clone.

In order to avoid unexpected (too old) versions of imaplib2, we restrict the
supported versions of this librabry.

Reviewed-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 12:17:53 +02:00
Nicolas Sebrecht
922bed05a7 threading: improve comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-04 02:25:44 +02:00
Nicolas Sebrecht
56f473326a bump imaplib2 from v2.52 to v2.53
Be aware upstream has two versions of both 2.52 and 2.53.

This bump change is from

 commit a205409a0047732840505e534c07d8d85d2644a1
 Author: Piers Lauder <piers@janeelix.com>
 Date:   Sun Dec 27 20:55:04 2015 +1100

     Back out BINARY changes - not implemented correctly.

to

  commit 0596e7372fd3556d27ea55510b1e8cfa8370ec43
  Author: Piers Lauder <piers@janeelix.com>
  Date:   Fri Jun 3 11:58:40 2016 +1000

      new version of imaplib2.py

Original-imaplib2-patch-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-03 12:09:40 +02:00
Łukasz Żarnowiecki
48ae1a36c8 maildir: Create top level dir recursively
This patch fixes the situation when "localfolders" specifies path that
is more that one level deep and top directory does not exists.  Example
would be "localfolders = ~/Mail/a".  This especially relevant on the
first run.

In that case we would end up with unhandled exception causing
unexpected termination of the program.

Thread 'Account sync test' terminated with exception:
Traceback (most recent call last):
  File "/offlineimap/offlineimap/threadutil.py", line 172, in run
    Thread.run(self)
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/offlineimap/offlineimap/accounts.py", line 258, in syncrunner
    self.localrepos  = Repository(self, 'local')
  File "/offlineimap/offlineimap/repository/__init__.py", line 82, in __new__
    return repo(name, account)
  File "/offlineimap/offlineimap/repository/Maildir.py", line 40, in __init__
    os.mkdir(self.root, 0o700)
OSError: [Errno 2] No such file or directory: '/Mail/a'

By replacing call to "mkdir" with "makedirs" we can simply create
directories recursively.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-01 19:49:55 +02:00
Nicolas Sebrecht
f00cbeed5a IMAP: ignore UID with 0 as value when searching for UIDs
Some servers are broken: they return zero as valid UID and respond "BAD invalid
parameter: 0" on the FETCH command.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-25 03:33:06 +02:00
Nicolas Sebrecht
b14f37942a globals: use whitespaces instead of tabs
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-22 23:31:54 +02:00
Nicolas Sebrecht
bb1160f0ee minor: fix copyright date
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-20 18:20:07 +02:00
Nicolas Sebrecht
b8c3e51739 v7.0.0-rc1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-19 09:25:01 +02:00
Nicolas Sebrecht
a2a8a908ca threading: fix variable names about namespaces
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-19 08:36:23 +02:00
Nicolas Sebrecht
0b32e787c7 imapserver: use boolean where it makes sense
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-19 08:33:14 +02:00
Nicolas Sebrecht
46a6bcbf1c threading: suggeststhreads must honor CLI and conf options
There's no need to honor them twice.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 04:23:02 +02:00
Nicolas Sebrecht
e0fdcb3852 threading: improve variable names and factorize code
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 04:23:02 +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
Nicolas Sebrecht
83539f8601 threading: minor improvements
Factorize string, enhance comments and minor code improvements.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 01:32:06 +02:00
Nicolas Sebrecht
f93b0963fa instancelimitedsems does not need a lock but must be used with global
All the calls to initInstanceLimit are at initialization time from the same
thread.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 01:32:06 +02:00
Nicolas Sebrecht
c843f34876 threading: get rid of the syncaccount function
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 01:32:06 +02:00
Nicolas Sebrecht
7ab18276f9 get rid of offlineimap/syncmaster.py
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 01:32:06 +02:00
Nicolas Sebrecht
857b2f449a threading: rename threadslist to accountThreads
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 01:32:06 +02:00
Nicolas Sebrecht
9f8aa38d62 threading: simplify names
Improve comments.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 01:32:06 +02:00
Łukasz Żarnowiecki
23f96ba880 Encode utf-8 argument for md5 function
Python3 accepts binary input for md5 function.

This patch is known to break setups using folder names not strictly conforming
the IMAP UTF-7 encoding. We always made it clear that such setup is unsupported
and might be broken at some point in time. See documentation about
'decodefoldernames' in the provided configuration file. This is why this patch
is considered introducing no regression for this use case.

Patches to support both Python 3 and Python 2 by re-encoding the MD5 in the
filenames are welcome. This likely requires a new CLI option to allow
backporting the feature for users downgrading or changing of Python environment.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-17 00:44:02 +02:00
Łukasz Żarnowiecki
2465e1ce6a Replace dictionary iteration methods
Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-16 23:18:26 +02:00
Nicolas Sebrecht
05c75e8c8d sqlite: open database when we use it rather than at instantiation time
We currently close the database as soon as possible while we handle the status
backend but this is still too early because autorefresh induces looping on this
code block.

Instead of delaying the closing outside of the loop, it's easier to delay the
opening as late as possible (inside the loop). The downside is that the database
is opened/closed more than once when autorefresh is enabled. The good news is
that this make the code much easier.

Fixes regression introduces by 6fb5700.

Reported-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-12 18:51:59 +02:00
Nicolas Sebrecht
14ef992444 conf: newmail_hook is a remote option
Improve documentation.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-12 18:04:41 +02:00
Nicolas Sebrecht
a1f40af033 threading: simplify the monitoring code for threads
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-12 05:29:49 +02:00
Nicolas Sebrecht
87cf6bda02 threadutil: don't limit the number of threads
With a maxsize to the Queue of threads we are introducing a blocking call while
adding new threads.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-12 04:35:57 +02:00
Nicolas Sebrecht
2611a0ba6a threading: add comments
Simplify the code.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-12 04:35:21 +02:00
Nicolas Sebrecht
bf8bfbc872 folder: utime_from_header is for Maildir only
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-11 04:10:13 +02:00
Łukasz Żarnowiecki
12866f2771 Wrap zip calls with list call
In Python3, zip returns iterator instead of list.

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
Łukasz Żarnowiecki
ca2d85a6dc Remove xreadlines calls
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
Łukasz Żarnowiecki
5476b68c25 Replace xrange with range
xrange was removed in Python3 while range exists in boths versions.

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
Łukasz Żarnowiecki
a3bd5d4d38 Replace has_key method to "key in dict"
There is no such method in Python3 any more.

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
Łukasz Żarnowiecki
19c43308b9 Change filter with lambda to list comprehension
It is more readable and returns a list therefore it is compatible both
with Python 2 and 3.

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
Ł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
Łukasz Żarnowiecki
3848bc55f3 Add workaround for string.split for 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
Łukasz Żarnowiecki
4fbb5640ac Convert basestring to str
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
Łukasz Żarnowiecki
1fb8ba9631 Rename email.Parser to email.parser
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
Łukasz Żarnowiecki
b5d9652bc9 Do not mix tabs with spaces
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
Łukasz Żarnowiecki
c327bec6c8 Convert except X,T to except X as T
Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-10 02:53:08 +02:00
Łukasz Żarnowiecki
6b8ee4a183 Handle maxage for davmail correctly
"imapobj.search" returns a list with one string element of numbers
separated by one whitespace character for regular box (GMail, AOL...).
['1 2 3 4 5 6 7 8 9 10 11 12']
But if we would like to sync from Davmail it would return a list of
numbers.
['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'].

The code "return res_data[0].split()" in the first case will return what
we already have when using Davmail, hence only one email will be
fetched.  But if only the first sync would be with maxage the emails
will be removed, because offlineimap will think that they were removed
by us.

The patch distinguishes between syncing with Davmail and regular box and
applies split on the first element only when it finds whitespace
character.  It also handles the case when the first element is empty on
first sync.

Closes #327

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-07 13:29:44 +02:00
Łukasz Żarnowiecki
92e5455eb4 Inform when maxage/startdate is in the future
Sometimes it might happen that you put wrong date and you except emails
to be fetched, but they are not and you do not have an idea why.

By raising exception the user will see a proper message telling that he
used the wrong date for maxage/startdate property.

If someone wants to set a future date intentionally might as well sync
in the future.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-05 23:50:24 +02:00
Nicolas Sebrecht
141abfdf50 don't write a pid file
This was likely used to avoid multiple instances but this is supported for
several years.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-26 23:49:45 +02:00
Nicolas Sebrecht
2fb2f840dc XOAUTH2: don't force oauth2_request_url to be defined
Not all users want XOAUTH2.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-25 18:38:31 +02:00
Nicolas Sebrecht
2fc5d2a814 XOAUTH2: raise error when oauth_request_url is missing for IMAP type
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-25 17:38:42 +02:00
Nicolas Sebrecht
d5853b5d65 learn to not delete messages
This enables the "append" mode feature. Configuration option is sync_deletes in
both local and remote repositories. Marked EXPERIMENTAL and UNTESTED.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-09 22:08:28 +02:00
Nicolas Sebrecht
41e275e9a2 make sqlite status cache the default
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-09 21:06:38 +02:00
Nicolas Sebrecht
6fb5700f94 SQLite: close db when done
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-09 19:55:26 +02:00
Nicolas Sebrecht
1ba5e9160d minor: logs: print readonly message in all debug modes
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-09 18:57:00 +02:00
Nicolas Sebrecht
801dda521e accounts.py: minor improvements
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-09 18:50:12 +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
Nicolas Sebrecht
9486a0dab3 IMAP: don't try to create empty folders
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-09 17:35:15 +02:00
Nicolas Sebrecht
8c7a7355a3 v6.7.0
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-03-10 17:08:18 +01:00
Ilias Tsitsimpis
c84d23b656 Identify and fix messages with FMD5 inconsistencies
Introduce the '--migrate-fmd5-using-nametrans' option which migrates the
FMD5 hashes from versions prior to 6.3.5.

It seems that commit 'Apply nametrans to all Foldertypes' (6b2ec956cf)
introduced a regression because it changed the FMD5 part of the filename
calculated by OfflineIMAP. Thus, OfflineIMAP believes that the messages
has been removed and adds them back.

For more information, see:
http://www.offlineimap.org/configuration/2016/02/12/debian-upgrade-from-jessie-to-stretch.html

Bug-Debian: https://bugs.debian.org/812108
Reported-by: François <francois@avalenn.eu>
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-03-06 21:01:51 +01:00
Ben Boeckel
d8398ba374 Curses, UIBase: remove references to __bigversion__
__bigversion__ was removed in 281bcefb52.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-03-05 06:47:24 +01:00
Ebben Aries
9bfd610230 change hard coding of AF_UNSPEC to user-defined address-families per repository
Some environments that return AAAA records for their IMAP servers can pose
problems for clients that do not have end-to-end IPv6 connectivity for a number
of reasons (e.g. policy, lack of full routing, security, etc..)

Even with a fallback mechanism in place, you can still arrive at IMAP
implementations that could prevent authentication from unknown IPv6 space. This
in itself is not enough to fallback to IPv4 since there is an actual connection
on that socket.

This change is for introducing a user-defined value:

  [Repository imap-remote]
  ipv6 = no

to create a preference per repository on which AF to connect to the remote
server on

ipv6 = yes (AF_INET6)
ipv6 = no (AF_INET)
unspecified = default

Signed-off-by: Ebben Aries <e@dscp.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-23 06:57:21 +01:00
Nicolas Sebrecht
893a90c291 v6.7.0-rc2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-22 12:47:42 +01:00
Nicolas Sebrecht
9fe337d4fb fix year of copyright
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-22 12:24:15 +01:00
Nicolas Sebrecht
281bcefb52 versioning: avoid confusing pip by spliting out __version__ with __revision__
Python tools are not used to a __revision__.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-22 12:14:49 +01:00
Nicolas Sebrecht
36375daee6 fix: exceptions.OSError might not have attribute EEXIST defined
Since this is used in an except calse, we first don't mask the real cause and
raise the original error.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-19 12:33:57 +01:00
Nicolas Sebrecht
36165e391f update links to the new URL www.offlineimap.org
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-19 12:10:23 +01:00
Ray Song
b670bb2022 XOAUTH2 handler: urlopen with proxied socket
Signed-off-by: Ray Song <i@maskray.me>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-15 11:14:50 +01:00
Ilias Tsitsimpis
37bcd45e4e Abort after three Ctrl-C keystrokes
By default, OfflineIMAP catches SIGTERM/SIGHUP/SIGINT and attempts to
gracefully terminate as soon as possible. Allow the user to abort
immediately, by hitting Ctrl-C several times.

Bug-Debian: https://bugs.debian.org/679975
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-04 15:30:14 +01:00
Nicolas Sebrecht
426905ba85 v6.7.0-rc1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-01-24 19:47:14 +01:00
Nicolas Sebrecht
1553e843b3 Revert "Don't output initial blurb in "quiet" mode"
This reverts commit a1dc76ae91.

Causes a crash when using Blinkenlights UI with -l CLI option.

  $ ./offlineimap.py -c offlineimap.conf.minimal -u blinkenlights -l foo
  Traceback (most recent call last):
    File "./offlineimap.py", line 36, in <module>
      oi.run()
    File "/tmp/offlineimap/offlineimap/init.py", line 50, in run
      options, args = self.__parse_cmd_options()
    File "/tmp/offlineimap/offlineimap/init.py", line 205, in __parse_cmd_options
      self.ui.setlogfile(options.logfile)
    File "/tmp/offlineimap/offlineimap/ui/UIBase.py", line 119, in setlogfile
      self.logger.info(msg)
    File "/usr/lib/python2.7/logging/__init__.py", line 1159, in info
      self._log(INFO, msg, args, **kwargs)
    File "/usr/lib/python2.7/logging/__init__.py", line 1278, in _log
      self.handle(record)
    File "/usr/lib/python2.7/logging/__init__.py", line 1288, in handle
      self.callHandlers(record)
    File "/usr/lib/python2.7/logging/__init__.py", line 1328, in callHandlers
      hdlr.handle(record)
    File "/usr/lib/python2.7/logging/__init__.py", line 751, in handle
      self.emit(record)
    File "/tmp/offlineimap/offlineimap/ui/Curses.py", line 305, in emit
      color = self.ui.gettf().curses_color
  AttributeError: 'CursesLogHandler' object has no attribute 'ui'

Reported-by: iliastsi
Github-issue: #293
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-01-08 17:33:00 +01:00
ojab
cfa704bbf2 Allow authorization via XOAUTH2 using access token
Signed-off-by: Slava Kardakov <ojab@ojab.ru>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-12-30 00:25:57 +01:00
Nicolas Sebrecht
7ed71fa742 v6.6.1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-12-28 01:32:37 +01:00
Nicolas Sebrecht
c8a511bb7e bump imaplib2 from 2.52 to 2.53
Remove support for binary send.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-12-28 01:18:16 +01:00
Nicolas Sebrecht
452ada330a folder/Maildir: ignore dot files
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-12-05 12:49:41 +01:00
Nicolas Sebrecht
4a06c2af24 v6.6.0
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-12-05 00:39:43 +01:00
Nicolas Sebrecht
02a5f77780 bump imaplib2 from v2.52 to v2.53
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-28 23:38:22 +01: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
Nicolas Sebrecht
5e0f733c3e Merge branch 'ia/maildir-keywords' into next 2015-11-22 20:06:43 +01:00
Nicolas Sebrecht
d6077a09cf Keywords: avoid warning at each message when no keywords are used
This fix does not apply when any keyword in configured which is already
harmless.

Written-by: Igor Almeida <igor.contato@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-22 20:05:34 +01:00
Igor Almeida
58a6f8b401 __syncmessagesto_flags: refactor for readability
Extract the flag/keyword translation and combination logic to a
function.

Signed-off-by: Igor Almeida <igor.contato@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-22 19:51:33 +01:00
Igor Almeida
61ee6e783e __syncmessagesto_flags: store keywords
This uses the destination folder's keyword mapping to translate the
message's keywords into some appropriate format.

Tested only with local Maildir.

Signed-off-by: Igor Almeida <igor.contato@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-22 19:51:20 +01:00
Igor Almeida
73a3767d11 IMAP folder: expose the message keywords
The keywords are in the flag string, so imaputil can just strip the
usual \Flags.

Signed-off-by: Igor Almeida <igor.contato@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-22 19:51:02 +01:00
Igor Almeida
4e2de8f58a Maildir repository: add config keys for IMAP keywords
This commit assembles a dictionary mapping user-specified IMAP keywords
to Maildir lower-case flags, similar to Dovecot's format
http://wiki2.dovecot.org/MailboxFormat/Maildir

Configuration example:

[Repository Local]
type = Maildir
localfolders = ~/Maildir/
customflag_a = $label1
customflag_b = $Forwarded
customflag_c = Junk

Signed-off-by: Igor Almeida <igor.contato@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-22 19:50:43 +01:00
Igor Almeida
c52ca66874 Maildir folder: extract lower-case letters (custom flags) from filename
Remove filtering that was previously done to avoid errors in flag
handling.

Signed-off-by: Igor Almeida <igor.contato@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-22 19:50:22 +01:00
Valentin Lab
6a6b01f1a1 fix: replace rogue print statement by self.ui.debug
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-09 11:47:39 +01:00
Nicolas Sebrecht
c5c45cc687 minor: add parenthesis to print in init
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-09 04:40:05 +01:00
Valentin Lab
4087f3a4e7 add a full stack of all thread dump upon EXIT or KILL signal in thread debug mode
Note that the stacks are grouped if similar, and the current
process (the one handling the signal) is identified and reports
where it was before the signal.

This can be quite handy when wanting to debug thread locks for
instance.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-09 04:39:42 +01:00
Nicolas Sebrecht
86a91f28c0 v6.6.0-rc3
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-05 09:26:01 +01:00
Nicolas Sebrecht
04babea607 bump from imaplib2 v2.51 to v2.52
Thanks-to: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-05 09:07:31 +01:00
Nicolas Sebrecht
74e5ff5785 Merge branch 'renard-timestap-maildir' into next 2015-11-04 10:37:57 +01:00
Valentin Lab
b2adf2d258 fix: avoid writing password to log
Github-fix: #266
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-04 08:00:50 +01:00
Sébastien Gross
3b30c4aa93 add new config option filename_use_mail_timestamp
If this value is true, use (if possible) a timestamp based on message
Date or Delivery-date headers. The current system time is used
otherwise.

filename_use_mail_timestamp and utime_from_header are now completely
separated option that do not interfere one with other.

To handle this feature in a multithread context we use a hash to count
the number of mail with the same timestamp. This method is more accurate
than using the old lasttime and timeseq variables.

Signed-off-by: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-11-04 00:56:46 +01:00
Max Vilimpoc
1becbff786 enable SSL by default
Fix-github-issue: #263
Signed-off-by: Max Vilimpoc <github@vilimpoc.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-29 16:13:44 +01:00
Nicolas Sebrecht
b7fec93661 v6.6.0-rc2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-15 04:55:34 +02:00
Nicolas Sebrecht
91d089641b bump imaplib2 from v2.50 to v2.51
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-15 04:15:37 +02:00
Nicolas Sebrecht
2a637bd457 bump impalib2 from v2.49 to v2.50
Allows ssl3 protocol to not be available.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-13 14:37:43 +02:00
Nicolas Sebrecht
63db8776e0 Noninteractive: add minor comment
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-13 00:52:43 +02:00
Ben Boeckel
e18428b25b UIBase: add a syslog ui
Rather than having an option for syslog output, make a separate UI
option.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-13 00:48:18 +02:00
Nicolas Sebrecht
3daddb9b33 folder/IMAP: minor indent fix
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-13 00:45:51 +02:00
Ben Boeckel
428bb77984 Noninteractive: fix docstring for Basic
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-13 00:40:27 +02:00
Janna Martl
ee0de28cc4 utime_from_header: handle out-of-bounds dates
Handle case where email's internal time is erroneously so large as to
cause overflow errors when setting file modification time with
utime_from_header = true.

Reported-by: Cameron Simpson <cs@zip.com.au>
Signed-off-by: Janna Martl <janna.martl109@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-12 16:19:23 +02:00
Ben Boeckel
f03afcd224 imapserver: add a tls_level option
Allow the user to block usage of known-bad versions of SSL and TLS.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-12 15:54:15 +02:00
Nicolas Sebrecht
9bb27de375 do use the XOAUTH2 url if configured
fix regression introduced by af640208e1.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-12 07:51:05 +02:00
Nicolas Sebrecht
af640208e1 make XOAUTH2 configuration option optional
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-12 07:42:30 +02:00
Nicolas Sebrecht
ebb2124dbb Merge branch 'Frizlab-gmail-oauth-2' into next 2015-10-06 14:25:15 +02:00
Christopher Corley
f7efaa2093 learn XOAUTH2 authentication
Signed-off-by: François Lamboley <francois.lamboley@happn.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-06 14:24:42 +02:00
Nicolas Sebrecht
cc3cbaea05 bump imaplib2 from v2.48 to v2.49
Includes changes to new TLS option.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-09-30 13:29:59 +02:00
Prashant Sachdeva
2f1c856c04 fix status code to reflect success or failure to sync
Return value set to 1 if sync failed and error is thrown. Otherwise set to 0 if successful.

Signed-off-by: Prashant Sachdeva <sachdevp@cs.ubc.ca>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-09-29 08:31:46 +02:00
Nicolas Sebrecht
fb12fc1975 v6.6.0-rc1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-09-28 03:09:43 +02:00
Nicolas Sebrecht
f591fe66cc Merge branch 'mathstuf-syslog-logging' into next 2015-09-27 04:14:54 +02:00
Ben Boeckel
585e5d5e2e logging: add a switch to log to syslog
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-09-27 04:12:33 +02:00
Nicolas Sebrecht
71dd03e88c Bump imaplib2 from 2.43 to 2.48
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-09-14 14:56:17 +02:00
Nicolas Sebrecht
55ca922dd1 Merge branch 'krafczyk-new-mail-hook-2' into next 2015-09-11 21:04:52 +02:00
Matthew Krafczyk
48bb2f4113 Added the newmail_hook
When new mail arrives, this hook is triggered, allowing the user to
play a sound, or launch a popup.

Signed-off-by: Matthew Krafczyk <krafczyk.matthew@gmail.com>
2015-09-11 20:34:38 +02:00
Nicolas Sebrecht
ebf9e24f87 Merge branch 'fix/225' of git://github.com/milouse/offlineimap into milouse-fix/225 2015-09-04 15:50:58 +02:00
Étienne Deparis
41692d0328 Try to fix #225 « Runonce (offlineimap -o) does not stop if autorefresh is declared in DEFAULT section »
Signed-off-by: Étienne Deparis <etienne@depar.is>
2015-09-04 12:12:28 +02:00
Tommie Gannert
a6e7b6627b Add decodefoldernames option to decode IMAP folder names using UTF-7.
Signed-off-by: Tommie Gannert <tommie@gannert.se>
2015-08-29 16:43:33 +01:00
Nicolas Sebrecht
ca1ce256ec v6.5.7
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-05-15 15:20:18 +02:00
Alex Kapranoff
07af72081a report UID validity problem in exit code
Since skipping a folder means no new data is downloaded, the UID validity
problem is a backup failure. Make it possible to alert or work around
it in scripts by signaling with the exit code.

Signed-off-by: Alex Kapranoff <alex@kapranoff.ru>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-05-11 14:38:31 +02:00
Nicolas Sebrecht
c8e5f32eba Merge branch 'kappa-error-in-exit-status' into next 2015-05-10 12:01:09 +02:00
Alex Kapranoff
a817400d76 report exceptions via exit code
Now it is possible to handle failed syncs in scripts.

Signed-off-by: Alex Kapranoff <alex@kapranoff.ru>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-05-10 12:00:23 +02:00
Nicolas Sebrecht
223a7d0f7f Merge branch 'mjhoy-fix-dst' into next 2015-04-09 01:50:51 +02:00
Michael Hoy
8dd146d8fe folder/IMAP: fix datetuple dst check
Signed-off-by: Michael Hoy <mjh@mjhoy.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-09 01:50:18 +02:00
Nicolas Sebrecht
c3f3012cfc accounts: remove unused imaplibutil import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-07 16:34:35 +02:00
Nicolas Sebrecht
548fa6e57f v6.5.7-rc4
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-07 12:31:51 +02:00
Nicolas Sebrecht
a9ed2ff98a folder/Maildir: fix emailutil import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-07 11:57:30 +02: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
71693b7d8c Maildir: fix imports of emailutil
Commit 0c17350e4f revisited utime_for_header without taking care of the
imports.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-06 23:50:56 +02:00
Abdo Roig-Maranges
c094304f93 make savemessagelabels honor utime_from_header
Previously, syncing labels on a message always resulted in updating the
file modification time, even with utime_from_headers=true

This patch restores the file mtime to the previous value when
utime_from_headers=true, preventing a label synchronization from
breaking the promise that the file mtimes coincide with the header date.

Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-06 17:49:36 +02:00
Abdo Roig-Maranges
0c17350e4f decouple utime_from_header from rtime
We were using rtime for two different purposes:
- to store remote internal date
- to use in the utime_from_header option

Let's decouple the utime_from_header logic from rtime, now rtime means
remote internal date.

Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-03 11:30:30 +02:00
Nicolas Sebrecht
3a056519f9 Merge branch 'pilou--tests1' into next 2015-04-02 19:32:37 +02:00
Pierre-Louis Bonicoli
1cdf34e100 remove unnecessary imaplib2 workaround
Upstream bug has been fixed, since imaplib2 v2.42 the untagged responses are
flushed (as stated by the documentation).
See https://sourceforge.net/p/imaplib2/bugs/7/

Signed-off-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@gmx.fr>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-04-02 19:32:15 +02:00
Nicolas Sebrecht
5a4e4fd0c2 rename utime_from_message to utime_from_header
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-27 16:50:17 +01:00
Nicolas Sebrecht
05fa311878 Revert "fix: don't loose local mails because of maxage"
This partially reverts commit 25513e9038.
Only changes about dates and times are reverted. The changes about the style are
kept.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-26 12:05:11 +01:00
Nicolas Sebrecht
1708fd09d1 imaplib2: bump to v2.43
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-25 13:39:13 +01:00
Ben Boeckel
4217fccb82 mbnames: add option to write the file once per account
The basic problem is in the context of syncing multiple accounts where
one is fast and the others are slower (due to the number of folders).
When the fast account completes, the other accounts are partially written
through the list and if the file is read during this time, the list can
be useless. However, in the general case, the file is probably left
around from a previous run of offlineimap and is more correct, so add an
option to leave it alone until all syncing is done.

Incremental is still the default since this running offlineimap using
its own timer setup is likely the most common setup. Turning it off
works best with one-shot mode triggered by cron or systemd timers.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-22 21:15:46 +01:00
Janna Martl
731129396c fix: don't copy messages if not necessary
Fix regresssion introduced in 428349e3.

Prevent messages with UID's already in the destination folder from getting
excluded from the copy list.

Signed-off-by: Janna Martl <janna.martl109@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-22 10:42:29 +01:00
Janna Martl
428349e3f4 fix inaccurate UI messages when some messages are excluded from the cached lists
Some messages were excluded from the copy/delete list after the UI message said
they were copied/deleted.
Also fix Internaldate2epoch(), which was wrong.

Signed-off-by: Janna Martl <janna.martl109@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-21 14:10:57 +01:00
Nicolas Sebrecht
97689ee484 v6.5.7-rc3
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-20 11:33:29 +01:00
Nicolas Sebrecht
f11eaaea6f contrib: introduce script to make new releases
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-20 11:31:27 +01:00
Nicolas Sebrecht
ebf1a9300a imaplib2: bump to version 2.42
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-20 11:03:17 +01:00
Nicolas Sebrecht
300f884c09 idle: continue trying selecting the folder on OfflineImapError.Error
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-18 23:09:34 +01:00
Nicolas Sebrecht
43dbe1578c imaplib2: bump to v2.41
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-18 21:54:36 +01:00
Nicolas Sebrecht
11fd0eb5a4 --help: put a bit more informations
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-17 12:27:34 +01:00
Nicolas Sebrecht
6d72fd74af Merge branch 'holomorph-remoteuser' into next 2015-03-10 23:06:17 +01:00
Mark Oteiza
a629b4e0e7 do not error if remoteuser is not configured
Signed-off-by: Mark Oteiza <mvoteiza@udel.edu>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-10 23:06:09 +01:00
Nicolas Sebrecht
0b43418911 docs: full refactoring of the MANUAL
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-10 16:33:30 +01:00
Janna Martl
25513e9038 fix: don't loose local mails because of maxage
Suppose messages A and B were delivered to the remote folder at
"maxage + 1" days ago.

A was downloaded to the local folder "maxage + 1" days ago, but B was only
downloaded "maxage - 1" days ago (contrived scenario to illustrate the two
things that could happen). The behavior was that B gets deleted from the local
folder, but A did not. The expected behavior is that neither is deleted.

Starting where Base.py: __syncmessagesto_delete(self, dstfolder, statusfolder)
is called where:
 - self is the remote folder
and
 - dstfolder is the local folder.

It defines deletelist to be the list of messages in the status folder
messagelist that aren't in the remote folder messagelist with

  not self.uidexists(uid)

A and B are both in the status folder. They're also both *NOT* in the remote
folder messagelist: this list is formed in IMAP.py: cachemessagelist(), which
calls _msgs_to_fetch(), which only asks the IMAP server for messages that are
"< maxage" days old.

Back to Base.py __syncmessagesto_delete(), look at the call
folder.deletemessages(deletelist), where folder is the local folder. This ends
up calling Maildir.py deletemessage() for each message on the deletelist. But we
see that this methods returns (instead of deleting anything) if the message is
in the local folder's messagelist. This messagelist was created by Maildir.py's
cachemessagelist(), which calls _scanfolder(), which tries to exclude messages
based on maxage. So at this point, we *WANT* A and B to be excluded -- then they
will be spared from deletion. This maxage check calls _iswithinmaxage(), and
actually does the date comparison based on the time found at the beginning of
the message's filename. These filenames were originally created in Maildir.py's
new_message_filename(), which calls _gettimeseq() to get the current time (i.e.
the time of retrieval).

Upshot: A's filename has an older timestamp than B's filename. A is excluded
from the local folder messagelist in _scanfolder(), hence spared from deletion
in deletemessage(); B is not excluded, and is deleted.

This patch does not address the timezone issue. As for the IMAP/timezone issue,
a similar issue is discussed in the thunderbird bug tracker here:

https://bugzilla.mozilla.org/show_bug.cgi?id=886534

In the end, they're solving a different problem, but they agree that
there is really no reliable way of guessing the IMAP server's internal
timezone.

Signed-off-by: Janna Martl <janna.martl109@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-09 10:31:54 +01:00
Nicolas Sebrecht
efc4df1bd7 LocalStatusSQLite: labels: don't fail if database returns unexpected None value
This requires more researches. See
  https://github.com/OfflineIMAP/offlineimap/issues/103
.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-22 14:15:55 +01:00
Nicolas Sebrecht
ca06819e70 imaplibutil: add missing errno import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-17 10:34:20 +01:00
夏恺(Xia Kai)
d36209a305 add proxy support powered by PySocks
Read proxy option in imapserver, instantiate a class in imaplibutil
using a self-defined keyword and a socket instance, and use this socket
instance to substitute the default socket instance used in imaplib2.

Signed-off-by: 夏恺(Xia Kai) <xiaket@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-17 10:34:20 +01:00
Nicolas Sebrecht
a1383da9b3 LocalStatusSQLite: provide information on what is failing for OperationalError
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-16 10:31:21 +01:00
Nicolas Sebrecht
73952b8c2c offlineimap.conf: say what is the default value for the sep option
Some style improvements.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-13 17:43:29 +01:00
Nicolas Sebrecht
655c2b1fb9 sqlite: provide offending filename when open fails
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-13 17:18:07 +01:00
Nicolas Sebrecht
9e63fa3784 fix: folder/*: never set self.messagelist to None
Empty the list by setting an empty dict.
Introduce BaseFolder().ismessagelistempty().

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-13 17:07:18 +01:00
Nicolas Sebrecht
baee2b6fd9 fix: folder/Base: missing """ for doc string
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-13 17:07:18 +01:00
Nicolas Sebrecht
95eb8697f9 folder: LocalStatus: avoid to redefine 'file'
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-10 17:35:44 +01: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
fd79baade5 Merge branch 'next' of github.com:OfflineIMAP/offlineimap into next 2015-01-31 10:08:07 +03:00
Eygene Ryabinkin
7ab779ab21 Imaplib2: use proper tracebacks for exceptions
Get real tracebacks (at the point that calls Request.abort()
and not from the point that handles collected abort requests)
and pass them to our calling functions to ease debugging
of user problems.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2015-01-19 00:18:14 +03:00
Nicolas Sebrecht
cb6790b804 minor: fix indentation
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-18 21:52:09 +01:00
Nicolas Sebrecht
d0cb96781c folder: LocalStatus(SQLite): avoid redefining unchanged Base method
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-18 21:52:09 +01:00
Nicolas Sebrecht
2af3d93a85 folder: LocalStatusSQLite: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-18 21:52:09 +01:00
Nicolas Sebrecht
285295c4f2 folder: LocalStatus: revamp cachemessagelist()
- Do not redefine "file".
- break loop as soon as possible.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-18 21:52:09 +01:00
Nicolas Sebrecht
17980baea6 v6.5.7-rc2
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-18 21:29:37 +01:00
Eygene Ryabinkin
f69613965f Make OS-default CA certificate file to be requested explicitely
This simplifies logics for the user, especially if he uses both
fingerprint and certificate validation: it is hard to maintain
the compatibility with the prior behaviour and to avoid getting
default CA bundle to be disabled when fingerprint verification
is requested.

See
  http://thread.gmane.org/gmane.mail.imap.offlineimap.general/6695
for discussion about this change.

Default CA bundle is requested via 'sslcertfile = OS-DEFAULT'.

I had also enforced all cases where explicitely-requested CA bundles
are non-existent to be hard errors: when users asks us to use CA
bundle (and, thus, certificate validation), but we can't find one,
we must error out rather than happily continue and downgrade to
no validation.

Reported-By: Edd Barrett <edd@theunixzoo.co.uk>
Reviewed-By: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2015-01-18 22:05:49 +03:00
Nicolas Sebrecht
7b2fbeee74 repository: GmailMaildir: fix copyright
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-14 18:01:05 +01:00
Nicolas Sebrecht
ab3423d039 localeval: avoid redefining 'file' keyword
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-14 17:18:48 +01:00
Nicolas Sebrecht
41fa3ae4fc more style consistency
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-13 18:16:25 +01:00
Eygene Ryabinkin
6fc9c36014 Fix regression introduced in 0f40ca4799
We have no variable "fullname", it must have been slipped in
unintentionally.

Blame commit:
	0f40ca4799 more style consistency

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-12 19:55:05 +01:00
Wieland Hoffmann
d08f6d15c2 addmessageheader: Add a note about the incorrect rendering of the docstring
The note tells people to look at the source of the method, which
spinx.ext.viewcode conveniently links right next to the methods
signature.

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
2015-01-12 17:17:42 +01:00
Giovanni Mascellani
29e9b7ab39 Drop caches after having processed folders.
This enhances a lot memory consumption when you have many folders
to process.

Signed-off-by: Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
2015-01-12 17:17:42 +01:00
Nicolas Sebrecht
63e499c6f2 more consistent style
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-12 17:17:42 +01:00
Nicolas Sebrecht
a44718130d minor: add comments
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-12 17:17:42 +01:00
Nicolas Sebrecht
c2b8a99fa2 repository: IMAP.py: do not redefine string
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-12 17:17:42 +01:00
Nicolas Sebrecht
14de280585 repository: Base: add comment about lying variable name self.uiddir
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-12 17:17:42 +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
Nicolas Sebrecht
8c6abc413e ui: Machine: remove offending param for a _printData() call
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-10 12:36:18 +01:00
Nicolas Sebrecht
f2010cdfb0 Machine.py; more consistent style
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-10 12:36:18 +01:00
Stefan Huber
561a3d4329 Do not keep reloading pyhtonfile, make it stateful
CustomConfigParser.getlocaleval() loads "pythonfile" at each call.
Besides unnecessary IO, in case that dynamic_folderfilter is true, the
code in "pythonfile" would behave stateless, since it is re-initialized
at each call of getlocaleval(), i.e., at every sync. Fix that by keeping
a singleton copy of localeval in CustomConfigParser after the first call
of getlocaleval().

Signed-off-by: Stefan Huber <shuber@sthu.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-10 12:36:18 +01:00
Wieland Hoffmann
4bc766035c error: Log the messages with level ERROR
Otherwise, messages logged through UIBase.error would only be passed to
UIBase._msg, which only logs at INFO. This causes error to not get
logged at all for the quit UI.

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-10 12:36:18 +01:00
Wieland Hoffmann
2f9d8d22ee folder/Base.py: fix comment: para -> param
Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-09 01:10:49 +01:00
Nicolas Sebrecht
0f40ca4799 more style consistency
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-08 23:36:19 +01:00
Nicolas Sebrecht
594a286888 repository/Maildir.py: use f variable instead of folder
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-08 23:36:18 +01:00
Nicolas Sebrecht
0dc45e421b init.py: avoid redefining "type" builtin
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-08 23:36:18 +01:00
Nicolas Sebrecht
11619faf7c imaputil.py: avoid to redefine "string"
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-08 23:36:18 +01:00
Nicolas Sebrecht
1339cc8913 emailutil.py: remove unused import time
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-08 23:36:18 +01:00
Nicolas Sebrecht
eab3e18613 remove garbage about unicode
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-08 12:07:29 +01:00
Nicolas Sebrecht
dbb632275e v6.5.7-rc1
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-07 22:20:14 +01:00
Nicolas Sebrecht
61021260cb more consistent style
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-07 21:31:43 +01:00
Nicolas Sebrecht
11a28fb0cb ui/UIBase: folderlist(): avoid built-in list() redefinition
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-05 13:15:26 +01:00
Nicolas Sebrecht
a35c432671 utils/const.py: fix ident
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:23 +01:00
Nicolas Sebrecht
4589cfeff2 localeval: comment on security issues
Minor syntax fixes.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:23 +01:00
Nicolas Sebrecht
e613f6992d ui/UIBase.py: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:23 +01:00
Nicolas Sebrecht
7b453efcce ui/Curses.py: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:23 +01:00
Nicolas Sebrecht
24a4ab3e16 repository/LocalStatus.py: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:23 +01:00
Nicolas Sebrecht
7f1419a40a repository/GmailMaildir.py: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:22 +01:00
Nicolas Sebrecht
62afde1825 repository/Base.py: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:22 +01:00
Nicolas Sebrecht
2785e779e2 init.py: remove unused import
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:22 +01:00
Nicolas Sebrecht
de5f22a23a CustomConfig.py: remove unused imports
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:24:22 +01:00
Nicolas Sebrecht
54cff7f786 imaplibutil.py: remove unused imports
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-01 22:23:35 +01:00
Nicolas Sebrecht
9b2c275561 Merge pull request #136 from aroig/gh/label-fix
Fix issue with multiple instances of gmail labels header
2014-12-23 03:30:36 +01:00
Keith Smiley
0521aa2706 Fix typo in apply_xforms invocation
Fixes a bug introduced in e51ed80ecc
since apply_xform (without the 's') doesn't exist.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-11-27 17:50:51 +03:00
Abdo Roig-Maranges
e70607e3e3 Warn about a tricky piece of code in addmessageheader
As requested by Nicholas Sebrecht.

Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
2014-11-20 14:18:35 +01: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
e51ed80ecc Enable tilde and environment variable expansion on some items
Expand environment variables in the following configuration items:
- general.pythonfile;
- general.metadata;
- mbnames.filename;
- Repository.localfolders.
- Repository.sslcacertfile.

Make tilde and environment variable expansion in the following
configuration items:
- Repository.sslclientcert;
- Repository.sslclientkey.

GitHub pull request: https://github.com/OfflineIMAP/offlineimap/pull/113
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-11-12 09:40:12 +03:00
Eygene Ryabinkin
8f3c22e227 Introduce CustomConfig method that applies set of transforms
It is a bit cleaner than making chains of calls like
{{{
value = os.path.expanduser(value)
value = os.path.abspath(value)
}}}
since we do see all transformations to be applied in a single
iterable and have no repeated code like in the above example.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-11-02 11:53:05 +03:00
Eygene Ryabinkin
dbf683ed38 Imaplib2: trade backticks to repr()
Backticks are gone in Python 3.x.

GitHub issue: https://github.com/OfflineIMAP/offlineimap/issues/121
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-11-02 10:35:43 +03:00
Eygene Ryabinkin
af464c1b56 Update imaplib2 to 2.37
The only fix is
 - add missing idle_lock in _handler().

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-11-02 10:35:34 +03:00
Eygene Ryabinkin
a1bf8db517 Brought CustomConfig.py into more proper shape
- Multi-line documentation for functions and methods
   now has ending triple-double-quotes on an own line,
   as per PEP 257.

 - Added documentation and comments to almost all functions
   and methods.

 - Added stub implementations for getconfig() and getsection()
   inside CustomConfig.ConfigHelperMixin to provide sane
   run-time diagnostics for classes that doesn't implement them.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-10-09 19:24:11 +04:00
Eygene Ryabinkin
0a569bea3d Add default CA bundle location for DragonFlyBSD
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-10-08 10:39:43 +04:00
nopjmp
716a6f4718 Add OpenBSD default CA certificates file location
GitHub pull: https://github.com/OfflineIMAP/offlineimap/pull/120
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-10-08 09:03:02 +04:00
Eygene Ryabinkin
0aa44c5df4 Fix warning processing for MachineUI
Old code were trying to pass the message to be output as-is,
but it should really be passed as the 'mesg' key in order to
be properly processed by MAchineLogFormatter.format().

GitHub pull: https://github.com/OfflineIMAP/offlineimap/pull/64
GitHub pull: https://github.com/OfflineIMAP/offlineimap/pull/118
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-10-05 11:34:23 +04:00
Eygene Ryabinkin
31d06d1ccb Properly capitalize OpenSSL
And I am also not against this change in licensing.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-10-05 11:33:22 +04:00
Sebastian Spaeth
5cacda68ac Add the OpenSSL exception
The GNU GPL and the OpenSSL license are incompatible. Some distributions
take a hardline stance and do not consider OpenSSL to be a systems library
(which would permit the usage/distribution of OpenSSL) when distributing
apps such as OfflineImap from the same repository. In order to solve these
distributions dilemma, we add the OpenSSL exception to our GNU GPL v2+ license.
This allows for unambiguous use/distribution of our GNU GPL'ed application
with a python linking to openssl.

Consent of all contributors has been requested via email by
Sebastian@SSpaeth.de. With very few exceptions of minor contributions (which
might or might not by copyright-worthy) all past contributors have consented
to adding the OpenSSL exception. None of the replying authors has disagreed
with adding the exception.

The corresponding issues at question:
 https://github.com/OfflineIMAP/offlineimap/issues/104
 Debian bug #747033

We are still missing consent from:
1	Asheesh Laroia
2	Bart Kerkvliet
4	Daniel Burrows
5	David Favro
1	David Logie
1	Eric Dorland
1	Ethan Schoonover
49	Eygene Ryabinkin
1	Loui Chang
1	Luca Capello
1	Michael Witten
2	Mike Dawson
1	Peter Colberg
1	Scott Henson
1	Tom Lawton
1	W. Trevor King
2	X-Ryl669
1	buergi
2	dtk
5	mj

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2014-10-02 11:34:44 +02:00
Eygene Ryabinkin
818486283e Add support for OS-specific CA bundle locations
GitHub pull: #19
Suggested-by: Michael Vogt <mvo@ubuntu.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-09-22 09:52:57 +04:00
Eygene Ryabinkin
aef88cc1f8 Fix label processing in GmailMaildir
Commit 7df765cfdb introduced regression:
GmailMaildir caches labels in its own function and it was testing the
presence of the 'labels' key in message descriptor.  But 7df765cf
changed descriptor initialization and this key is always present.

So now we have 'labels_cached' flag that tells us if labels were
already cached or not.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-08-22 17:43:36 +04: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
73e2c95acd Create SQLite DB directory if it doesn't exist yet
Also check if DB path doesn't point to a directory.

By: Nick Farrell
GitHub: https://github.com/OfflineIMAP/offlineimap/pull/102
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-08-02 22:25:33 +04:00
Eygene Ryabinkin
aa55b38e26 Avoid copying array every time, just slice it
Suggested-by: Josh Berry
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-07-10 10:25:34 +04:00
Eygene Ryabinkin
1f2e8af8aa Trade recursion by plain old cycle
We can do a simpler and more stack-friendly hack for IMAP
servers with limited line lenghts.

Reported-by: Josh Berry, https://github.com/josh-berry
GH: https://github.com/OfflineIMAP/offlineimap/pull/100
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-07-08 12:23:05 +04:00
Eygene Ryabinkin
ffd1b1d691 IMAP: provide message-id in error messages
This is handy for debug purposes when one tries to locate exact
message that was e.g. rejected by server.

Feature-request: http://comments.gmane.org/gmane.mail.imap.offlineimap.general/6491
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-07-01 07:44:18 +04:00
Eygene Ryabinkin
863113efa3 Match header names case-insensitively
http://tools.ietf.org/html/rfc5234#section-2.3 says that ABNF strings
are case-insensitive.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-06-30 16:41:17 +04:00
Adam Spiers
807f3da880 addmessageheader(): add debug for header insertion
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-06-24 23:36:48 +04:00
Adam Spiers
37f74d859a addmessageheader: fix case #2 and flesh out docstring
The example illustrations were slightly cryptic;
modify them to be more obvious.

Fix case #2 (message starts with two line breaks)
where additional line break was shown and coded.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-06-24 23:25:45 +04:00
Adam Spiers
afead6c48e Rename addmessageheader()'s crlf parameter to linebreak
The parameter's value is a string representing the linebreak,
and can sometimes contain just '\n', in which case naming it
crlf is slightly misleading.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-06-24 23:12:06 +04:00
Eygene Ryabinkin
968ffc20bd More clearly show results of folder name translation
For cases like
  http://article.gmane.org/gmane.mail.imap.offlineimap.general/6468
it is beneficial to see that folder name was translated and the result
of this translation on a single line: having log like
{{{
Folder Boring/Wreck [acc: tmarble@info9.net]:
 Syncing Boring/Breck: Gmail -> Maildir
}}}
with translated name on the "Folder" line and original one on the
"Syncing" line isn't very intuitive.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-06-24 18:48:58 +04:00
Eygene Ryabinkin
c92c4e56a0 Add version qualifier to differentiate releases and development ones
It is always good to see which version we're talking about, so I had
added explicit marker for -devel, -release, -rcX and other states of
the OfflineIMAP.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-06-01 22:39:10 +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
Eygene Ryabinkin
1746676af8 Make IDLE mode to work again
Refactoring in commit 6cbd2498 touched wrong class's "idle" call.

Found-by: Tomasz Żok <tomasz.zok@gmail.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-23 13:19:11 +04:00
Eygene Ryabinkin
0005bcb2f0 Make IDLE mode to work again
Refactoring in commit 6cbd2498 touched wrong class's "idle" call.

Found-by: Tomasz Żok <tomasz.zok@gmail.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-23 10:24:55 +04:00
Eygene Ryabinkin
d2ec2a4e9e Extend handling of cert_fingerprint
Add ability to specify multiple fingerprints.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-11 22:45:34 +04:00
Abdo Roig-Maranges
1690e5f74e Copymessageto should not be private since we override it
private methods prevent them from being overriden on derived classes. In
GmailFolder we need to override copymessageto, so it can't be private.

Before this commit, copymessageto was made private in Base but not in
GmailFolder. The end result was that labels were not set when copying
the message content, and always needed to be set on the label copying
pass.

Pointyhat-to: Eygene Ryabinkin
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-11 22:44:57 +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
8b4f86be67 Class LocalStatusFolder: remove duplicate cachemessagelist()
Remained from GMail label sync merge.

Pointyhat-to: Eygene Ryabinkin
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 18:29:47 +04:00
Abdo Roig-Maranges
b982549e4d Class LocalStatusRepository: add missing self qualifier
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 18:29:47 +04:00
Abdo Roig-Maranges
96c9cca83a Class IMAPServer: idle() is private now
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 18:29:47 +04:00
Abdo Roig-Maranges
1300f2289b deletemessageheaders(): use passed list of headers to remove
... and not self.filterheaders.  With the current code this change
is no-op (since self.filterheaders is always passed as header_list),
but it is a bug in general.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 18:29:47 +04:00
Eygene Ryabinkin
5150de5514 Add support for XDG Base Directory Specification
$XDG_CONFIG_HOME/offlineimap/config will now be tried before
the canonical ~/.offlineimaprc.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 00:40:59 +04:00
Eygene Ryabinkin
d96af192ed Move space to the end of string
... to be aligned with the rest of the code.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 00:07:56 +04:00
Ben Boeckel
7c271d5131 Imapserver: add missing space to the log message
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-07 00:04:44 +04:00
Abdo Roig-Maranges
1b954c3b4c Add ability to migrate status data across backends
If when we request a LocalStatus folder, the folder has to be created,
we look whether the other backend has data, and if it does we migrate
it to the new backend.

The old backend data is left untouched, so that if you change back say
from sqlite to plaintext, the older data is still there.  That should
not lead to data loss, only a slower sync while the status folder gets
updated.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-06 23:37:11 +04:00
Abdo Roig-Maranges
214137eb7b Improvements to the SQlite-based local status folder
* Do not inherit LocalStatusSQLiteFolder class from the plaintext
    one.

  * Use some functions already in BaseFolder in both, plaintext and
    sqlite classes.

  * Add a saveall method. The idea is that saveall dumps the entire
    messagelist to disk, while save only commits the uncommited
    changes. Right now, save is noop for sqlite, and equivalent to
    saveall for plaintext, but it enables to be more clever on when we
    commit to disk in the future.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-06 23:37:11 +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
Abdó Roig-Maranges
9319ae212b Restructured folder/IMAP code
In preparation for GMail label sync, we had split our some functionality
that will be needed further into their own functions.  This also permitted
the code to look more compact and concise.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-06 23:03:21 +04:00
Abdó Roig-Maranges
5391476dfb Add ability to trim some local mail headers
When filterheaders is set to a comma-separated list of headers,
OfflineIMAP removes those headers from messages before uploading them
to the server.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-03 14:45:28 +04:00
Eygene Ryabinkin
844ca6b08c Don't embed CRLF multiple times when saving a message
Since we just do multiple passes for saving the message without
actually modifying its content (apart from header insertion that
is CRLF-clean), we can change line ends to the proper CRLF just
once.

And we can also get message's date only once too.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-03 14:43:11 +04:00
Abdó Roig-Maranges
0903428fda Enable compressed connections to the IMAP server
Added the configuration setting usecompression for the IMAP repositories.
When enabled, the data from and to the IMAP server is compressed.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-02 19:30:49 +04:00
Abdó Roig-Maranges
0c4fe6bada Bugfix: make change_message_uid to update messagelist's filename
This broke code that relied on the filename being up to date in memory
after messages are copied.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-02 19:28:28 +04:00
Abdó Roig-Maranges
697ca8a229 Changed NotImplementedException to NotImplementedError
It seems NotImplementedException does not exist. It must be a relic
from old Python...

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-05-02 19:23:01 +04:00
Eygene Ryabinkin
6cbd2498ae Refactoring: make functions to be private if we can
Make external API of class/module to be smaller, explicitely mark
all internal functions.  Also annotate methods that are implemented
as the part of the parent class interface.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-04-30 19:35:56 +04:00
Stefan Huber
af2d6dc5e1 Fix: Undefined variable 'this' should be 'self'
Pointyhat-to: Eygene Ryabinkin
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-03-06 10:48:34 +04:00
Eygene Ryabinkin
829c9cf4be Introduce dynamic filtering for repository folders
Allow people who want folder filtering to depend on the external
conditions or to make it dynamic for other reasons, to do what
they want.

New repository configuration knob 'dynamic_folderfilter' was
introduced; it defaults to 'False' that matches historical behaviour.

GitHub: #73
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-03-02 16:37:41 +04:00
Eygene Ryabinkin
b01274ce38 Fix double release of IMAP connection object
This commit fixes the case when we're invoking releaseconnection()
for a given imapobj twice.

This bug manifests itself as
{{{
ValueError: list.remove(x): x not in list

  File "[...]/offlineimap/folder/IMAP.py", line 615, in savemessage
    self.imapserver.releaseconnection(imapobj)
  File "[...]/offlineimap/imapserver.py", line 130, in releaseconnection
    self.assignedconnections.remove(connection)
}}}

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2014-02-26 17:51:48 +04:00
Eygene Ryabinkin
8bc2f35bf6 OfflineIMAP 6.5.5 is out
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-10-04 17:03:06 +04:00
Eygene Ryabinkin
254e848140 Rolling in release candidate #3 for 6.5.5
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-09-20 14:35:37 +04:00
Eygene Ryabinkin
57adfc23a5 Fix parsing of quoted strings
When imaputil was parsing quoted strings, it treated "abcd\\"
as incomplete quoted string having escaped quote, rather than
properly-quoted string having escaped backslash.

GitHub issue: https://github.com/OfflineIMAP/offlineimap/issues/53
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-09-19 22:56:55 +04:00
Eygene Ryabinkin
be1c72ea5f Updated bundled imaplib2 to 2.36
2.36 it includes support for SSL version override that was integrated
into our code before, no other changes.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-09-19 17:19:37 +04:00
Eygene Ryabinkin
2df5b716b5 Updated bundled imaplib2 to 2.35:
- Fix for Gmail sending a BYE response after reading >100 messages
   in a session.

 - Includes fix for GitHub#15: patch was accepted upstream.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-09-02 09:08:50 +04:00
Eygene Ryabinkin
1ef506655c Catch two instances of untested regexp matches
They could possibly lead to the problems mentioned in
  https://github.com/OfflineIMAP/offlineimap/issues/6
though there are no sound evidences for this.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-30 21:50:08 +04:00
Eygene Ryabinkin
69765a3ef0 Properly call error() function from ui.UIBase
Second argument is exception traceback, not the message; without this
tracebacks like mentioned in
  http://permalink.gmane.org/gmane.mail.imap.offlineimap.general/5712
were happening when this exception handling block was hit.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-30 21:49:09 +04:00
Eygene Ryabinkin
f2c858330f Always show full tracebacks at the end of the run
This greatly simplifies developer's life and will, possibly, allow
users familiar with Python to debug and fix the problems by
themselves.

We, possibly, should not give tracebacks for the problems like
"can't open connection", but this is up to the caller of this
routine not to provide traceback in this case.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-27 20:25:30 +04:00
Eygene Ryabinkin
d55e4ef15e imaplib2: fix handling of zero-sized IMAP objects
self._expecting_data was used both as the expected data length and the
flag that we expect some data.  This obviously fails when advertized
data length is zero, so self._expecting_data_len was introduced to
hold the length of the expected data and self._expecting_data was left
as the flag that we expect the data to come.

GitHub issue: https://github.com/OfflineIMAP/offlineimap/issues/15
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-27 20:25:30 +04:00
Eygene Ryabinkin
95aea5e489 Add new expansion key for mbnames.peritem config variable
It is called localfolders and holds expanded name for the same
variable for the local repository of the account that is being
processed.

GitHub issue: https://github.com/OfflineIMAP/offlineimap/issues/21
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-27 20:25:23 +04:00
Eygene Ryabinkin
8b6f10e2e7 Pass folder names for the foldersort function
Bring the description in the template offlineimap.conf in sync to the
actual implementation: pass folder names to the sorting function, not
the offlineimap.folder.IMAP.IMAPFolder objects themselves.

GitHub issue: https://github.com/OfflineIMAP/offlineimap/issues/27
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-27 16:27:36 +04:00
X-Ryl669
3bc66c0858 Add support for alternative message date synchronisation
Global or per-repository option utime_from_message tells OfflineIMAP
to set file modification time of messages pushed from one repository
to another basing on the message's "Date" header.

This is useful if you are doing some processing/finding on your
Maildir (for example, finding messages older than 3 months),
without parsing each file/message content.

From: Cyril RUSSO <boite.pour.spam@gmail.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-09 10:48:00 +04:00
Andreas Mack
e26827c1cb Make authentication mechanisms configurable
Added configuration option "auth_mechanisms" to the config file:
it is a list of mechanisms that will be tried in the specified order.

Author: Andreas Mack <andreas.mack@konsec.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-08 22:34:30 +04:00
Steve Purcell
968d5520da Allow transport-type tunnels to the IMAP servers
It's nice to set up an ssh tunnel command which forwards an IMAP tcp
port inside an encrypted session, e.g. with ssh's "-W" flag.  In this
case the tunnelled connection still requires authentication inside
IMAP session, because this is transport-only tunnel that substitutes
normal TCP/SSL connection.

New directive, 'transporttunnel' was added: it specifies the command
that will create the tunnel.  Only one type of tunnel must be
specified for a single repository: we can't have both preauthenticated
and transport-type tunnels, they won't chain together.

From: Steve Purcell <steve@sanityinc.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-06 12:18:21 +04:00
Andreas Mack
acaa96291d Add SASL PLAIN authentication method
- this method isn't as deprecated as IMAP LOGIN;

 - it allows to keep hashed passwords on the server side;

 - it has the ability to specify that the remote identity
   is different from authenticating username, so it even
   can be useful in some cases (e.g., migrated mailboxes);
   configuration variable "remote_identity" was introduced
   to leverage this functionality.

From: Andreas Mack <andreas.mack@konsec.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-06 01:51:41 +04:00
Eygene Ryabinkin
7d313f49dc Refactored authentication handling
- created helper routine that will do authentication;

 - routine tries each method in turn, first successful
   one terminates it: makes things easier to read
   and handle;

 - renamed plainauth() inside offlineimap/imapserver.py
   to loginauth(): the function does IMAP LOGIN authentication
   and there is PLAIN SASL method, so previous name was
   a bit misleading;

 - slightly improved error reporting: all exceptions during
   authentication will be reported at the end of the run;

 - now loginauth() is never called if LOGINDISABLED is advertized
   by the server; it used to be invoked unconditionally when
   CRAM-MD5 fails, but we should respect server's opinion on
   how to handle its users.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-06 01:10:10 +04:00
Adam Spiers
d39a1f864f make savemessage() handle NO response to APPEND correctly
IMAP servers can return `NO` responses to the `APPEND` command,
e.g. here's an example response from Groupwise's IMAP server:

    NO APPEND The 1500 MB storage limit has been exceeded.

In this case, savemessage() should abort the repository sync rather
than returning UID 0 which would cause the local copy of the message
being saved to get irreversibly deleted.

Signed-off-by: Adam Spiers <offlineimap@adamspiers.org>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-02 16:41:54 +04:00
Johan Herland
56b0c5dbac Allow custom sorting of mailboxes for mbnames
mutt-sidebar and, probably, other MUA show mailboxes in the order
they are listed in the file written by mbnames.  Therefore, to allow
customization of the order with which mailboxes are listed, introduce
the new 'sort_keyfunc' directive in the [mbnames] section.

'sort_keyfunc' must be a function that will be called once for each
mailbox.  It must accept the only argument -- a dict with 2 items,
'accountname' and 'foldername', and should return an object that
will be used as the sorting key for each mailbox.

Default key function returns (d['accountname'], d['foldername']),
thus sorting by account name and then by the folder name.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-02 14:46:44 +04:00
mxgr7
0d992ee7d3 Execute pre/post hooks for IDLE-toggled syncs
Make IDLE syncs be equal to the regular synchronisations
in respect to pre-sync and post-sync hooks.

From: mxgr7 <maxgerer@gmail.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-08-02 13:53:21 +04:00
Eygene Ryabinkin
67d68c2fc8 IMAP: simplify locking and fix potential lock loss
Run the locked code under 'with': this guarantees that lock
will be released in any case.

This modification also avoids the case when our thread wasn't running
locked when exception was caught, another thread got the lock, our
code checked it via self.connectionlock.locked() and errorneously
released the lock thinking that is was running locked.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-07-22 00:08:39 +04:00
Eygene Ryabinkin
41cb0f577f Prune trailing whitespaces from code and documentation
They are redundant in all pruned cases and sometimes even create some
problems, e.g., when one tries to jump through paragraphs in vi.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-07-21 23:00:23 +04:00
Dmitrijs Ledkovs
e8c40a9285 Merge branch 'master' into next 2013-07-10 02:49:52 +01:00
xnox
05284b4df8 Merge pull request #28 from aspiers/fix-typos
fix typos
2013-07-09 18:30:28 -07:00
Dmitrijs Ledkovs
7a21cab6c5 Correct whitespace & add docs about remoteporteval. 2013-07-10 02:17:01 +01:00
Ryan Kavanagh
2bacdb7fa3 Allow setting IMAP servers' SSL version
We now allow setting the SSL version used when connecting to IMAPS servers, and
do so via the `ssl_version` configuration option. We default to the current
practice (letting python's "ssl" library automatically detect the correct
version). There are however rare cases where one must specify the version to
use.

Signed-off-by: Ryan Kavanagh <rak@debian.org>
2013-07-08 10:57:58 -04:00
Kim Lidström
dde021ce52 Added remoteporteval 2013-06-20 11:38:45 +02:00
Adam Spiers
aa5202396c fix typos 2013-03-27 12:42:32 +00:00
Eygene Ryabinkin
611f6e89c0 IMAP class: don't suggest multithreading in single-threaded mode
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-02-11 23:34:28 +04:00
Eygene Ryabinkin
f4140cbbed Create global instance of command-line options
This eases testing of option values inside the code.  This instance
is implemented as the read-only copy of the obtained 'options' object,
so callers won't be able to modify its contents.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-02-11 23:34:18 +04:00
X-Ryl669
5c842c01bd Fix deadlock for IMAP folder synced in singlethreaded mode
The problem lies in the fact that offlineimap.folder.Base's method
syncmessagesto_copy() uses threaded code everytime it is suggested by
the derived class's suggeststhreads() (currently, only IMAP does this
suggestion), but offlineimap/init.py will not spawn the
exitnotifymonitorloop() from offlineimap.threadutil.

The root cause is that ExitNotifyThread-derived threads need
offlineimap.threadutil's exitnotifymonitorloop() to be running the
cleaner for the exitthreads Queue(), because it fills the queue via
the run() method from this class: it wants to put() itself to the
Queue on exit, so when no exitnotifymonitorloop() is running, the
queue will fill up.  And if this thread is an instance of
InstanceLimitedThread that hits the limit on the number of threads,
then it will hold the instancelimitedsems[] semaphore will prevent
other InstanceLimitedThread()s of the same name to pass its start()
method.

The fix is to avoid using threaded code if we're running
single-threaded.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Obtained-from: X-Ryl669 <boite.pour.spam@gmail.com>
2013-02-05 07:53:25 +04:00
Eygene Ryabinkin
1c8917b036 And add forgotten __init__.py for offlineimap.utils
I should learn to check my commits when rebasing and reordering.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-02-05 07:52:25 +04:00
Eygene Ryabinkin
de84c3941c Implement stack trace dump for all running threads on SIGQUIT
This is handy when we're debugging the thread locks: we can try to
understand which thread does what and how it was called.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-02-02 16:25:37 +04:00
Dmitrijs Ledkovs
83e8fca2e0 Make SIGHUP singal handler equivalent to SIGTERM and SIGINT.
offlineimap has several frontends that encourage running it from a
terminal under an X session. When X session closes for a system
shutdown, the terminals exit, after sending SIGHUP to their children.

Previously SIGHUP was treated to be equivalent to SIGUSR1, i.e. wake
up and sync all accounts. This causes delays during shutdown.

According to Wikipedia [0], SIGHUP has been repurposed from a
historical meaning to one of:
 * re-read configuration files, or reinitialize (e.g. Apache, sendmail)
 * controlling pseudo or virtual terminal has been closed

I believe second meaning is more appropriate for offlineimap, and
hence this patch makes SIGHUP to be handled in the same way SIGTERM
and SIGINT are handled.

[0] http://en.wikipedia.org/wiki/SIGHUP

Debian-Bug: http://bugs.debian.org/670120
Reported-By: Steve Langasek <steve.langasek@canonical.com>
Signed-off-by: Dmitrijs Ledkovs <xnox@debian.org>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2013-01-26 23:05:46 +04:00
Tobias Thierer
caef9a72fc Fix IMAP folder throwing away time zone when parsing email Date headers
Fix imapfolder.getmessageinternaldate misparsing the Date:
header from emails due to a bug or surprising behaviour by
email.utils.parsedate. This is because email.utils.parsedate's
return value contains the unadjusted hour value from the string
parsed but does not include information about the time zone in
which it is specified. For example (Python 2.7.3):

$ python -c "import email.utils;
  print email.utils.parsedate('Mon, 20 Nov 1995 19:12:08 -0500')"
 (1995, 11, 20, 19, 12, 8, 0, 1, -1)

(the -1 is the isdst field); the -0500 time zone is completely
ignored, so e.g. the same input with time "19:12:08 +0300" has
the same result. When passed to time.struct_time as allowed per
the parsedate documentation, this time is interpreted in GMT and
thus deviates from the correct value by the timezone offset
(in this example, -5 hours).

I consider this a bug in email.utils.parsedate: In my opinion,
since the return value of the parsetime doesn't include a timezone,
it should be expressed in terms of UTC rather than in terms of the
time zone from the Date header; the existence of
email.utils.parsedate_tz, to which I've switched, indicates that
maybe the authors were aware of this problem.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-10-03 11:16:13 +02:00
Sebastian Spaeth
721035eace Release v6.5.5-rc2
(Same as rc1, but with Changelog updated and version number bumped)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-09-05 17:40:09 +02:00
Sebastian Spaeth
3476e9ab36 Fix fallout when filtering folders
Previous commit e7ca5b25cb combined
checks for filtered folders in one place. However, it turns out there
was a reason to have them separate. getfolder() on a non-existent Maildir
fails and there might not be an equivalent local Maildir folder for a
filtered out IMAP folder.

Fix this by first checking if the remote folder should be filtered, and
only then retrieving the local folder (which should exist then).

This bug was found by our test suite!

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-09-01 03:15:08 +02:00
Sebastian Spaeth
49c11fc8f0 LocalStatus._folders needs to be {} not None
the LocalStatus._folders cache was changed to be a dict that can be
searched for names. One instance were _folders was set to "None" was
accidentally left over. Fix this.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-09-01 02:58:14 +02:00
Dave Abrahams
7d1d5283f8 No need to filter Maildir folders here
commit e94642bb4d centralized folder filtering by using the
repository.should_sync_folder() function. Therefore there is no need
to check for folderfilter in the Maildir backend separately.

Origina patch by Dave, split into 3 by Sebastian

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-09-01 02:49:00 +02:00
Dave Abrahams
e94642bb4d Determine folder syncing on Folder initialization
Rather than later when retrieving them by IMAP, we determine the
"sync_this" value of a folder on Folder() initialization.

This also fixes a bug where folder structure was not propagated when
a folder was filtered out but included in the folderincludes list.

Patch by Dave, split and modified slightly by Sebastian

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-09-01 02:30:46 +02:00
Dave Abrahams
e7ca5b25cb Combine checks for ignored folders in one place
- Factor out the code to find a local folder given a remote folder

Patch by Dave, split and modified by Sebastian.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-09-01 02:16:06 +02:00
Sebastian Spaeth
1b54b85f20 Reuse LocalStatus() folders rather than recreate instances
If we ask twice for a LocalStatusFolder via getfolder(), we would
get a newly created instance each time. This can lead to problems,
as e.g. write locks protecting files only work within the same Folder
instance. Make it so, that we cache all Folder instances that we have
asked for and hand back the existing one if we ask again for it,
rather than recreate a new instance.

Also, make getfolders() a noop for LocalStatus. We attempted to
derive the foldername from the name of the LocalStatusfile. However,
this is not really possible, as we do file name mangling
(".$" -> "dot", "/" -> ".") and there is no way to get the original folder
name from the LocalStatus file name anyway.

This commit could potentially solve the "file not found" errors, that people
have been seeing with their LocalStatusCache files. If we have 2
instances of a LocalStatusFolder pointing to the same file, our locking
system would not work.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-09-01 01:19:19 +02:00
Sebastian Spaeth
a1dc76ae91 Don't output initial blurb in "quiet" mode
When logging to a file using the -l switch, we would still write an initial
banner to the file. This was never intended. Quiet should be really quiet
unless it experiences an error. Simplify the logging statement, to do nothing
if logevel is set to "WARNING" aka quiet.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-08-31 23:11:11 +02:00
Sebastian Spaeth
3cb2ddccb8 Use "with lock" pattern
While looking at the code to investigate if an why we sometimes don't
seem to honor the write lock, I made it use the more modern "with lock:"
pattern.

Still have not found out how we could ever be using 2 instances of the
LocalStatusFolder for the same folder.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-08-31 22:34:53 +02:00
Sebastian Spaeth
04ffae2f00 Exit with nice error message failing to get repositories
If we throw an OfflineImapError in case of the Repository()
initialization, we display the nice error message and exit rather
than bomb out with a traceback. Misconfiguring a repository name in
the configuration file is now nicely pointed out to the user.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-08-31 20:34:54 +02:00
Sebastian Spaeth
103524c979 Throw OfflineImapErrors rather than weird Exceptions
When misconfiguring OLI, e.g. by specifying a repository name that was
not configured anywhere, we would bomb out with cryptic "NoSectionError".
Throw OfflineImapError that explains what has happened. We still need to
avoid throwing exceptions with Tracebacks here though.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-08-31 20:31:43 +02:00
Sebastian Spaeth
925a5bcae1 Fix cut-off line
Commit 6e5fbebc introduced a cut-off line. Fixing that.
All tests ran successfully.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-08-21 17:00:39 +02:00
Sebastian Spaeth
a134301ac5 Improve 'find first quotation' regex
Reported by http://www.dfranke.com/blog/2012/08/20/offlineimap-error-beim-syncen-mit-lotus-domino/
our 'find the first quote possible containing encoded quotation
marks' regex did not seem to have caught all cases. E.g. "\\".

Verified the fix as good. Thanks Daniel Franke.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-08-21 16:58:32 +02:00
Vladimir Nesov
6e5fbebc0e fix: createfolders setting is ignored if readonly is True
If 'readonly' is True, folders shouldn't be created (regardless of
'createfolders' option). With old behavior, instead folders were always created
when 'readonly' is True (even if 'createfolders' was also False), which is a
serious bug (offlineimap was creating folders in all read-only repositories).
'createfolders' should only play a role if 'readonly' is False, in which case
folders should only be created if 'createfolders' is True.

Submitted-by: Vladimir Nesov <robotact@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2012-08-20 21:12:56 +02:00
Eygene Ryabinkin
131ac5c827 IMAPlib mixin class: pass 'readonly' exception to our callers
This will allow our callers who are capable of dealing with
readonly folders to properly detect this condition and act
accordingly.

One example is Gmail's "Chats" folder that is read-only,
but contains logs of the quick chats.

Minor Changelog improvements.

Tested-by: Abdó Roig-Maranges <abdo.roig@gmail.com>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2012-08-11 11:59:26 +02:00
Dmitrijs Ledkovs
d45872e59c Add missing OfflineImapError import in folder/UIDMaps.py
Bug-Debian: http://bugs.debian.org/671279
Reported-by: Ansgar Burchardt <ansgar@debian.org>
Signed-off-by: Dmitrijs Ledkovs <xnox@debian.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2012-07-30 20:10:11 +02:00
Sebastian Spaeth
36156fa985 Remove the APPENDUID hack, previously introduced
As Gmail was only announcing the presence of the UIDPLUS extension
after we logged in, and we were then only getting server
capabilities before, a hack was introduced that checked the
existence of an APPENDUID reply, even if the server did not claim
to support it.

However, John Wiegley reports problems, where the APPENDUID would
be None, and we attempt to go this path (it seems that imaplib2
returns [None] if there is no such reply, so our test here for "!="
might fail. Given that this is an undocumented imaplib2 function
anyway, and we do fetch gmail capabilities after authentication,
this hack should no longer be necessary.

We had problems there earlier, where imapobj.response() would
return [None] although we had received a APPENDUID response from
the server, this might need more debugging and testing.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-06-06 10:13:42 +02:00
David Logie
a614f9a735 Fix str.format() calls for Python 2.6.
Python 2.6 requires a slightly different string formatting that >2.7.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-06-02 18:25:51 +02:00
Sebastian Spaeth
686561b42c Release v6.5.4
See Changelog for details

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-06-02 13:41:20 +02:00
Sebastian Spaeth
0752c123f5 Implement the "createfolders" setting for repositories
By default OfflineImap propagates new folders in both
directions. Sometimes this is not what you want. E.g. you might want
new folders on your IMAP server to propagate to your local MailDir,
but not the other way around. The 'readonly' setting on a repository
will not help here, as it prevents any change from occuring on that
repository. This is what the `createfolders` setting is for. By
default it is `True`, meaning that new folders can be created on this
repository. To prevent folders from ever being created on a
repository, set this to `False`. If you set this to False on the
REMOTE repository, you will not have to create the `Reverse
nametrans`_ rules on the LOCAL repository.

Also implement a test for this

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-05-08 16:56:45 +02:00
Sebastian Spaeth
644b9f0bb9 Implement .readonly property for repositories
Set the value once on repository initialization to centralize the
default value.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-05-08 16:31:19 +02:00
Sebastian Spaeth
61e754c65e Do not try to release IMAP connection twice
Reported by sharat87 in https://github.com/spaetz/offlineimap/pull/38,
he would often get an unhandled Exception when trying to
releaseconnection() a connection that was not in the pool of
connections.

The reason this could happen is that when folder.IMAP.quickchanged()
raises an Exception in select(), we would release the connection in the
"except" handling, and than release the same connection in the "finally"
clause, which led to the error. The right thing is to only release the
connection once, of course.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-21 13:32:14 +02:00
Sebastian Spaeth
895e709bf2 Fix SSL fingerprint was not always checked
As reported by James Cook, we would not check the fingerprint of the SSL
server, as we were looking for the 'ssl' module in locals() rather than
globals(). Ooops!

Rather than using globals() though, I simply remove the by-now
superfluous check. We now rely on python2.6 and we unconditionally
import the SSL module in any case, so it needs to be there.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-19 18:26:29 +02:00
Christoph Höger
b9af72ea11 Curses UI: Reset the warn method before terminate
The warn() method tries to set the color to red. This leads to a garbled
tty after endwin() has been called. So lets simply use the UIBase
implementation.

Signed-off-by: Christoph Höger <christoph.hoeger@tu-berlin.de>
2012-04-19 17:20:49 +02:00
Sebastian Spaeth
8fe8bbe366 imaplib2: bump upstream version 2.29 --> 2.33
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-19 13:22:03 +02:00
Sebastian Spaeth
679c491c56 bugfix release v6.5.3.1
a single bugfix when no dry-run option was given in the config file.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-03 01:39:28 +02:00
Sebastian Spaeth
c708e36ff7 Don't fail if no dry-run setting has been specified
Somehow we failed if no dry-run setting had been specified in the config
file. This got caught thanks to extending the test suite with a stock
configuration.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-03 01:13:27 +02:00
Sebastian Spaeth
d3427a664e v6.5.3 release
see changelog

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-02 23:47:32 +02:00
Eygene Ryabinkin
2f88b0296a Fix Curses interface for Python 2.6
In 2.6 all logging classes are not the new-style ones, so they
have no mro() method and, thus, we can't use super() for them.
Since CursesLogHanler is singly-inherited method, there will
be no problems in usage of the explicit superclass name.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-02 23:39:36 +02:00
Sebastian Spaeth
29ba2fc523 Warn about nonsensical config option 'sep' for IMAP repositories
We autodetect the folder separator on IMAP servers and ignore any 'sep'
setting in the repository section for IMAP servers. Detect if there is
such a setting and warn the user about it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-04-02 23:26:59 +02:00
Sebastian Spaeth
3c481d9ce5 -f command line option only works on the untranslated remote names
Previously folderfilters had to match both the local AND remote
name which caused unwanted behavior in combination with nametrans
rules. Make it operate on the untranslated remote names now and
clarify in the command line option help text.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-24 14:52:30 +01:00
Sebastian Spaeth
925538f02d docs: Fix docstrings to proper .rst syntax
Prevents compile errors when creating the user documentation.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-24 11:20:22 +01:00
Sebastian Spaeth
0e6b4ae798 Revert "Clean up and improve APPENDUID handling"
This reverts commit 4d47f7bf3c.

This is one of two candidates for introducing the instabilities that
John Wiegley observed. We need to reintroduce with careful testing only.

The original patch has been mostly reverted.
2012-02-24 08:35:59 +01:00
Sebastian Spaeth
bc73c11239 Revert "Don't CHECK imapserver after each APPEND"
This reverts commit 47390e03d6.

It is one of two potential candidates for the APPENDUID
regression that John Wiegley reported. We need to examine this
carefully before reintroducing this patch.

Resolved Changelog.draft.rst conflict.
2012-02-24 08:31:31 +01:00
Sebastian Spaeth
aa01fe754a Improve command line option help text
Shuffle around and update command line option descriptions in the
docs.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 13:17:05 +01:00
Sebastian Spaeth
256a26a649 dry-run mode: Protect us from actually deleting a message in dry-run mode
Document which functions honor dry-run mode and which don't.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 13:17:05 +01:00
Sebastian Spaeth
5ef69e95c0 Prevent modifications on a folder level to occur in dry-run
Prevent savemessage(), and savemessageflags() to occur in dryrun mode in
all backends. Still need to protect against deletemessage().

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 13:17:05 +01:00
Sebastian Spaeth
b6807355b5 Implement ui.makefolder and abort repo.makefolder() in dry-run mode
IMAP, Maildir, and LocalStatus abort if in dry-run mode. IMAP and Maildir
will log that they "would have" created a new folder.

This will probably fail later on as we can not cache messagelists on
folder that don't exist, so --dry-run is not yet safe when new folders
have been created.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 13:17:03 +01:00
Sebastian Spaeth
33f55b5362 Implement dry-run on Account() level
1) Set attribute self.dryrun depending on whether we are in dry-run mode.
2) Don't actually call hooks in --dry-run (just log what you would
   invoke
3) Don't write out the mbnames file in --dry-run mode.

Repository, and Folder levels still need to be protected in dry-run mode
as of now.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 10:53:10 +01:00
Sebastian Spaeth
b7e0a51751 Add command line option --dry-run
And set the [general]dry-run=True setting if yes. It is not used yet.
Also set ui.dryrun to True so we can output what WE WOULD HAVE DONE in
dryrun mode.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 10:32:04 +01:00
Sebastian Spaeth
a8c6407f50 Implement CustomConfig.set_if_not_exists()
A convenience helper function that allows to set a configuration value
if the user has not explicitly configured anything ie the option does
not exist yet in the configuration. It won't do anything, if the option
exists.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 10:28:59 +01:00
Sebastian Spaeth
bf44d30b46 UIDMaps: Better error message when not finding a mapping
Bail out with a better Exception and error text. The whole mapped
UID situation needs to be improved though.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-17 08:48:59 +01:00
Sebastian Spaeth
7da50e638d folder/IMAP: better error when savemessage fails
If we cannot identify the new UID after a sendmessage(), log a better error
message, including the server response for better debugging.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-16 16:49:06 +01:00
Sebastian Spaeth
ac033c68fd Improve nametrans local->remote folder syncing
While improving the test suite, I noticed that we would not create folders on
the remote in some cases when we should (yay for test suites!). This is because
we were testing the untransposed LOCAL foldername and check if it existed on
the remote side when deciding whether we should potentially create a new folder.

Simplify the code by transposing the LOCAL folder names in dst_hash, saving us
to create another confusing "newsrc" temp variable. Make the code a bit more
readable by using dst_name_t to indicate we operate a transposed folder name.

This now passes test 03 (using invalid nametrans rules) when test 03 would pass
before.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-16 11:45:18 +01:00
Sebastian Spaeth
189d78cc5c sync_folder_structure: make more readable
Rename variable src_name to src_name_t to indicate that it is the transposed
name. Also rather than testing the hash thingie, we can simply test for
"if source_name_t in dst_folders" now.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-02-16 11:12:07 +01:00