Inherited Folder Properties

I’ve now posted my inherited folder property bug for checkin, so I thought it would be a good time to describe this method.

There are often situations in the mailnews code where some attribute of a folder is set, and you have to decide whether this is a global, per-server, per-folder tree, or per-folder attribute. For me, the immediate need was to decide whether to apply soft tags to messages. In the initial release of TaQuilla, I simply used a global that was either on or off. But that is less than ideal for something that is fairly intrusive like automatic tagging. Also, as I extend bayes analysis to RSS and news, the problem gets even more complex. Asking a user to enable or disable it in every folder separately, which is the other extreme, is a large burden for someone with tens or even hundreds of folders.

Enter the inherited folder property. In the underlying code, when I want to test whether to apply soft tags on messages in a folder, I simply ask for the inherited property for the folder:

softTagsToApply = folder.getInheritedStringProperty("softTagsToApply");

Then I get a list of soft tags for the folder.

So far, this is just like a normal folder property. But the inherited property can be precisely applied at many different levels. It looks up the property to apply like this:

  1. If the property value is defined on the folder, use that value
  2. If not, then get the inherited property from the folder’s parent
  3. At the root folder for a server, get the property value for the server object.
  4. The server object in turn may be assigned a global value using the preference mail.server.default.(propertyName)

So with this scheme, simply by changing the basic call from getStringProperty to getInheritedStringProperty, you can precisely control in an extension whether the property is applied for a specific folder, for a folder and its descendents, for a server, or globally.

I think that this should be the standard way to get folder properties in the future, unless there is some overriding reason why it should not be allowed. Here’s some examples of where I think we should be using it:

  • whether to apply gloda indexing to messages
  • whether to apply filters to new messages in an IMAP folder
  • retention policies
  • columns to display in thread pane
  • which folder to place Sent messages for replies

One issue though is that this value is tri-state (when we are talking about a boolean), or in the case of strings then there is an ambiguity between an empty string and a null string (which means inherit). So in cases where UI exists to set properties on a folder, then the UI will need to explictly support “inherit” as a separate option from (checked/unchecked) or (blank/not blank).

Share

4 comments to Inherited Folder Properties

  • [...] other than the inbox, previously you could not use TB filters on it. Now you can, controlled by an inherited folder property. There is no user interface for this feature at the moment, but I will add some to FiltaQuilla. See [...]

  • [...] a previous posting, I introduced the concept of inherited folder properties in the Mozilla mailnews products [...]

  • blankety blank

    My IMAP server has all folders at the top level (same level as INBOX) by default, and doesn’t allow certain folders like Trash to be moved to be subfolders of INBOX so this doesn’t help me (it doesn’t work in 3.0.1). There in no UI to enable / disable filters for INBOX (I assume it’s hardcoded to true) but would it be possible to add this UI to the account, since all folders appear as children of the account in Thunderbird’s “All Folders” view?

    • I’m not sure specifically which UI you are referring to here, as I am currently using inherited properties in several addons. But in general, the beauty of inherited folder properites is that if you don’t like to apply it at the folder level, you can apply it at the account level, or globally. Most of my extensions also include the account-level option as well, or if you know the property you can always add it yourself using preferences.

      So which particular feature are you trying to apply to an account?

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

To comment, click below to log in.