]>
code.delx.au - offlineimap/blob - offlineimap/head/offlineimap/ui/Blinkenlights.py
1 # Blinkenlights base classes
2 # Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 from threading
import *
20 from offlineimap
.ui
.UIBase
import UIBase
22 from offlineimap
.threadutil
import MultiLock
24 from debuglock
import DebuggingLock
27 """This is a mix-in class that should be mixed in with either UIBase
28 or another appropriate base class. The Tk interface, for instance,
29 will probably mix it in with VerboseUI."""
31 def acct(s
, accountname
):
32 s
.gettf().setcolor('purple')
33 s
.__class
__.__bases
__[-1].acct(s
, accountname
)
35 def connecting(s
, hostname
, port
):
36 s
.gettf().setcolor('gray')
37 s
.__class
__.__bases
__[-1].connecting(s
, hostname
, port
)
39 def syncfolders(s
, srcrepos
, destrepos
):
40 s
.gettf().setcolor('blue')
41 s
.__class
__.__bases
__[-1].syncfolders(s
, srcrepos
, destrepos
)
43 def syncingfolder(s
, srcrepos
, srcfolder
, destrepos
, destfolder
):
44 s
.gettf().setcolor('cyan')
45 s
.__class
__.__bases
__[-1].syncingfolder(s
, srcrepos
, srcfolder
, destrepos
, destfolder
)
47 def loadmessagelist(s
, repos
, folder
):
48 s
.gettf().setcolor('green')
49 s
._msg
("Scanning folder [%s/%s]" % (s
.getnicename(repos
),
50 folder
.getvisiblename()))
52 def syncingmessages(s
, sr
, sf
, dr
, df
):
53 s
.gettf().setcolor('blue')
54 s
.__class
__.__bases
__[-1].syncingmessages(s
, sr
, sf
, dr
, df
)
56 def copyingmessage(s
, uid
, src
, destlist
):
57 s
.gettf().setcolor('orange')
58 s
.__class
__.__bases
__[-1].copyingmessage(s
, uid
, src
, destlist
)
60 def deletingmessages(s
, uidlist
, destlist
):
61 s
.gettf().setcolor('red')
62 s
.__class
__.__bases
__[-1].deletingmessages(s
, uidlist
, destlist
)
64 def deletingmessage(s
, uid
, destlist
):
65 s
.gettf().setcolor('red')
66 s
.__class
__.__bases
__[-1].deletingmessage(s
, uid
, destlist
)
68 def addingflags(s
, uid
, flags
, destlist
):
69 s
.gettf().setcolor('yellow')
70 s
.__class
__.__bases
__[-1].addingflags(s
, uid
, flags
, destlist
)
72 def deletingflags(s
, uid
, flags
, destlist
):
73 s
.gettf().setcolor('pink')
74 s
.__class
__.__bases
__[-1].deletingflags(s
, uid
, flags
, destlist
)
77 s
.availablethreadframes
= {}
79 s
.tflock
= MultiLock()
81 def threadExited(s
, thread
):
82 threadid
= thread
.threadid
83 accountname
= s
.getthreadaccount(thread
)
86 if threadid
in s
.threadframes
[accountname
]:
87 tf
= s
.threadframes
[accountname
][threadid
]
88 del s
.threadframes
[accountname
][threadid
]
89 s
.availablethreadframes
[accountname
].append(tf
)
94 UIBase
.threadExited(s
, thread
)
97 threadid
= thread
.get_ident()
98 accountname
= s
.getthreadaccount()
103 if not accountname
in s
.threadframes
:
104 s
.threadframes
[accountname
] = {}
106 if threadid
in s
.threadframes
[accountname
]:
107 return s
.threadframes
[accountname
][threadid
]
109 if not accountname
in s
.availablethreadframes
:
110 s
.availablethreadframes
[accountname
] = []
112 if len(s
.availablethreadframes
[accountname
]):
113 tf
= s
.availablethreadframes
[accountname
].pop(0)
114 tf
.setthread(currentThread())
116 tf
= s
.getaccountframe().getnewthreadframe()
117 s
.threadframes
[accountname
][threadid
] = tf