<?xml version="1.0"?>

<!--
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
-->

<!--
  This is the overlay that adds a menu and some PGP buttons
  to messenger mail reading window
-->

<!DOCTYPE window SYSTEM "chrome://enigmail/locale/enigmail.dtd" >

<overlay id="enigmailMessengerOverlay"
    xmlns:html="http://www.w3.org/1999/xhtml"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/x-javascript"  src="chrome://enigmail/content/enigmailMessengerOverlay.js"/>

  <link href="chrome://enigmail/skin/enigmail.css" rel="stylesheet" type="text/css"/>

  <broadcasterset id="otherActionsButtonBroadcasters">
    <broadcaster id="enigmailBcDisplayClass" class="headerValue"/>
    <broadcaster id="enigmail-pEp-bc" collapsed="true"/>
  </broadcasterset>

  <!-- Thunderbird secondary pane -->
  <popup id="appmenuSecondaryPane">
    <splitmenu id="menu_Enigmail2ndPane"
          label="&enigmail.label;"
          enigmaillabel="&enigmail.label;"
          peplabel="&enigmail.pEp.label;"
          accesskey="&enigmail.messengermenu.accesskey;"
          insertafter="appmenu_customize">
        <menupopup id="enigmail_2ndPanePopup" onpopupshowing="Enigmail.msg.setupMainMenu(this)"/>
    </splitmenu>
  </popup>

  <!-- Menu content for all apps -->
  <menubar id="mail-menubar">
    <menu id="menu_Enigmail"
          label="&enigmail.label;"
          enigmaillabel="&enigmail.label;"
          peplabel="&enigmail.pEp.label;"
          accesskey="&enigmail.messengermenu.accesskey;"
          insertbefore="tasksMenu">

      <menupopup id="menu_EnigmailPopup"
        onpopupshowing="Enigmail.msg.displayMainMenu(this)">

        <menuitem id="enigmail_wizard_basic"
             label="&enigmail.setupWiz.label;"
             advanced="reverse"
             enigmailtype="enigmail"
             accesskey="&enigmail.setupWiz.accesskey;"
             oncommand="EnigmailWindows.openSetupWizard(window, true);" />

        <menuitem id="enigmail_decryptverify"
             label="&enigmail.decryptverify.label;"
             accesskey="&enigmail.decryptverify.accesskey;"
             advanced="true"
             hidden="false"
             oncommand="Enigmail.msg.messageDecrypt(null, false);" />

        <menuseparator
             advanced="true"
             hidden="false"/>

        <menuitem id="enigmail_autoDecrypt"
             type="checkbox"
             checked="false"
             advanced="true"
             hidden="false"
             label="&enigmail.autoDecrypt.label;"
             accesskey="&enigmail.autoDecrypt.accesskey;"
             oncommand="Enigmail.msg.toggleAttribute('autoDecrypt');" />

        <menuseparator
             advanced="true"
             hidden="false"/>

        <menuitem id="enigmail_clearPassphrase"
             label="&enigmail.clearPassphrase.label;"
             accesskey="&enigmail.clearPassphrase.accesskey;"
             advanced="true"
             hidden="false"
             oncommand="EnigmailPassword.clearPassphrase(window);" />

        <menuitem id="enigmail_reload_msg"
             label="&enigmail.reload.label;"
             accesskey="&enigmail.reload.accesskey;"
             advanced="true"
             hidden="false"
             oncommand="Enigmail.msg.reloadCompleteMsg();" />

        <menu id="enigmail_sendersKeyMenu"
             label="&enigmail.sendersKeyMenu.label;"
             advanced="true"
             hidden="false"
             accesskey="&enigmail.sendersKeyMenu.accesskey;">

          <menupopup onpopupshowing="Enigmail.hdrView.updateSendersKeyMenu();">

            <menuitem id="enigmail_importpublickey"
                 label="&enigmail.importpublickey.label;"
                 accesskey="&enigmail.importpublickey.accesskey;"
                 disabled="true"
                 oncommand="Enigmail.msg.messageImport();" />

            <menuseparator/>

            <menuitem label="&enigmail.displayKeyProperties.label;"
                      id="enigmail_keyMgmtDispKeyDetails"
                      oncommand="Enigmail.hdrView.dispKeyDetails();"/>
            <menuitem label="&enigmail.signSenderKey.label;"
                      id="enigmail_keyMgmtSignKey"
                      oncommand="Enigmail.hdrView.signKey();"/>
            <menuitem label="&enigmail.trustSenderKey.label;"
                      id="enigmail_keyMgmtKeyTrust"
                      oncommand="Enigmail.hdrView.editKeyTrust();"/>
            <menuitem label="&enigmail.showPhoto.label;"
                      id="enigmail_keyMgmtShowPhoto"
                      oncommand="Enigmail.hdrView.showPhoto();"/>
          </menupopup>
        </menu>

        <menu
            id="enigmailDecryptToFolder"
            label="&enigmail.decryptToFolder.label;"
            accesskey="&enigmail.decryptToFolder.accesskey;"
            enigmailtype="enigmail"
            oncommand="Enigmail.msg.decryptToFolder(event.target._folder)">

          <menupopup id="enigmailDecryptfileHereMenu"
                     type="folder"
                     mode="filing"
                     showFileHereLabel="true"
                     showRecent="true"
                     recentLabel="&enigmail.recent.label;"
                     recentAccessKey="&enigmail.recent.accesskey;"/>
        </menu>

        <menuseparator enigmailtype="enigmail"/>

        <menuitem id="enigmail_keymgmt"
             label="&enigmail.keyManWindow.label;"
             accesskey="&enigmail.keyManWindow.accesskey;"
             oncommand="EnigmailWindows.openKeyManager(window);" />

        <menuitem label="&enigmail.adminSmartCard.label;"
                id="enigmail_smartCard"
                accesskey="&enigmail.adminSmartCard.accesskey;"
                advanced="true"
                hidden="false"
                oncommand="EnigmailWindows.openCardDetails();"/>

        <menuitem id="enigmail_RulesEditor"
            label="&enigmail.editRules.label;"
            accesskey="&enigmail.editRules.accesskey;"
            enigmailtype="enigmail"
            oncommand="EnigmailWindows.openRulesEditor();"/>

        <menuseparator enigmailtype="enigmail"/>

        <menuitem id="enigmail_prefs"
             label="&enigmail.prefs.label;"
             accesskey="&enigmail.prefs.accesskey;"
             oncommand="EnigmailWindows.openPrefWindow(window, true, null);" />

        <menuitem id="enigmail_help"
             label="&enigmail.help.label;"
             accesskey="&enigmail.help.accesskey;"
             enigmailtype="enigmail"
             oncommand="EnigmailWindows.openHelpWindow('messenger');" />

        <menu id="enigmail_debugMenu"
             label="&enigmail.debugMenu.label;"
             advanced="true"
             hidden="false"
             accesskey="&enigmail.debugMenu.accesskey;">

          <menupopup>
            <menuitem id="enigmail_console"
                 label="&enigmail.viewconsole.label;"
                 accesskey="&enigmail.viewconsole.accesskey;"
                 oncommand="EnigmailWindows.openConsoleWindow();" />

            <menuitem id="enigmail_debug_log"
                 label="&enigmail.viewlog.label;"
                 accesskey="&enigmail.viewlog.accesskey;"
                 oncommand="EnigmailWindows.openDebugLog(window);" />
          </menupopup>
        </menu>

        <menuitem id="enigmail_wizard_advanced"
             label="&enigmail.setupWiz.label;"
             advanced="true"
             accesskey="&enigmail.setupWiz.accesskey;"
             oncommand="EnigmailWindows.openSetupWizard(window, true);" />

        <menuitem id="enigmail_about"
             label="&enigmail.about.label;"
             accesskey="&enigmail.about.accesskey;"
             enigmailtype="enigmail"
             oncommand="EnigmailWindows.openAboutWindow();" />

      </menupopup>
    </menu>
  </menubar>

  <!-- menuitem in folder list context menu to decrypt message -->
  <menupopup id="mailContext">
    <menu
        id="enigmailContext-decryptToFolder"
        noinsertafter="mailContext-copyMenu"
        label="&enigmail.decryptToFolder.label;"
        accesskey="&enigmail.decryptToFolder.accesskey;"
        oncommand="Enigmail.msg.decryptToFolder(event.target._folder)">
      <menupopup id="enigmailCtxDecrypt-fileHereMenu"
                 type="folder"
                 mode="filing"
                 showFileHereLabel="true"
                 showRecent="true"
                 recentLabel="&enigmail.recent.label;"
                 recentAccessKey="&enigmail.recent.accesskey;"/>
    </menu>
  </menupopup>

  <!-- the default set does not include the Enigmail decryption icon anymore -->

  <!-- enigmailHdrBox is defined in messengerOverlay-(tbird|sm).xul -->

  <vbox id="enigmailHdrBox">
    <hbox id="enigmailBox"
          class="expandedEnigmailBox"
          collapsed="true" align="center">

      <vbox>
        <spacer class="enigmailHeaderSpacer"/>
      </vbox>

      <hbox class="headerNameBox" align="start" id="enigmailStatusTextBox" pack="start">
        <image id="enigToggleHeaderView2"
               class="enigmailExpandViewButton" onclick="Enigmail.hdrView.toggleHeaderView();"
               state="false" persist="state class"/>
        <spacer flex="1"/>
        <label class="enigmailHeaderName"
              id="enigmailStatusHdr" flex="1"
              value="&enigmail.label;" control="enigmailStatusText"/>
      </hbox>

      <hbox flex="1" pack="start" class="headerValueBox">
        <vbox flex="1" pack="start">
          <hbox flex="1" align="center">
            <label flex="1" readonly="true"
                 id="enigmailStatusText" chromedir="ltr"
                 class="enigmailHeaderValue">...
            </label>
          </hbox>
          <textbox flex="1" readonly="true"
                 id="expandedEnigmailStatusText"
                 class="enigmailHeaderValue"
                 observes="enigmailStatusText"
                 chromedir="ltr"
                 collapsed="true" display="false" state="false"
                 persist="display" aria-labelledby="enigmailStatusHdr"/>
        </vbox>
        <vbox flex="0" pack="center">
          <button id="enigmail_importKey" pack="center"
                  label="&enigmail.importKey.label;"
                  hidden="true"
                  class="enigMsgHdrView-flat-button"
                  oncommand="Enigmail.msg.handleUnknownKey();"/>
        </vbox>
        <vbox flex="0" pack="center">
          <button id="enigmail_confirmKey" pack="center"
                  label="..."
                  hidden="true"
                  class="enigMsgHdrView-flat-button"
                  oncommand="Enigmail.msg.confirmKeyRequest();"/>
        </vbox>
        <vbox class="enigmailHeaderNameBox" flex="0" pack="center">
          <observes element="enigmailStatusText" attribute="class"/>
          <button id="enigmailStatusHdrDetails" pack="center"
                  label="&enigmail.detailsHdrButton.label;"
                  type="menu"
                  class="enigMsgHdrView-flat-button">
            <menupopup id="enigSecurityContext"
                   onpopupshowing="Enigmail.hdrView.dispSecurityContext();">
              <menuitem label="&enigmail.importpublickey.label;"
                        id="enigmail_importKeyunused"
                        hidden="true"
                        oncommand="Enigmail.msg.handleUnknownKey();"/>
              <menuitem label="&enigmail.reload.label;"
                        id="enigmail_reloadMessage"
                        disabled="true"
                        oncommand="Enigmail.msg.reloadCompleteMsg();"/>
              <menuitem label="&enigmail.pgpSecurityInfo.label;"
                        id="enigmail_pgpSecurityInfo"
                        oncommand="Enigmail.msg.viewOpenpgpInfo(null, false);"/>
              <menuitem label="&enigmail.copySecurityInfo.label;"
                        id="enigmail_copySecurityInfo"
                        oncommand="Enigmail.hdrView.copyStatusInfo();"/>
              <menuseparator/>
              <menuitem label="&enigmail.displayKeyProperties.label;"
                        id="enigmail_dispKeyDetails"
                        oncommand="Enigmail.hdrView.dispKeyDetails();"/>
              <menuitem label="&enigmail.showPhoto.label;"
                        id="enigmail_showPhoto"
                        oncommand="Enigmail.hdrView.showPhoto();"/>
              <menuitem label="&enigmail.signSenderKeyPopup.label;"
                        id="enigmail_signSenderKey"
                        oncommand="Enigmail.hdrView.signKey();"/>
              <menuitem label="&enigmail.trustSenderKeyPopup.label;"
                        id="enigmail_editSenderKeyTrust"
                        oncommand="Enigmail.hdrView.editKeyTrust();"/>
            </menupopup>
          </button>
        </vbox>
      </hbox>
    </hbox>

    <hbox id="enigmailRevealAttachments" hidden="true" class="enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureUnknown" flex="0" pack="center">
      <vbox flex="1" pack="start">
        <textbox flex="1" readonly="true" align="center" class="enigmailHeaderValue" chromedir="ltr"
          value="&enigmail.revealAttachmentsButton.label;"/>
      </vbox>
      <button class="enigMsgHdrView-flat-button"
              label="&enigmail.revealAttachments.button;"
              oncommand="Enigmail.msg.revealAttachments();"/>
    </hbox>

    <vbox id="enigmailBrokenExchangeBox"
        flex="0" class="enigmailHeaderNameBox enigmailHeaderBoxLabelSignatureUnknown"
        collapsed="true"
        pack="center">
      <hbox pack="center">
        <vbox flex="1" pack="start">
          <description class="enigmailHeaderValue">&enigmail.exchangeGarbage.desc;</description>
        </vbox>
        <vbox flex="0" pack="center">
          <button id="enigmailFixBrokenMessageButton"
                class="enigMsgHdrView-flat-button"
                label="&enigmail.exchangeGarbage.fixButton.label;"
                oncommand="Enigmail.msg.fixBuggyExchangeMail()"/>
          <label id="enigmailFixBrokenMessageProgress" value="&enigmail.exchangeGarbage.waitMessage;" collapsed="true"/>
        </vbox>
      </hbox>
    </vbox>
  </vbox>


  <!-- Thunderbird -->
  <popup id="attachmentItemContext" onpopupshowing="return Enigmail.hdrView.enigOnShowAttachmentContextMenu();">
    <menuseparator/>
    <menuitem id="enigmail_ctxImportKey"
      label="&enigmail.ctxImportKey.label;"
      accesskey="&enigmail.ctxImportKey.accesskey;"
      oncommand="Enigmail.msg.handleAttachmentSel('importKey');"/>
    <menuitem id="enigmail_ctxDecryptOpen"
      label="&enigmail.ctxDecryptOpen.label;"
      accesskey="&enigmail.ctxDecryptOpen.accesskey;"
      oncommand="Enigmail.msg.handleAttachmentSel('openAttachment');"/>
    <menuitem id="enigmail_ctxDecryptSave"
      label="&enigmail.ctxDecryptSave.label;"
      accesskey="&enigmail.ctxDecryptSave.accesskey;"
      oncommand="Enigmail.msg.handleAttachmentSel('saveAttachment');"/>
    <menuitem id="enigmail_ctxVerifyAtt"
      label="&enigmail.ctxVerifyAtt.label;"
      accesskey="&enigmail.ctxVerifyAtt.accesskey;"
      oncommand="Enigmail.msg.handleAttachmentSel('verifySig');"/>
  </popup>

  <!-- SeaMonkey -->
  <popup id="attachmentListContext">
    <menuseparator/>
    <menuitem id="enigmail_ctxImportKey_SM"
      label="&enigmail.ctxImportKey.label;"
      accesskey="&enigmail.ctxImportKey.accesskey;"
      oncommand="Enigmail.msg.handleAttachmentSel('importKey');"/>
    <menuitem id="enigmail_ctxDecryptOpen_SM"
      label="&enigmail.ctxDecryptOpen.label;"
      accesskey="&enigmail.ctxDecryptOpen.accesskey;"
      oncommand="Enigmail.msg.handleAttachmentSel('openAttachment');"/>
    <menuitem id="enigmail_ctxDecryptSave_SM"
      label="&enigmail.ctxDecryptSave.label;"
      accesskey="&enigmail.ctxDecryptSave.accesskey;"
      oncommand="Enigmail.msg.handleAttachmentSel('saveAttachment');"/>
    <menuitem id="enigmail_ctxVerifyAtt_SM"
      label="&enigmail.ctxVerifyAtt.label;"
      accesskey="&enigmail.ctxVerifyAtt.accesskey;"
      oncommand="Enigmail.msg.handleAttachmentSel('verifySig');"/>
  </popup>

  <hbox id="messagepanewrapper">
    <description id="enigmailMsgDisplay"
        insertafter="messagepane"
        minheight="1"
        class="enigmailMessagePane"
        flex="1"
        collapsed="true"/>
  </hbox>

  <hbox id="expandedHeadersBottomBox">
    <vbox id="enigmail-pEp-status" insertbefore="otherActionsBox">
      <spacer flex="1" maxheight="40"/>
      <image id="enigmail-pEp-icon"
        observes="enigmail-pEp-bc"
        tooltiptext="&enigmail.messeneger.pEpIcon.tootlip;"
        class="enigmailPepRating"
        style="width:48px; height:48px; margin-left:2px; margin-right:2px;"
        onclick="Enigmail.hdrView.pEpIconPopup();"/>
      <spacer flex="1"/>
    </vbox>
  </hbox>

  <statusbar id="status-bar">
    <hbox id="enigmail-status-bar"
          insertafter="totalMessageCount"
          app="mailnews">
      <statusbarpanel id="enigmail-encrypted-status"
        class="statusbarpanel-iconic"
        collapsed="true"/>
      <statusbarpanel id="enigmail-signed-status"
        class="statusbarpanel-iconic"
        collapsed="true"/>
    </hbox>
  </statusbar>
</overlay>
