]>
code.delx.au - offlineimap/blob - offlineimap/syncmaster.py
1 # OfflineIMAP synchronization master code
2 # Copyright (C) 2002-2007 John Goerzen
3 # <jgoerzen@complete.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 from offlineimap
import imapserver
, repository
, folder
, mbnames
, threadutil
, version
21 from offlineimap
.threadutil
import InstanceLimitedThread
, ExitNotifyThread
22 import offlineimap
.accounts
23 from offlineimap
.accounts
import SyncableAccount
, SigListener
24 from offlineimap
.ui
import UIBase
25 import re
, os
, os
.path
, offlineimap
, sys
26 from ConfigParser
import ConfigParser
27 from threading
import *
29 def syncaccount(threads
, config
, accountname
, siglisteners
):
30 account
= SyncableAccount(config
, accountname
)
31 siglistener
= SigListener()
32 thread
= InstanceLimitedThread(instancename
= 'ACCOUNTLIMIT',
33 target
= account
.syncrunner
,
34 name
= "Account sync %s" % accountname
,
35 kwargs
= {'siglistener': siglistener
} )
36 # the Sync Runner thread is the only one that will mutate siglisteners
37 siglisteners
.append(siglistener
)
42 def syncitall(accounts
, config
, siglisteners
):
43 currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
44 ui
= UIBase
.getglobalui()
45 threads
= threadutil
.threadlist()
46 mbnames
.init(config
, accounts
)
47 for accountname
in accounts
:
48 syncaccount(threads
, config
, accountname
, siglisteners
)
49 # Wait for the threads to finish.