Correct current selected mailbox functionality
Correct the functionality that provides monitoring of the current selected mailbox in each account, where the wrong variable was written. Simplify and clarify the code around this functionality.
This commit is contained in:
parent
e888721242
commit
d7f2910212
|
@ -31,6 +31,8 @@ Account._mt.__call = function (self, arg)
|
||||||
|
|
||||||
object._imap = arg
|
object._imap = arg
|
||||||
|
|
||||||
|
object._selected = nil
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +48,7 @@ function Account._login_user(self)
|
||||||
if (r == nil) then
|
if (r == nil) then
|
||||||
return true
|
return true
|
||||||
elseif (r == true) then
|
elseif (r == true) then
|
||||||
self._mailbox = nil
|
self._selected = nil
|
||||||
return true
|
return true
|
||||||
elseif (r == false) then
|
elseif (r == false) then
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -38,10 +38,11 @@ function Mailbox._detach_message(self, uid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Mailbox._cached_select(self, account, mbox)
|
function Mailbox._cached_select(self)
|
||||||
if (account._mailbox == nil or account._mailbox ~= mbox) then
|
if (self._account._selected == nil or
|
||||||
if (ifcore.select(self._account._imap, mbox) == true) then
|
self._account._selected ~= self._mailbox) then
|
||||||
account._mailbox = mbox
|
if (ifcore.select(self._account._imap, self._mailbox) == true) then
|
||||||
|
self._account._selected = self._mailbox
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
@ -51,8 +52,8 @@ function Mailbox._cached_select(self, account, mbox)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Mailbox._cached_close(self, account)
|
function Mailbox._cached_close(self)
|
||||||
account._mailbox = nil
|
self._account._selected = nil
|
||||||
return ifcore.close(self._account._imap)
|
return ifcore.close(self._account._imap)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,15 +83,14 @@ function Mailbox._send_query(self, criteria, charset)
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local _, results = ifcore.search(self._account._imap, query, charset)
|
local _, results = ifcore.search(self._account._imap, query, charset)
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (results == nil) then
|
if (results == nil) then
|
||||||
|
@ -115,8 +115,7 @@ function Mailbox._flag_messages(self, mode, flags, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,7 +140,7 @@ function Mailbox._flag_messages(self, mode, flags, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
@ -159,7 +158,7 @@ function Mailbox._copy_messages(self, dest, messages)
|
||||||
|
|
||||||
local r = false
|
local r = false
|
||||||
if (self._account._imap == dest._account._imap) then
|
if (self._account._imap == dest._account._imap) then
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~= true) then
|
if (self._cached_select(self) ~= true) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -178,7 +177,7 @@ function Mailbox._copy_messages(self, dest, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local fast = self._fetch_fast(self, messages)
|
local fast = self._fetch_fast(self, messages)
|
||||||
|
@ -213,8 +212,7 @@ function Mailbox._fetch_fast(self, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -235,7 +233,7 @@ function Mailbox._fetch_fast(self, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -250,8 +248,7 @@ function Mailbox._fetch_flags(self, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -268,7 +265,7 @@ function Mailbox._fetch_flags(self, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -283,8 +280,7 @@ function Mailbox._fetch_date(self, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -305,7 +301,7 @@ function Mailbox._fetch_date(self, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -320,8 +316,7 @@ function Mailbox._fetch_size(self, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -342,7 +337,7 @@ function Mailbox._fetch_size(self, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -357,8 +352,7 @@ function Mailbox._fetch_header(self, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -380,7 +374,7 @@ function Mailbox._fetch_header(self, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -395,8 +389,7 @@ function Mailbox._fetch_body(self, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -417,7 +410,7 @@ function Mailbox._fetch_body(self, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -455,8 +448,7 @@ function Mailbox._fetch_fields(self, fields, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -483,7 +475,7 @@ function Mailbox._fetch_fields(self, fields, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -498,8 +490,7 @@ function Mailbox._fetch_structure(self, messages)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -522,7 +513,7 @@ function Mailbox._fetch_structure(self, messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -533,8 +524,7 @@ function Mailbox._fetch_parts(self, parts, message)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -555,7 +545,7 @@ function Mailbox._fetch_parts(self, parts, message)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (type(options) == 'table' and options.close == true) then
|
if (type(options) == 'table' and options.close == true) then
|
||||||
self._cached_close(self, self._account._imap)
|
self._cached_close(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -1231,8 +1221,7 @@ function Mailbox.enter_idle(self)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self._cached_select(self, self._account._imap, self._mailbox) ~=
|
if (self._cached_select(self) ~= true) then
|
||||||
true) then
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue