]>
code.delx.au - offlineimap/blob - 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., 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 skippingfolder(s
, folder
):
46 s
.gettf().setcolor('cyan')
47 s
.__class
__.__bases
__[-1].skippingfolder(s
, folder
)
49 def loadmessagelist(s
, repos
, folder
):
50 s
.gettf().setcolor('green')
51 s
._msg
("Scanning folder [%s/%s]" % (s
.getnicename(repos
),
52 folder
.getvisiblename()))
54 def syncingmessages(s
, sr
, sf
, dr
, df
):
55 s
.gettf().setcolor('blue')
56 s
.__class
__.__bases
__[-1].syncingmessages(s
, sr
, sf
, dr
, df
)
58 def copyingmessage(s
, uid
, src
, destlist
):
59 s
.gettf().setcolor('orange')
60 s
.__class
__.__bases
__[-1].copyingmessage(s
, uid
, src
, destlist
)
62 def deletingmessages(s
, uidlist
, destlist
):
63 s
.gettf().setcolor('red')
64 s
.__class
__.__bases
__[-1].deletingmessages(s
, uidlist
, destlist
)
66 def deletingmessage(s
, uid
, destlist
):
67 s
.gettf().setcolor('red')
68 s
.__class
__.__bases
__[-1].deletingmessage(s
, uid
, destlist
)
70 def addingflags(s
, uidlist
, flags
, destlist
):
71 s
.gettf().setcolor('yellow')
72 s
.__class
__.__bases
__[-1].addingflags(s
, uidlist
, flags
, destlist
)
74 def deletingflags(s
, uidlist
, flags
, destlist
):
75 s
.gettf().setcolor('pink')
76 s
.__class
__.__bases
__[-1].deletingflags(s
, uidlist
, flags
, destlist
)
78 def warn(s
, msg
, minor
= 0):
80 s
.gettf().setcolor('pink')
82 s
.gettf().setcolor('red')
83 s
.__class
__.__bases
__[-1].warn(s
, msg
, minor
)
86 s
.availablethreadframes
= {}
88 s
.tflock
= MultiLock()
90 def threadExited(s
, thread
):
91 threadid
= thread
.threadid
92 accountname
= s
.getthreadaccount(thread
)
95 if threadid
in s
.threadframes
[accountname
]:
96 tf
= s
.threadframes
[accountname
][threadid
]
97 del s
.threadframes
[accountname
][threadid
]
98 s
.availablethreadframes
[accountname
].append(tf
)
103 UIBase
.threadExited(s
, thread
)
106 threadid
= thread
.get_ident()
107 accountname
= s
.getthreadaccount()
112 if not accountname
in s
.threadframes
:
113 s
.threadframes
[accountname
] = {}
115 if threadid
in s
.threadframes
[accountname
]:
116 return s
.threadframes
[accountname
][threadid
]
118 if not accountname
in s
.availablethreadframes
:
119 s
.availablethreadframes
[accountname
] = []
121 if len(s
.availablethreadframes
[accountname
]):
122 tf
= s
.availablethreadframes
[accountname
].pop(0)
123 tf
.setthread(currentThread())
125 tf
= s
.getaccountframe().getnewthreadframe()
126 s
.threadframes
[accountname
][threadid
] = tf
131 def callhook(s
, msg
):
132 s
.gettf().setcolor('white')
133 s
.__class
__.__bases
__[-1].callhook(s
, msg
)
135 def sleep(s
, sleepsecs
, siglistener
):
136 s
.gettf().setcolor('red')
137 s
.getaccountframe().startsleep(sleepsecs
)
138 return UIBase
.sleep(s
, sleepsecs
, siglistener
)
140 def sleeping(s
, sleepsecs
, remainingsecs
):
141 if remainingsecs
and s
.gettf().getcolor() == 'black':
142 s
.gettf().setcolor('red')
144 s
.gettf().setcolor('black')
145 return s
.getaccountframe().sleeping(sleepsecs
, remainingsecs
)