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>
Add offlineimap.utils to the list of our modules

Forgot to do it while was adding stacktrace support.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
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>
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>
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>
IMAP class: don't suggest multithreading in single-threaded mode

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
Added support for email date synchronization with the file timestamp, through the repository "syncdate" option.

When using the (new) "syncdate" option in a Maildir repository, the local file will have the mtime/atime matching the messages' date.
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.
Without the option, the local file will have their timestamp set to the time offlineimap ran.

You likely want this option when you bootstrap your initial synchronization, or if you run offlineimap very sparsely.

Update copyright notice and use proper method for the repository object instead of direct access
Fix a bug with the email date parsing is not giving a valid date crashing the process.

Signed-off-by: Cyril RUSSO <boite.pour.spam@gmail.com>