<?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/.
-->

<?xml-stylesheet href="chrome://messenger/skin/" type="text/css"?>
<!-- ?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"? -->

<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
<!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
%enigMailDTD;
]>

<wizard id="enigmailSetupWizard"
        title="&enigmail.setupWiz.title;"
        onwizardnext="return onNext();"
        onwizardback="return onBack();"
        onload="onLoad();"
        onwizardcancel="return onCancel();"
        minheight="500px"
        minwidth="700px"
        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/enigmailCommon.js"/>
  <script type="application/x-javascript" src="chrome://enigmail/content/enigmailKeygen.js"/>
  <script type="application/x-javascript" src="chrome://enigmail/content/enigmailSetupWizard.js"/>

  <broadcasterset>
    <broadcaster id="bcKeyEnabled" properties=""/>
  </broadcasterset>


  <!-- Introduction Page -->
  <wizardpage id="pgIntro" pageid="pgIntro"
              next="pgWelcome"
              label="&enigmail.setupWiz.pgIntro.title;">
    <description>
      &enigmail.setupWiz.pgIntro.desc;
    </description>
    <separator/>

    <description control="startNow">
      &enigmail.setupWiz.pgIntro.desc2;
    </description>
    <separator/>

    <radiogroup id="startNow" value="1">
      <radio id="startNow_yes"
             label="&enigmail.setupWiz.pgIntro.startNow;"
             oncommand="onSetStartNow(1)"
             selected="true"
             value="1"/>
       <radio id="startNow_no"
             label="&enigmail.setupWiz.pgIntro.startLater;"
             oncommand="onSetStartNow(0)"
             value="0"/>
    </radiogroup>
  </wizardpage>

  <!-- Welcome Page -->
  <wizardpage id="pgWelcome" pageid="pgWelcome"
              next="pgInstallGnuPG"
              label="&enigmail.setupWiz.pgWelcome.title;"
              onpageshow="onPageShow(); wizardSetFocus()">
    <description control="selectMode">
      &enigmail.setupWiz.pgWelcome.manualOrAuto;
    </description>
    <separator/>

    <radiogroup id="selectMode" value="1">
      <radio id="selectMode_beginner"
             label="&enigmail.setupWiz.pgWelcome.beginnersMode;"
             selected="true"
             oncommand="onSetSelectMode('beginner')"
             value="1"/>
       <radio id="selectMode_advanced"
             label="&enigmail.setupWiz.pgWelcome.advancedMode;"
             oncommand="onSetSelectMode('advanced')"
             value="2"/>
      <radio id="selectMode_expert"
             label="&enigmail.setupWiz.pgWelcome.manualMode;"
             oncommand="onSetSelectMode('expert')"
             value="3"/>
      <separator/>
      <radio id="selectMode_import"
             label="&enigmail.setupWiz.pgWelcome.importSettings;"
             oncommand="onSetSelectMode('import')"
             value="4"/>
    </radiogroup>
  </wizardpage>


  <!-- Optional Install GnuPG Page -->
  <wizardpage id="pgInstallGnuPG" pageid="pgInstallGnuPG"
              next="pgSelectId"
              label="&enigmail.setupWiz.pgInstall.title;"
              description="&enigmail.setupWiz.pgInstall.title;"
              onpageshow="onPageShow(); onShowPgInstallGnuPG()">

    <description>
      &enigmail.setupWiz.pgInstall.desc;
    </description>

    <vbox id="installBox" collapsed="true">
      <description>
        &enigmail.setupWiz.pgInstall.installDesc1;
      </description>
      <hbox>
        <button id="btnInstallGnupg" label="&enigmail.setupWiz.pgInstall.installButton;" oncommand="installGnuPG()"/>
      </hbox>
      <separator/>
      <description>
        &enigmail.setupWiz.pgInstall.installDesc2;
      </description>
      <hbox>
        <button id="btnLocateGnuPG" label="&enigmail.setupWiz.pgInstall.locateButton;" oncommand="wizardLocateGpg()"/>
      </hbox>

    </vbox>

    <vbox id="findGpgBox" collapsed="true">
      <description>
        &enigmail.setupWiz.pgInstall.locateDesc;
      </description>
      <hbox>
        <button label="&enigmail.setupWiz.pgInstall.locateButton;" oncommand="wizardLocateGpg()"/>
      </hbox>
    </vbox>

    <vbox id="progressBox" collapsed="true">
      <label id="downloadLabel" value="&enigmail.setupWiz.pgInstall.downloadLabel;" control="progressBar"/>
      <progressmeter id="downloadProgress" mode="determined" value="0"/>
      <label value=""/>
      <label id="installLabel" value="&enigmail.setupWiz.pgInstall.installLabel;" collapsed="true"/>
      <progressmeter id="installProgress" mode="undetermined" collapsed="true"/>
      <label value=""/>
      <label id="installComplete" value="&enigmail.setupWiz.pgInstall.installDone;" collapsed="true"/>
    </vbox>

    <vbox id="gpgFoundBox" collapsed="true">
      <label value="&enigmail.setupWiz.pgInstall.gnupgFound;"/>
    </vbox>
  </wizardpage>


  <!-- Select Account IDs Page -->
  <wizardpage id="pgSelectId" pageid="pgSelectId" next="pgKeySel"
              label="&enigmail.setupWiz.pgSelectId.title;"
              description="&enigmail.setupWiz.pgSelectId.subtitle;"
              onpageshow="onPageShow();">
    <description control="activateId">
      &enigmail.setupWiz.pgSelectId.desc2;
    </description>

    <separator/>

    <radiogroup id="activateId" value="1">
      <radio id="activateId_all"
             label="&enigmail.setupWiz.pgSelectId.selectallIds;"
             selected="true"
             oncommand="disableIdSel(true)"
             value="1"/>
      <radio id="activateId_sel"
             label="&enigmail.setupWiz.pgSelectId.selectedIds;"
             oncommand="disableIdSel(false)"
             value="0"/>
    </radiogroup>
    <groupbox height="60px" width="200px">
      <vbox id="idSelection"/>
    </groupbox>

    <separator/>
    <description>
      &enigmail.setupWiz.pgSelectId.note;
    </description>
  </wizardpage>


  <!-- Select Keys Page -->
  <wizardpage id="pgKeySel" pageid="pgKeySel"
              next="pgUpload"
              onpageshow="onPageShow(); displayKeySel()"
              label="&enigmail.setupWiz.pgKeySel.title;"
              description="&enigmail.setupWiz.pgKeySel.subtitle;">
    <description id="createPgpKeyLabel">
      &enigmail.setupWiz.pgKeySel.desc2;
    </description>
    <radiogroup id="createPgpKey" value="0" aria-labelledby="createPgpKeyLabel">
      <radio id="createPgpKey_no"
             label="&enigmail.setupWiz.pgKeySel.useExistingKey;"
             oncommand="setUseKey()"
             selected="true"
             value="0"/>

      <tree id="uidSelection"
        hidecolumnpicker="false"
        style="height:200px"
        minwidth="450"
        seltype="single"
        onselect="onKeySelected();">

        <treecols>
          <treecol id="uidCol" primary="true"
                   flex="1"
                   ignoreincolumnpicker="true"
                   label="&enigmail.keyUserId.label;"/>
          <splitter class="tree-splitter"/>
          <treecol id="keyCol" style="width:90px"
                   label="&enigmail.keyId.label;"/>
          <splitter class="tree-splitter"/>
          <treecol id="expCol" style="width:70px"
                   label="&enigmail.created.label;"/>
        </treecols>

        <treechildren id="uidSelectionChildren"/>
      </tree>

      <separator/>

      <radio id="createNewPgpKey"
             label="&enigmail.setupWiz.pgKeySel.newKey;"
             oncommand="setNewKey()"
             value="1"/>

    </radiogroup>

  </wizardpage>


  <!-- Optional "No Key Found" Page -->
  <wizardpage id="pgNoKeyFound" pageid="pgNoKeyFound"
              next="pgKeyCreate"
              onpageshow="onPageShow(); disableNext(true)"
              label="&enigmail.setupWiz.pgNoKeyFound.title2;">

    <description id="noPgpKeyFoundLabel">
      &enigmail.setupWiz.pgNoKeyFound.desc2;
    </description>
    <radiogroup id="newPgpKey" value="0" aria-labelledby="noPgpKeyFoundLabel">

      <radio id="createNewPgpKey2"
             label="&enigmail.setupWiz.pgKeySel.newKey;"
             oncommand="setNewKey()"
             value="1"/>

      <radio id="importPgpKeys"
             label="&enigmail.setupWiz.pgNoKeyFound.importKey;"
             oncommand="setImportKeys()"
             value="2"/>
    </radiogroup>
  </wizardpage>


  <!-- Optional Create Key Page -->
  <wizardpage id="pgKeyCreate" pageid="pgKeyCreate"
              next="pgKeygen"
              onpageshow="onPageShow(); displayKeyCreate()"
              label="&enigmail.setupWiz.pgKeyCreate.title;"
              description="&enigmail.setupWiz.pgKeyCreate.subtitle;">
    <description>
      &enigmail.setupWiz.pgKeyCreate.descTwoKeys;
    </description>
    <description>
      &enigmail.setupWiz.pgKeyCreate.descPub;
    </description>
    <description id="keyCreateDescSec1">
      &enigmail.setupWiz.pgKeyCreate.descSec1;
    </description>
    <description id="keyCreateDescSec2" collapsed="true">
      &enigmail.setupWiz.pgKeyCreate.descSec2;
    </description>
    <separator/>
    <description>
     &enigmail.setupWiz.pgKeyCreate.descPass;
     &enigmail.setupWiz.pgKeyCreate.passContain;
    </description>
    <separator/>
    <vbox>
      <label class="label" value="&enigmail.keyUserId.label;:" control="userIdentity"/>
      <hbox flex="1">
        <menulist id="userIdentity" label="...">
          <menupopup id="userIdentityPopup"/>
        </menulist>
      </hbox>
    </vbox>
    <label id="userIdentityLabel" value="" collapsed="true"/>

    <vbox id="passphraseBox" align="start">
      <label control="passphrase" value="&enigmail.keyPassphrase.label;" />
      <hbox>
        <textbox id="passphrase" size="20" type="password" oninput="checkPassphraseQuality(this)" onblur="checkPassphraseOnChange(this)"/>
        <image id="passphraseErrorImg" hidden="true" class="enigmailErrorIcon"/>
      </hbox>
      <label id="passphraseError" hidden="true" value="&enigmail.setupWiz.pgKeyCreate.passError;" class="passphraseError"/>
      <label control="passphraseRepeat" value="&enigmail.setupWiz.pgKeyCreate.passRepeat;" />
      <hbox>
        <textbox id="passphraseRepeat" size="20" type="password" oninput="checkPassphrasesEqual()"/>
        <image id="passphraseErrorRepImg" hidden="true" class="enigmailErrorIcon"/>
      </hbox>
      <label id="passphraseErrorRepeat" hidden="true" value="&enigmail.setupWiz.pgKeyCreate.passErrorRepeat;" class="passphraseError"/>
      <description>&enigmail.setupWiz.pgKeyCreate.passQuality;</description>
      <progressmeter id="passphraseQuality" mode="determined" value="0"/>
    </vbox>

    <separator/>

    <hbox autostretch="never" align="center">
      <label tooltip="maxIdleMinutes.tooltip" id="maxIdleMinutesHeadLabel" value="&enigmail.maxIdleMinutesHead.label;"/>
      <textbox id="maxIdleMinutes"
               aria-labelledby="maxIdleMinutesHeadLabel maxIdleMinutes maxIdleMinutesTailLabel"
               type="number"
               min="0" max="1440"
               size="4"
               maxlength="4"
               pref="true"
               preftype="int"
               tooltip="maxIdleMinutes.tooltip"
               prefstring="extensions.enigmail.maxIdleMinutes"/>
      <description tooltip="maxIdleMinutes.tooltip" id="maxIdleMinutesTailLabel">&enigmail.maxIdleMinutesTail.label;</description>
    </hbox>
  </wizardpage>


  <!-- Optional Import Key Page -->
  <wizardpage id="pgKeyImport" pageid="pgKeyImport"
              next="pgKeySel"
              label="&enigmail.setupWiz.pgKeyImport.title;"
              onpageadvanced="return importKeyFiles()"
              description="&enigmail.setupWiz.pgKeyImport.subtitle;">
    <description>
      &enigmail.setupWiz.pgKeyImport.desc;
    </description>

    <grid>
      <columns>
        <column/>
        <column flex="1"/>
      </columns>

      <rows autostretch="never">
        <row>
          <hbox align="center">
            <label class="label" value="&enigmail.setupWiz.pgKeyImport.pubkeyFile;" id="publicKeysFileLbl"/>
          </hbox>
          <hbox align="center">
            <textbox id="publicKeysFile" size="30" aria-labelledby="publicKeysFileLbl" readonly="true"/>
            <button id="browsePubKeyFile"
                    label="&enigmail.browse.label;"
              oncommand="browseKeyFile('publicKeysFile', gPubkeyFile);"/>
          </hbox>
        </row>

        <row>
          <hbox align="center">
            <label class="label" value="&enigmail.setupWiz.pgKeyImport.seckeyFile;" id="privateKeysFileLbl"/>
          </hbox>
          <hbox align="center">
            <textbox id="privateKeysFile" size="30" aria-labelledby="privateKeysFileLbl" readonly="true"/>
            <button id="browseSecKeyFile"
                    label="&enigmail.browse.label;"
              oncommand="browseKeyFile('privateKeysFile', gSeckeyFile);"/>
          </hbox>
        </row>
      </rows>
    </grid>
  </wizardpage>


   <!-- Key Create Progress Page -->
  <wizardpage id="pgKeygen" pageid="pgKeygen"
              onpageshow="wizardGenKey()"
              next="pgRevocert"
              label="&enigmail.setupWiz.pgKeygen.title;"
              description="&enigmail.setupWiz.pgKeygen.subtitle;">
    <groupbox id="keygenConsoleBox" orient="vertical" flex="1">

      <description>&enigmail.keygen.desc;</description>
      <groupbox>
        <progressmeter id="keygenProgress" mode="determined" value="0"/>
      </groupbox>

      <separator/>
      <description id="keyGenCompleteMsg" hidden="true">
        <html:b>&enigmail.setupWiz.pgKeygen.keyGenComplete;</html:b>
      </description>
      <separator/>
    </groupbox>
  </wizardpage>

  <!-- Key Revocation certificate page -->
  <wizardpage id="pgRevocert" pageid="pgRevocert"
              onpageshow="wizardRevoCert()"
              next="pgUpload"
              label="&enigmail.setupWiz.pgRevocert.title;"
              description="&enigmail.setupWiz.pgRevocert.subtitle;">
    <groupbox id="keygenConsoleBox" orient="vertical" flex="1">

      <separator/>
      <vbox id="revCertBox">
        <description>
          &enigmail.setupWiz.pgRevocert.desc;
        </description>
        <hbox>
          <button label="&enigmail.setupWiz.pgRevocert.button;" oncommand="wizardCreateRevCert()"/>
        </hbox>
      </vbox>

    </groupbox>

  </wizardpage>

  <!-- Optional Key Upload Page -->
  <wizardpage id="pgUpload" pageid="pgUpload"
              onpageshow="wizardUpload()"
              next="pgComplete"
              label="&enigmail.setupWiz.pgUpload.title;"
              description="&enigmail.setupWiz.pgUpload.subtitle;">
    <groupbox id="keygenConsoleBox" orient="vertical" flex="1">
      <vbox>
        <caption label="&enigmail.setupWiz.pgUpload.title;"/>
        <description>&enigmail.keyUpload.desc;</description>
        <separator/>
        <deck id="keyUploadWksDeck">
          <hbox align="center">
            <label value="&enigmail.keyUpload.label;"/>
            <spacer width="5px"/>
            <progressmeter mode="undetermined"/>
          </hbox>
          <checkbox label="&enigmail.keyUpload.wks.label;" checked="true" id="keyUploadWks"/>
        </deck>
        <spacer height="5px"/>
        <checkbox label="&enigmail.keyUpload.sks.label;" checked="false" id="keyUploadSks"/>
        <description>&enigmail.keyUpload.sks.desc;</description>
        <separator/>
        <caption label="&enigmail.setupWiz.pgAttachAuto.title;"/>
        <description>&enigmail.attachAuto.desc;</description>
        <separator/>
        <deck id="keyUploadAKsDeck">
          <checkbox label="&enigmail.keyAttachAuto.label;" checked="false" id="keyAttachAuto" onchange="wizardSaveAutoAttach()"/>
        </deck>
      </vbox>
    </groupbox>

  </wizardpage>

  <wizardpage id="pgImportSettings" pageid="pgImportSettings"
              next="pgUpload"
              onpageshow="disableNext(true);"
              onpageadvanced="return importSettings();"
              label="&enigmail.setupWiz.pgImportSettings.title;">
    <vbox>
      <description>
        &enigmail.setupWiz.pgImportSettings.desc;
      </description>
      <separator/>
      <label class="label" value="&enigmail.setupWiz.pgImportSettings.fileName;" id="importFileLbl"/>
      <hbox align="center">
        <textbox id="importFile" size="30" aria-labelledby="importFileLbl" readonly="true"/>
        <button id="browseBackupFile"
                label="&enigmail.browse.label;"
          oncommand="browseBackupFile('importFile', gImportSettingsFile);"/>
      </hbox>

      <vbox id="importInProgress" hidden="true">
        <separator/>
        <description>
          &enigmail.setupWiz.pgImportSettings.importing;
        </description>

        <separator/>
        <hbox flex="0" id="spinningWheel">
          <spacer flex="1"/>
          <image class="enigmailWheel enigmailSpinning"/>
          <spacer flex="1"/>
        </hbox>
      </vbox>

      <description id="errorMessage" hidden="true">
        &enigmail.setupWiz.pgImportSettings.error;
      </description>
    </vbox>
  </wizardpage>

  <!-- End page Page -->
  <wizardpage id="pgComplete" pageid="pgComplete"
              onpageshow="applyWizardSettings()"
              label="&enigmail.setupWiz.pgComplete.title;">

    <vbox id="wkdKeysUploaded" hidden="true">
      <description>
        &enigmail.setupWiz.pgComplete.wkdUploaded;
      </description>
      <spacer height="20px"/>
    </vbox>
    <description>
      &enigmail.setupWiz.pgComplete.desc;
    </description>
    <separator/>
    <description>&enigmail.pgComplete.help.title;</description>
    <description onclick="EnigmailWindows.openEnigmailDocu(window);"
      class="enigmailLink">https://www.enigmail.net/documentation/</description>
  </wizardpage>


  <!-- Manual setup Page -->
  <wizardpage id="pgExpert" pageid="pgExpert"
              label="&enigmail.setupWiz.pgExpert.title;">
    <description>
      &enigmail.setupWiz.pgExpert.desc;
    </description>

    <grid>
      <columns>
        <column/>
        <column flex="1"/>
      </columns>

      <rows autostretch="never">
        <row>
          <hbox align="center">
            <label class="label" value="&enigmail.setupWiz.pgExpert.keyManager;"/>
          </hbox>
          <hbox align="center">
            <button label="&enigmail.keyManWindow.label;"
              oncommand="EnigmailWindows.openKeyManager();"/>
          </hbox>
        </row>

        <row>
          <hbox align="center">
            <label class="label" value="&enigmail.setupWiz.pgExpert.expertSettings;"/>
          </hbox>
          <hbox align="center">
            <button label="&enigmail.prefs.label;"
              oncommand="EnigmailWindows.openPrefWindow(window, true, null);"/>
          </hbox>
        </row>
      </rows>
    </grid>

  </wizardpage>

</wizard>
