Split offlineimap.run()

Was getting too large, split into an parse_cmd_options and a sync()
function. Moving config and ui to self.config and self.ui to make them
available through the OfflineImap instance.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Implement server diagnostics

This outputs a handy summary of your server configuration and version
strings etc, which is useful for bug reporting.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Fix string formatting when port is not given.

If port is None, we would try to format an empty string with %d wich
fails. Fix it by using %s.

Reported-by: Iain Dalton <iain.dalton@gmail.com>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Use 'reference' value when creating an IMAP directory

A repositories 'reference value is always prefixed to the full folder
path, so we should do so when creating a new one. The code had existed
but was commented out since 2003, I guess the "reference" option is not
too often used.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Fix quotation marks

I guess they looked identical to whoever wrote that, but here the
the first had a space with a combining grave accent where the second has
a plain space and a plain backquote instead.

Reported-by: Daniel Shahaf <d.s@daniel.shahaf.name>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
imapserver: Make noop() more resitent against dropped connections.

Drop a connection, if the NOOP to keep a connection open fails due to
broken connections.

Note that I believe this function is not working as intended. We grab
one random connection and send a NOOP. This is not enough to keep all
connections open, and if we invoke this function multiple times, we
might well always get the same connection to send a NOOP through.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Do not import threading.*

Only import the lock, that we actually need. Also import the with statement
for use with python 2.5. We'll need it for sure in this file.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
createfolder: Fix wrong error output

If folder creation failed, we would output the wrong repository and
folder name (copy'n paste error). Fix this so we actually output the
correct values.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Fix typos in documentary comments in exemplary config file

I stumbled upon a few typos in the config file coming with master and just
patched them. Apply as you like.

Signed-off-by: dtk <dtk@gmx.de>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Rework UI system to make use of the logging module

Logging was flawed as the output was e.g. heavily buffered and people
complained about missing log entries. Fix this by making use of the
standard logging facilities that offlineimap offers.

This is one big ugly patch that does many things. It fixes the
Blinkenlights backend to work again with the logging facilities.

Resize windows and hotkeys are still not handled absolut correctly, this
is left for future fixing. THe rest of the backends should be working fine.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Simplify the keepalive code a bit

Should not change behavior.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Prettify Blinkenlights.sleep()

Prettify the function.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Rework the whole unused get/setExitCause machinery

It is basically unused by now. Rework to be able to make use of it
later, no functional changes.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Fix getExitStackTrace call

It was changed
Add changelog entry for reworked UI backends

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Fix mbox.select(foldername) readonly parameter comparison

The default parameter value was "None", and we were comparing that
directly to the imaplib2 value of is_readonly which is False or True, so
the comparison always returned "False".

Fix this by setting the default parameter to "False" and not
"None". Also convert all users of that function to use False/True.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Make releaseconnection a NOOP when conn is None

During cleanup we often call releaseconnection in a finally: block. But
in cases of error, we might have dropped the connection earlier already
and set it to "None". In this case don't fail releaseconnection() but
make it a NOOP.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Drop connection if it might be bad on APPEND

1) Differentiate error messages between imaplib.abort and imaplib.error
exceptions in the log.

2) Drop connections in the case of imapobj.error, it also might denote a
   broken connection.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Bump bundled imaplib2 to 2.29

It has fixed some bugs, so update to current upstream.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Append, don't truncate, log file

The new logging handler was truncating the log file on each start.
Append by default.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>