MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / handlech

Function handlech

src/bitmessagecurses/__init__.py:266–707  ·  view source on GitHub ↗
(c, stdscr)

Source from the content-addressed store, hash-verified

264 stdscr.keypad(1)
265 curses.curs_set(0)
266def handlech(c, stdscr):
267 if c != curses.ERR:
268 global inboxcur, addrcur, sentcur, subcur, abookcur, blackcur
269 if c in range(256):
270 if chr(c) in '12345678':
271 global menutab
272 menutab = int(chr(c))
273 elif chr(c) == 'q':
274 global quit
275 quit = True
276 elif chr(c) == '\n':
277 curses.curs_set(1)
278 d = Dialog(dialog="dialog")
279 if menutab == 1:
280 set_background_title(d, "Inbox Message Dialog Box")
281 r, t = d.menu("Do what with \""+inbox[inboxcur][5]+"\" from \""+inbox[inboxcur][3]+"\"?",
282 choices=[("1", "View message"),
283 ("2", "Mark message as unread"),
284 ("3", "Reply"),
285 ("4", "Add sender to Address Book"),
286 ("5", "Save message as text file"),
287 ("6", "Move to trash")])
288 if r == d.DIALOG_OK:
289 if t == "1": # View
290 set_background_title(d, "\""+inbox[inboxcur][5]+"\" from \""+inbox[inboxcur][3]+"\" to \""+inbox[inboxcur][1]+"\"")
291 data = ""
292 ret = sqlQuery("SELECT message FROM inbox WHERE msgid=?", inbox[inboxcur][0])
293 if ret != []:
294 for row in ret:
295 data, = row
296 data = shared.fixPotentiallyInvalidUTF8Data(data)
297 msg = ""
298 for i, item in enumerate(data.split("\n")):
299 msg += fill(item, replace_whitespace=False)+"\n"
300 scrollbox(d, unicode(ascii(msg)), 30, 80)
301 sqlExecute("UPDATE inbox SET read=1 WHERE msgid=?", inbox[inboxcur][0])
302 inbox[inboxcur][7] = 1
303 else:
304 scrollbox(d, unicode("Could not fetch message."))
305 elif t == "2": # Mark unread
306 sqlExecute("UPDATE inbox SET read=0 WHERE msgid=?", inbox[inboxcur][0])
307 inbox[inboxcur][7] = 0
308 elif t == "3": # Reply
309 curses.curs_set(1)
310 m = inbox[inboxcur]
311 fromaddr = m[4]
312 ischan = False
313 for i, item in enumerate(addresses):
314 if fromaddr == item[2] and item[3] != 0:
315 ischan = True
316 break
317 if not addresses[i][1]:
318 scrollbox(d, unicode("Sending address disabled, please either enable it or choose a different address."))
319 return
320 toaddr = m[2]
321 if ischan:
322 toaddr = fromaddr
323

Callers 1

runFunction · 0.85

Calls 15

BMConfigParserClass · 0.90
set_background_titleFunction · 0.85
sqlQueryFunction · 0.85
scrollboxFunction · 0.85
asciiFunction · 0.85
sqlExecuteFunction · 0.85
sendMessageFunction · 0.85
dialogresetFunction · 0.85
decodeAddressFunction · 0.85
addBMIfNotPresentFunction · 0.85
redrawFunction · 0.85
putMethod · 0.80

Tested by

no test coverage detected