On 5. May 2021, at 17.28, Ryan Beethe <ryan@splintermail.com> wrote:

You probably shold look some much more simple commands as
insipiration. Try looking e.g. how cmd_id is implemented instead.

I implemented a simpler command as well, but because it was simple I
didn't have any questions :)

Unfortunately I do need a long-running command more like IDLE as well.

What kind of "long running command" did you have in mind?

My email service offers a layer of encryption which is not transparent
to IMAP, and where the keys are created and kept on each client device.
Since IMAP synchronization is bidirectional, each client needs to
encrypt uploaded messages to all known client devices.  Thus, clients
need a way update their list of all known keys.

So the command is roughly:

   tag XKEYSYNC [known_fingerprint ...]
   ...
   DONE

And the responses are rougly:

   * XKEYSYNC DELETED fingerprint

   * XKEYSYNC CREATED public_key

The full source can be found at:

github.com/splintermail/splintermail-client/blob/dev/server/xkeysync.c

These look rather simple commands. Like Aki said, look at the simple commands for examples rather than the more complicated IDLE and APPEND commands which have various special cases.

But do you have to implement these command extensions? Looks like it would be much easier to just use the IMAP METADATA extension and store them in the server metadata.