[imapfilter-devel] RFC: IDLE support for imapfilter-2.0.2 (patch)

Hans-Werner Hilse hilse at sub.uni-goettingen.de
Mon Jul 2 01:11:22 EEST 2007


Hi,

as I had said, I was thinking about implementing support for the IDLE
extension in imapfilter.

My first take on it is attached as a patch, as well as a short
test/example. It works fine for me.

Things I did not yet check (but I will, and report back here):
- make sure it "works" when server has no IDLE capability

Things I did check:
- timeout works

Explanation:

The patch allows imapfilter scripts to drop the polling behaviour and
use the IDLE capability of the IMAP server if implemented. It adds a
function that lets the process sleep until a change to the mailbox (at
the moment: new messages and expunges) is detected. This way, a
time-based polling can be circumvented and push-update like behaviour
can be implemented.

User frontend:
- account:idle_supported() returns true if the server supports the IDLE
  extension
- account[mailbox]:idle() makes the script sleep until server announces
  either an update to the mailbox (returns true), or an error (returns false)

Lua backend:
- ifcore.idle_supported(account) returns true if the server supports
  IDLE
- ifcore.idle(account) puts server in IDLE state, returns true if
  changes happened, false if an error happened

In the C code:
- changed socket_read to use a specified timeout
- added request_idle, request_idle_supported, response_idle, check_untagged,
  imap_idle, ifcore_idle, ifcore_idle_supported, receive_response_timeout
- added consts for responses

Please see the attached demo script in order to see how it works. The
"idletimeout" server setting allows to specify when an IDLE session is
interrupted and a NOOP is being send in order to keep the connection
up, needed e.g. when NAT gateways are in the path. Default is 29
minutes, since that's what the IDLE RFC recommends.

I would be happy if I could get some opinions, especially regarding
inclusion into imapfilter. Of course, I volunteer to write
documentation for the man pages.

References:
- RFC 2177 - IMAP4 IDLE command (http://www.faqs.org/rfcs/rfc2177.html)

-hwh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-idle.lua
Type: text/x-lua
Size: 436 bytes
Desc: not available
URL: <http://lists.hellug.gr/pipermail/imapfilter-devel/attachments/20070702/2b34b69a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imapfilter-2.0.2-idle-support.patch
Type: text/x-patch
Size: 13411 bytes
Desc: not available
URL: <http://lists.hellug.gr/pipermail/imapfilter-devel/attachments/20070702/2b34b69a/attachment-0001.bin>


More information about the Imapfilter-devel mailing list