]>
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; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 from threading
import *
19 from offlineimap
.ui
.UIBase
import UIBase
21 from offlineimap
.threadutil
import MultiLock
24 """This is a mix-in class that should be mixed in with either UIBase
25 or another appropriate base class. The Tk interface, for instance,
26 will probably mix it in with VerboseUI."""
28 def acct(s
, accountname
):
29 s
.gettf().setcolor('purple')
30 s
.__class
__.__bases
__[-1].acct(s
, accountname
)
32 def connecting(s
, hostname
, port
):
33 s
.gettf().setcolor('gray')
34 s
.__class
__.__bases
__[-1].connecting(s
, hostname
, port
)
36 def syncfolders(s
, srcrepos
, destrepos
):
37 s
.gettf().setcolor('blue')
38 s
.__class
__.__bases
__[-1].syncfolders(s
, srcrepos
, destrepos
)
40 def syncingfolder(s
, srcrepos
, srcfolder
, destrepos
, destfolder
):
41 s
.gettf().setcolor('cyan')
42 s
.__class
__.__bases
__[-1].syncingfolder(s
, srcrepos
, srcfolder
, destrepos
, destfolder
)
44 def loadmessagelist(s
, repos
, folder
):
45 s
.gettf().setcolor('green')
46 s
._msg
("Scanning folder [%s/%s]" % (s
.getnicename(repos
),
47 folder
.getvisiblename()))
49 def syncingmessages(s
, sr
, sf
, dr
, df
):
50 s
.gettf().setcolor('blue')
51 s
.__class
__.__bases
__[-1].syncingmessages(s
, sr
, sf
, dr
, df
)
53 def copyingmessage(s
, uid
, src
, destlist
):
54 s
.gettf().setcolor('orange')
55 s
.__class
__.__bases
__[-1].copyingmessage(s
, uid
, src
, destlist
)
57 def deletingmessages(s
, uidlist
, destlist
):
58 s
.gettf().setcolor('red')
59 s
.__class
__.__bases
__[-1].deletingmessages(s
, uidlist
, destlist
)
61 def deletingmessage(s
, uid
, destlist
):
62 s
.gettf().setcolor('red')
63 s
.__class
__.__bases
__[-1].deletingmessage(s
, uid
, destlist
)
65 def addingflags(s
, uidlist
, flags
, destlist
):
66 s
.gettf().setcolor('yellow')
67 s
.__class
__.__bases
__[-1].addingflags(s
, uidlist
, flags
, destlist
)
69 def deletingflags(s
, uidlist
, flags
, destlist
):
70 s
.gettf().setcolor('pink')
71 s
.__class
__.__bases
__[-1].deletingflags(s
, uidlist
, flags
, destlist
)
74 s
.availablethreadframes
= {}
76 s
.tflock
= MultiLock()
78 def threadExited(s
, thread
):
79 threadid
= thread
.threadid
80 accountname
= s
.getthreadaccount(thread
)
83 if threadid
in s
.threadframes
[accountname
]:
84 tf
= s
.threadframes
[accountname
][threadid
]
85 del s
.threadframes
[accountname
][threadid
]
86 s
.availablethreadframes
[accountname
].append(tf
)
91 UIBase
.threadExited(s
, thread
)
94 threadid
= thread
.get_ident()
95 accountname
= s
.getthreadaccount()
100 if not accountname
in s
.threadframes
:
101 s
.threadframes
[accountname
] = {}
103 if threadid
in s
.threadframes
[accountname
]:
104 return s
.threadframes
[accountname
][threadid
]
106 if not accountname
in s
.availablethreadframes
:
107 s
.availablethreadframes
[accountname
] = []
109 if len(s
.availablethreadframes
[accountname
]):
110 tf
= s
.availablethreadframes
[accountname
].pop(0)
111 tf
.setthread(currentThread())
113 tf
= s
.getaccountframe().getnewthreadframe()
114 s
.threadframes
[accountname
][threadid
] = tf
119 def sleep(s
, sleepsecs
):
120 s
.gettf().setcolor('red')
121 s
.getaccountframe().startsleep(sleepsecs
)
122 UIBase
.sleep(s
, sleepsecs
)
124 def sleeping(s
, sleepsecs
, remainingsecs
):
125 if remainingsecs
and s
.gettf().getcolor() == 'black':
126 s
.gettf().setcolor('red')
128 s
.gettf().setcolor('black')
129 return s
.getaccountframe().sleeping(sleepsecs
, remainingsecs
)