mirror of https://github.com/lcpz/lain.git
imap: asynchronous
This commit is contained in:
parent
6f988d8eb7
commit
763805f5ad
|
@ -20,31 +20,27 @@ local setmetatable = setmetatable
|
||||||
-- Mail IMAP check
|
-- Mail IMAP check
|
||||||
-- 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 mail = args.mail
|
||||||
|
local password = args.password
|
||||||
|
local port = args.port or 993
|
||||||
|
local timeout = args.timeout or 60
|
||||||
|
local is_plain = args.is_plain or false
|
||||||
|
local followtag = args.followtag or false
|
||||||
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
local server = args.server
|
local head_command = "curl --connect-timeout 3 -fsm 3"
|
||||||
local mail = args.mail
|
|
||||||
local password = args.password
|
|
||||||
|
|
||||||
local port = args.port or 993
|
|
||||||
local timeout = args.timeout or 60
|
|
||||||
local is_plain = args.is_plain or false
|
|
||||||
local followtag = args.followtag or false
|
|
||||||
local settings = args.settings or function() end
|
|
||||||
|
|
||||||
local head_command = "curl --connect-timeout 3 -fsm 3"
|
|
||||||
local request = "-X 'SEARCH (UNSEEN)'"
|
local request = "-X 'SEARCH (UNSEEN)'"
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue