<?xml version="1.0" encoding="UTF-8"?>
<!--
  TimeView for Outlook - Mail add-in.

  Rendered per environment by tools/build-manifest.mjs; the double-brace tokens
  come from config/environments.js. Do not edit the generated manifest.

  Why this is a separate file from office.template.xml: an add-in only manifest
  cannot span add-in types. Microsoft: "if you want your add-in to be
  installable on Outlook and on one of the other Office applications, you must
  create two add-ins, one with a Mail type manifest and the other with a Task
  pane or Content type manifest." See docs/decisions.md 2.3.
-->
<OfficeApp
  xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
  xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
  xsi:type="MailApp">

  <Id>9e613907-7259-4246-a691-fbfd63cb6490</Id>
  <!-- Office rejects a manifest version below 1.0, independent of the npm package version. -->
  <Version>1.0.0.0</Version>
  <ProviderName>TimeSolutions A/S</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="TimeView (Test)"/>
  <Description DefaultValue="File e-mail and attachments to a TimeView customer or task, and register time, without leaving Outlook."/>
  <IconUrl DefaultValue="https://office-add-in.timeviewtest.dk/assets/icon-80.png"/>
  <HighResolutionIconUrl DefaultValue="https://office-add-in.timeviewtest.dk/assets/icon-color-192.png"/>
  <SupportUrl DefaultValue="https://www.timesolutions.dk"/>

  <AppDomains>
    <AppDomain>https://office-add-in.timeviewtest.dk</AppDomain>
  </AppDomains>

  <Hosts>
    <Host Name="Mailbox"/>
  </Hosts>

  <!--
    The floor is deliberately low. Filing needs item.getAsFileAsync, which is
    Mailbox 1.8, but registering time against a mail needs only the subject and
    recipients. Microsoft's guidance is to require in the manifest only what the
    add-in must have "to be of any significant value at all" and to degrade the
    rest at runtime, so the higher requirement sets are feature-detected in code
    rather than gating installation. This is what keeps the add-in installable
    on perpetual Office and on mobile.
  -->
  <Requirements>
    <Sets DefaultMinVersion="1.5">
      <Set Name="Mailbox"/>
    </Sets>
  </Requirements>

  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://office-add-in.timeviewtest.dk/taskpane.html"/>
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
    <Form xsi:type="ItemEdit">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://office-add-in.timeviewtest.dk/taskpane.html"/>
      </DesktopSettings>
    </Form>
  </FormSettings>

  <!--
    ReadWriteMailbox is required, not chosen: both getSelectedItemsAsync and
    loadItemByIdAsync document "read/write mailbox" as their minimum permission
    level, and those are the two APIs multi-select filing is built on. It is the
    highest Outlook permission, so administrators will see it at consent.
  -->
  <Permissions>ReadWriteMailbox</Permissions>

  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/>
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit"/>
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Read"/>
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Edit"/>
  </Rule>

  <DisableEntityHighlighting>false</DisableEntityHighlighting>

  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
      <!--
        No <Requirements> element here on purpose. Microsoft warns that a
        requirement in VersionOverrides removes *every* add-in command wherever
        it is unsupported, not just the commands that need it. Gating on the
        1.15 that multi-select wants would strip the ribbon button from Outlook
        on Mac and from perpetual Office, which is the audience this whole
        manifest exists to reach.
      -->
      <Hosts>
        <Host xsi:type="MailHost">
          <!-- Event-based activation runs in its own lightweight runtime. -->
          <Runtimes>
            <!-- Used by Outlook on the web and Mac, and new Outlook on Windows. -->
            <Runtime resid="WebViewRuntime.Url">
              <!-- Used by classic Outlook on Windows, which needs a plain script. -->
              <Override type="javascript" resid="JSRuntime.Url"/>
            </Runtime>
          </Runtimes>

          <DesktopFormFactor>
            <FunctionFile resid="Commands.Url"/>

            <!-- Reading a message. -->
            <ExtensionPoint xsi:type="MessageReadCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="tvMsgReadGroup">
                  <Label resid="GroupLabel"/>
                  <Control xsi:type="Button" id="tvMsgReadOpenPane">
                    <Label resid="TaskpaneButton.Label"/>
                    <Supertip>
                      <Title resid="TaskpaneButton.Label"/>
                      <Description resid="TaskpaneButton.Tooltip"/>
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16"/>
                      <bt:Image size="32" resid="Icon.32x32"/>
                      <bt:Image size="80" resid="Icon.80x80"/>
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url"/>
                      <SupportsPinning>true</SupportsPinning>
                      <!-- Activates the pane on a multiple-message selection. -->
                      <SupportsMultiSelect>true</SupportsMultiSelect>
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>

            <!-- Composing a message. -->
            <ExtensionPoint xsi:type="MessageComposeCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="tvMsgComposeGroup">
                  <Label resid="GroupLabel"/>
                  <Control xsi:type="Button" id="tvMsgComposeOpenPane">
                    <Label resid="TaskpaneButton.Label"/>
                    <Supertip>
                      <Title resid="TaskpaneButton.Label"/>
                      <Description resid="TaskpaneButton.Tooltip"/>
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16"/>
                      <bt:Image size="32" resid="Icon.32x32"/>
                      <bt:Image size="80" resid="Icon.80x80"/>
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url"/>
                      <SupportsPinning>true</SupportsPinning>
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>

            <!-- Viewing an appointment, for time registration. -->
            <ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="tvApptGroup">
                  <Label resid="GroupLabel"/>
                  <Control xsi:type="Button" id="tvApptOpenPane">
                    <Label resid="TaskpaneButton.Label"/>
                    <Supertip>
                      <Title resid="TaskpaneButton.Label"/>
                      <Description resid="AppointmentButton.Tooltip"/>
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="Icon.16x16"/>
                      <bt:Image size="32" resid="Icon.32x32"/>
                      <bt:Image size="80" resid="Icon.80x80"/>
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="Taskpane.Url"/>
                      <SupportsPinning>true</SupportsPinning>
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>

            <!--
              Prompt the user at send so an outgoing mail can be correlated and
              filed from Sent Items. PromptUser rather than SoftBlock: failing to
              file is not a reason to stand between someone and their mail. See
              docs/decisions.md 5.2 and GAP-15.
            -->
            <ExtensionPoint xsi:type="LaunchEvent">
              <LaunchEvents>
                <LaunchEvent Type="OnMessageSend" FunctionName="onMessageSendHandler" SendMode="PromptUser"/>
              </LaunchEvents>
              <SourceLocation resid="WebViewRuntime.Url"/>
            </ExtensionPoint>
          </DesktopFormFactor>
        </Host>
      </Hosts>

      <Resources>
        <bt:Images>
          <bt:Image id="Icon.16x16" DefaultValue="https://office-add-in.timeviewtest.dk/assets/icon-16.png"/>
          <bt:Image id="Icon.32x32" DefaultValue="https://office-add-in.timeviewtest.dk/assets/icon-32.png"/>
          <bt:Image id="Icon.80x80" DefaultValue="https://office-add-in.timeviewtest.dk/assets/icon-80.png"/>
        </bt:Images>
        <bt:Urls>
          <bt:Url id="Taskpane.Url" DefaultValue="https://office-add-in.timeviewtest.dk/taskpane.html"/>
          <bt:Url id="Commands.Url" DefaultValue="https://office-add-in.timeviewtest.dk/commands.html"/>
          <bt:Url id="WebViewRuntime.Url" DefaultValue="https://office-add-in.timeviewtest.dk/commands.html"/>
          <bt:Url id="JSRuntime.Url" DefaultValue="https://office-add-in.timeviewtest.dk/commands.js"/>
        </bt:Urls>
        <bt:ShortStrings>
          <bt:String id="GroupLabel" DefaultValue="TimeView (Test)"/>
          <bt:String id="TaskpaneButton.Label" DefaultValue="TimeView (Test)"/>
        </bt:ShortStrings>
        <bt:LongStrings>
          <bt:String id="TaskpaneButton.Tooltip" DefaultValue="File this mail to a customer or task and register time."/>
          <bt:String id="AppointmentButton.Tooltip" DefaultValue="Register time for this appointment in TimeView."/>
        </bt:LongStrings>
      </Resources>
    </VersionOverrides>
  </VersionOverrides>
</OfficeApp>
