JSON Adapter/MessageCache

Description

p≡p for Thunderbird is using the MIME implementation of the p≡p engine. Therefore, when calling decrypt_message() and mime_encode_message() p≡p for Thunderbird transmits most of the data unmodified twice through the socket to the p≡p JSON server adapter. This is a waste of CPU cycles and I/O.

The functionality of the Message Cache mitigates the performance drawback. Instead of transmitting all data twice .longmsg, .longmsg_formatted and the .attachments are cached and not re-transmitted.

API

cache_mime_decode_message()

This function has the same arguments as mime_decode_message(). It is a drop-in replacement. This function adds msg as src to the cache using msg.id as key. Hence the delivery of msg.id is mandatory.

cache_decrypt_message()

This function has the same arguments as decrypt_message(). It is a drop-in replacement. This function uses src and dst from the cache using src.id as key. Hence the delivery of src.id is mandatory.

cache_decrypt_message() does not send back .longmsg, .longmsg_formatted and the .attachments, neither from src nor from dst. All other fields remain unmodified and are transmitted.

cache_encrypt_message()

This function has the same arguments as encrypt_message(). It is a drop-in replacement. This function uses src and dst from the cache using src.id as key. Hence the delivery of src.id is mandatory.

cache_encrypt_message() does not send back .longmsg, .longmsg_formatted and the .attachments, neither from src nor from dst. All other fields remain unmodified and are transmitted.

cache_encrypt_message_for_self()

This function has the same arguments as encrypt_message_for_self(). It is a drop-in replacement. This function uses src and dst from the cache using src.id as key. Hence the delivery of src.id is mandatory.

cache_encrypt_message_for_self() does not send back .longmsg, .longmsg_formatted and the .attachments, neither from src nor from dst. All other fields remain unmodified and are transmitted.

cache_mime_encode_message()

This function has an int parameter followed by the arguments of mime_encode_message(). The first parameter must be 0 if the src field of the cache is to be encoded. It must be 1 if the dst field of the cache is to be encoded. All other parameters do not differ from mime_encode_message().

This function deletes the message from the Message Cache, which is identified by msg.id. Hence the delivery of msg.id is mandatory.

cache_release(id)

When a call to cache_mime_decode_message() is followed by a call to cache_mime_encode_message() calling cache_release(id) is not necessary. This function is for removing a cache entry in case it was added by cache_mime_decode_message() but no further call to cache_mime_encode_message() will occur.