imap: asynchronous

This commit is contained in:
copycat-killer 2017-01-21 00:29:31 +01:00
parent 6f988d8eb7
commit 763805f5ad
1 changed files with 14 additions and 18 deletions

View File

@ -21,13 +21,11 @@ local setmetatable = setmetatable
-- lain.widgets.imap -- lain.widgets.imap
local function worker(args ) local function worker(args )
local imap = {} local imap = helpers.make_widget_textbox()
local args = args or {} local args = args or {}
local server = args.server local server = args.server
local mail = args.mail local mail = args.mail
local password = args.password local password = args.password
local port = args.port or 993 local port = args.port or 993
local timeout = args.timeout or 60 local timeout = args.timeout or 60
local is_plain = args.is_plain or false local is_plain = args.is_plain or false
@ -40,11 +38,9 @@ local function worker(args)
helpers.set_map(mail, 0) helpers.set_map(mail, 0)
if not is_plain then if not is_plain then
password = helpers.read_pipe(password):gsub("\n", "") helpers.async(password, function(f) password = f:gsub("\n", "") end)
end end
imap.widget = wibox.widget.textbox('')
function update() function update()
mail_notification_preset = { mail_notification_preset = {
icon = helpers.icons_dir .. "mail.png", icon = helpers.icons_dir .. "mail.png",
@ -78,7 +74,7 @@ local function worker(args)
end end
helpers.newtimer(mail, timeout, update, true) helpers.newtimer(mail, timeout, update)
return setmetatable(imap, { __index = imap.widget }) return setmetatable(imap, { __index = imap.widget })
end end