mail/components/extensions/schemas/mailTabs.json
author Geoff Lankow <geoff@darktrojan.net>
Thu, 12 Mar 2020 12:58:31 +0200
changeset 38476 0ab55e9b87ee6a6fda6fb628fbb82148ede7961e
parent 38153 5c29bf6eb78be3eda24e484bc4bf8ed5f7cfe3aa
child 38688 fa5c346560d7e9b1ed341e9e2bf644ebde887889
permissions -rw-r--r--
Bug 1621873 - Enforce mailTabs event/function permissions with the schema, not the code. r=mkmelin

[
  {
    "namespace": "mailTabs",
    "types": [
      {
        "id": "QuickFilterTextDetail",
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "String to match against the <var>recipients</var>, <var>author</var>, <var>subject</var>, or <var>body</var>."
          },
          "recipients": {
            "type": "boolean",
            "description": "Shows messages where <var>text</var> matches the recipients.",
            "optional": true
          },
          "author": {
            "type": "boolean",
            "description": "Shows messages where <var>text</var> matches the author.",
            "optional": true
          },
          "subject": {
            "type": "boolean",
            "description": "Shows messages where <var>text</var> matches the subject.",
            "optional": true
          },
          "body": {
            "type": "boolean",
            "description": "Shows messages where <var>text</var> matches the message body.",
            "optional": true
          }
        }
      }
    ],
    "functions": [
      {
        "name": "query",
        "type": "function",
        "description": "Gets all mail tabs that have the specified properties, or all mail tabs if no properties are specified.",
        "async": true,
        "parameters": [
          {
            "type": "object",
            "name": "queryInfo",
            "properties": {
              "active": {
                "type": "boolean",
                "optional": true,
                "description": "Whether the tabs are active in their windows."
              },
              "currentWindow": {
                "type": "boolean",
                "optional": true,
                "description": "Whether the tabs are in the current window."
              },
              "lastFocusedWindow": {
                "type": "boolean",
                "optional": true,
                "description": "Whether the tabs are in the last focused window."
              },
              "windowId": {
                "type": "integer",
                "optional": true,
                "minimum": -2,
                "description": "The ID of the parent window, or :ref:`windows.WINDOW_ID_CURRENT` for the current window."
              }
            }
          }
        ]
      },
      {
        "name": "update",
        "type": "function",
        "description": "Modifies the properties of a mail tab. Properties that are not specified in <var>updateProperties</var> are not modified.",
        "async": true,
        "parameters": [
          {
            "name": "tabId",
            "type": "integer",
            "description": "Defaults to the active tab of the current window.",
            "optional": true,
            "minimum": 1
          },
          {
            "name": "updateProperties",
            "type": "object",
            "properties": {
              "displayedFolder": {
                "$ref": "folders.MailFolder",
                "description": "Sets the folder displayed in the tab. The extension must have an accounts permission to do this.",
                "optional": true
              },
              "sortType": {
                "type": "string",
                "description": "Sorts the list of messages. <var>sortOrder</var> must also be given.",
                "optional": true,
                "enum": [
                  "none",
                  "date",
                  "subject",
                  "author",
                  "id",
                  "thread",
                  "priority",
                  "status",
                  "size",
                  "flagged",
                  "unread",
                  "recipient",
                  "location",
                  "tags",
                  "junkStatus",
                  "attachments",
                  "account",
                  "custom",
                  "received",
                  "correspondent"
                ]
              },
              "sortOrder": {
                "type": "string",
                "description": "Sorts the list of messages. <var>sortType</var> must also be given.",
                "optional": true,
                "enum": [
                  "none",
                  "ascending",
                  "descending"
                ]
              },
              "layout": {
                "type": "string",
                "description": "Sets the arrangement of the folder pane, message list pane, and message display pane. Note that setting this applies it to all mail tabs.",
                "optional": true,
                "enum": [
                  "standard",
                  "wide",
                  "vertical"
                ]
              },
              "folderPaneVisible": {
                "type": "boolean",
                "description": "Shows or hides the folder pane.",
                "optional": true
              },
              "messagePaneVisible": {
                "type": "boolean",
                "description": "Shows or hides the message display pane.",
                "optional": true
              }
            }
          }
        ]
      },
      {
        "name": "getSelectedMessages",
        "type": "function",
        "description": "Lists the selected messages in the current folder. A messages permission is required to do this.",
        "permissions": ["messagesRead"],
        "async": true,
        "parameters": [
          {
            "name": "tabId",
            "type": "integer",
            "description": "Defaults to the active tab of the current window.",
            "optional": true,
            "minimum": 1
          }
        ]
      },
      {
        "name": "setQuickFilter",
        "type": "function",
        "description": "Sets the Quick Filter user interface based on the options specified.",
        "async": true,
        "parameters": [
          {
            "name": "tabId",
            "type": "integer",
            "description": "Defaults to the active tab of the current window.",
            "optional": true,
            "minimum": 1
          },
          {
            "name": "properties",
            "type": "object",
            "properties": {
              "show": {
                "type": "boolean",
                "description": "Shows or hides the Quick Filter bar.",
                "optional": true
              },
              "unread": {
                "type": "boolean",
                "description": "Shows only unread messages.",
                "optional": true
              },
              "flagged": {
                "type": "boolean",
                "description": "Shows only flagged messages.",
                "optional": true
              },
              "contact": {
                "type": "boolean",
                "description": "Shows only messages from people in the address book.",
                "optional": true
              },
              "tags": {
                "optional": true,
                "choices": [
                  {
                    "type": "boolean"
                  },
                  {
                    "$ref": "messages.TagsDetail"
                  }
                ],
                "description": "Shows only messages with tags on them."
              },
              "attachment": {
                "type": "boolean",
                "description": "Shows only messages with attachments.",
                "optional": true
              },
              "text": {
                "$ref": "QuickFilterTextDetail",
                "description": "Shows only messages matching the supplied text.",
                "optional": true
              }
            }
          }
        ]
      }
    ],
    "events": [
      {
        "name": "onDisplayedFolderChanged",
        "type": "function",
        "description": "Fired when the displayed folder changes in any mail tab.",
        "permissions": ["accountsRead"],
        "parameters": []
      },
      {
        "name": "onSelectedMessagesChanged",
        "type": "function",
        "description": "Fired when the selected messages change in any mail tab.",
        "permissions": ["messagesRead"],
        "parameters": []
      }
    ]
  }
]