]>
code.delx.au - offlineimap/blob - offlineimap/ui/Blinkenlights.py
717e81ba8280743cc067a8b8fb1974df06467062
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 from threading
import *
20 from offlineimap
.ui
.UIBase
import UIBase
22 from offlineimap
.threadutil
import MultiLock
25 """This is a mix-in class that should be mixed in with either UIBase
26 or another appropriate base class. The Tk interface, for instance,
27 will probably mix it in with VerboseUI."""
29 def acct(s
, accountname
):
30 s
.gettf().setcolor('purple')
31 s
.__class
__.__bases
__[-1].acct(s
, accountname
)
33 def connecting(s
, hostname
, port
):
34 s
.gettf().setcolor('gray')
35 s
.__class
__.__bases
__[-1].connecting(s
, hostname
, port
)
37 def syncfolders(s
, srcrepos
, destrepos
):
38 s
.gettf().setcolor('blue')
39 s
.__class
__.__bases
__[-1].syncfolders(s
, srcrepos
, destrepos
)
41 def syncingfolder(s
, srcrepos
, srcfolder
, destrepos
, destfolder
):
42 s
.gettf().setcolor('cyan')
43 s
.__class
__.__bases
__[-1].syncingfolder(s
, srcrepos
, srcfolder
, destrepos
, destfolder
)
45 def loadmessagelist(s
, repos
, folder
):
46 s
.gettf().setcolor('green')
47 s
._msg
("Scanning folder [%s/%s]" % (s
.getnicename(repos
),
48 folder
.getvisiblename()))
50 def syncingmessages(s
, sr
, sf
, dr
, df
):
51 s
.gettf().setcolor('blue')
52 s
.__class
__.__bases
__[-1].syncingmessages(s
, sr
, sf
, dr
, df
)
54 def copyingmessage(s
, uid
, src
, destlist
):
55 s
.gettf().setcolor('orange')
56 s
.__class
__.__bases
__[-1].copyingmessage(s
, uid
, src
, destlist
)
58 def deletingmessages(s
, uidlist
, destlist
):
59 s
.gettf().setcolor('red')
60 s
.__class
__.__bases
__[-1].deletingmessages(s
, uidlist
, destlist
)
62 def deletingmessage(s
, uid
, destlist
):
63 s
.gettf().setcolor('red')
64 s
.__class
__.__bases
__[-1].deletingmessage(s
, uid
, destlist
)
66 def addingflags(s
, uidlist
, flags
, destlist
):
67 s
.gettf().setcolor('yellow')
68 s
.__class
__.__bases
__[-1].addingflags(s
, uidlist
, flags
, destlist
)
70 def deletingflags(s
, uidlist
, flags
, destlist
):
71 s
.gettf().setcolor('pink')
72 s
.__class
__.__bases
__[-1].deletingflags(s
, uidlist
, flags
, destlist
)
75 s
.availablethreadframes
= {}
77 s
.tflock
= MultiLock()
79 def threadExited(s
, thread
):
80 threadid
= thread
.threadid
81 accountname
= s
.getthreadaccount(thread
)
84 if threadid
in s
.threadframes
[accountname
]:
85 tf
= s
.threadframes
[accountname
][threadid
]
86 del s
.threadframes
[accountname
][threadid
]
87 s
.availablethreadframes
[accountname
].append(tf
)
92 UIBase
.threadExited(s
, thread
)
95 threadid
= thread
.get_ident()
96 accountname
= s
.getthreadaccount()
101 if not accountname
in s
.threadframes
:
102 s
.threadframes
[accountname
] = {}
104 if threadid
in s
.threadframes
[accountname
]:
105 return s
.threadframes
[accountname
][threadid
]
107 if not accountname
in s
.availablethreadframes
:
108 s
.availablethreadframes
[accountname
] = []
110 if len(s
.availablethreadframes
[accountname
]):
111 tf
= s
.availablethreadframes
[accountname
].pop(0)
112 tf
.setthread(currentThread())
114 tf
= s
.getaccountframe().getnewthreadframe()
115 s
.threadframes
[accountname
][threadid
] = tf
120 def sleep(s
, sleepsecs
):
121 s
.gettf().setcolor('red')
122 s
.getaccountframe().startsleep(sleepsecs
)
123 UIBase
.sleep(s
, sleepsecs
)
125 def sleeping(s
, sleepsecs
, remainingsecs
):
126 if remainingsecs
and s
.gettf().getcolor() == 'black':
127 s
.gettf().setcolor('red')
129 s
.gettf().setcolor('black')
130 return s
.getaccountframe().sleeping(sleepsecs
, remainingsecs
)