Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Capability items to be 'dynamic' #181

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

shaun-a-johnson
Copy link
Contributor

This patch converts the previous string-literal representation of the capabilities to a dynamic list of 'capability objects' each reflecting the capability word they intend to add along with flags that represent when the capability word is to be displayed (eg: varying states).

Upon a request for the capability string the list of capability objects is iterated and a capability string is dynamically built by appending each capability word if the conditions described in the flags of the capability object are met.

This patch provides full backwards compatibility for existing plugins that might have previously used client_add_capability as well as honors (and converts) existing string literal capability words into equivalent additions to the new list of capability objects.

Some examples of circumstances that can be specified when adding
new capabilities are:

  • Only show at pre-login or post-login
  • Only show if any TLS/SSL is active/inactive
  • Only show if plaintext auth login is enabled

The default operation is to show the capabaility word if at least
one of the circumstances is met, an additional flag provides the
ability to only show the capability word if exactly all of the
circumstances are met.

The API for adding capabilities now simply wraps the API for adding
entries to the capability list with the 'show always' flag set.

Retrieving the capability string is now a loop that iterates the list
of capability objects and evaluates whether each capability should be
added to the capability string based on the state of the current IMAP
session.

Added a new API to lib-imap which exposes functions for manipulating a
capability list.  This addition is the first step towards conditionally
displaying capabilities.  For example, displaying certain capabilities
to the client only after TLS has been negotiated.
Updated imap-login to use the new capability list API from lib-imap
which will allow for pre-login IMAP capabilities to be displayed
conditionally.
This adds two new boolean fields: 'secured', and 'ssl_secured' to the
imap client structure, these reflect the values of conn_secured and
conn_ssl_secured respectively.

This is a prerequisite to integrating the imap_capability_list APIs into
imap because imap needs to distinguish between secured/tls/non-secured
connections when determining whether conditional capabilities should be
displayed or not.
Updated imap to use the new capability list API from lib-imap which will
allow for post-login imap capabilities to be displayed conditionally.
This ensures functionality of client_add_capability() does not change,
and it introduces a new imap function client_get_capability() which is
now used everywhere that client->capability_string was previously used.
@sirainen
Copy link
Contributor

sirainen commented Mar 2, 2022

Reopened from #86. Internal Jira: DOP-1362

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants