]>
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
19 from offlineimap
import imaplib2
, imapserver
, repository
, folder
, mbnames
, threadutil
, version
20 from offlineimap
.threadutil
import InstanceLimitedThread
, ExitNotifyThread
21 import offlineimap
.accounts
22 from offlineimap
.accounts
import SyncableAccount
, SigListener
23 from offlineimap
.ui
import UIBase
24 import re
, os
, os
.path
, offlineimap
, sys
25 from ConfigParser
import ConfigParser
26 from threading
import *
28 def syncaccount(threads
, config
, accountname
, siglisteners
):
29 account
= SyncableAccount(config
, accountname
)
30 siglistener
= SigListener()
31 thread
= InstanceLimitedThread(instancename
= 'ACCOUNTLIMIT',
32 target
= account
.syncrunner
,
33 name
= "Account sync %s" % accountname
,
34 kwargs
= {'siglistener': siglistener
} )
35 # the Sync Runner thread is the only one that will mutate siglisteners
36 siglisteners
.append(siglistener
)
41 def syncitall(accounts
, config
, siglisteners
):
42 currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
43 ui
= UIBase
.getglobalui()
44 threads
= threadutil
.threadlist()
45 mbnames
.init(config
, accounts
)
46 for accountname
in accounts
:
47 syncaccount(threads
, config
, accountname
, siglisteners
)
48 # Wait for the threads to finish.