<?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 http://mozilla.org/MPL/2.0/. -->

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

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

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        id="autoconfigWizard"
        windowtype="mail:autoconfig"
        title="&autoconfigWizard.title;"
        onload="gEmailConfigWizard.onLoad();"
        onkeypress="gEmailConfigWizard.onKeyDown(event);"
        onclose="gEmailConfigWizard.onWizardShutdown();"
        onunload="gEmailConfigWizard.onWizardShutdown();"
        >

  <stringbundleset>
    <stringbundle id="bundle_brand"
          src="chrome://branding/locale/brand.properties"/>
    <stringbundle id="strings"
          src="chrome://messenger/locale/accountCreation.properties"/>
    <stringbundle id="utilstrings"
          src="chrome://messenger/locale/accountCreationUtil.properties"/>
    <stringbundle id="bundle_messenger"
          src="chrome://messenger/locale/messenger.properties"/>
  </stringbundleset>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/util.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/accountConfig.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/emailWizard.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/sanitizeDatatypes.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/fetchhttp.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/readFromXML.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/guessConfig.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/verifyConfig.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/fetchConfig.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/createInBackend.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountcreation/MyBadCertHandler.js"/>
  <script type="application/javascript"
          src="chrome://messenger/content/accountUtils.js" />

  <keyset id="mailKeys">
    <key keycode="VK_ESCAPE" oncommand="window.close();"/>
  </keyset>

  <panel id="insecureserver-cleartext-panel" class="popup-panel">
    <hbox>
      <image class="insecureLarry"/>
      <vbox flex="1">
        <description class="title">&insecureServer.tooltip.title;</description>
        <description class="details">
                                &insecureUnencrypted.description;</description>
      </vbox>
    </hbox>
  </panel>
  <panel id="insecureserver-selfsigned-panel" class="popup-panel">
    <hbox>
      <image class="insecureLarry"/>
      <vbox flex="1">
        <description class="title">&insecureServer.tooltip.title;</description>
        <description class="details">
                                 &insecureSelfSigned.description;</description>
      </vbox>
    </hbox>
  </panel>
  <panel id="secureserver-panel" class="popup-panel">
    <hbox>
      <image class="secureLarry"/>
      <vbox flex="1">
        <description class="title">&secureServer.description;</description>
      </vbox>
    </hbox>
  </panel>

  <tooltip id="insecureserver-cleartext">
    <hbox>
      <image class="insecureLarry"/>
      <vbox>
        <description class="title">&insecureServer.tooltip.title;</description>
        <description class="details">
                                 &insecureServer.tooltip.details;</description>
      </vbox>
    </hbox>
  </tooltip>
  <tooltip id="insecureserver-selfsigned">
    <hbox>
      <image class="insecureLarry"/>
      <vbox>
        <description class="title">&insecureServer.tooltip.title;</description>
        <description class="details">
                                 &insecureServer.tooltip.details;</description>
      </vbox>
    </hbox>
  </tooltip>
  <tooltip id="secureservertooltip">
    <hbox>
      <image class="secureLarry"/>
      <description class="title">&secureServer.description;</description>
    </hbox>
  </tooltip>
  <tooltip id="optional-password">
    <description>&password.text;</description>
  </tooltip>

  <spacer id="fullwidth"/>

  <vbox id="mastervbox" class="mastervbox" flex="1">
    <grid id="initialSettings">
      <columns>
        <column/>
        <column/>
        <column/>
      </columns>
      <rows>
        <row align="center">
          <label accesskey="&name.accesskey;"
                 class="autoconfigLabel"
                 value="&name.label;"
                 control="realname"/>
          <textbox id="realname"
                   class="padded"
                   placeholder="&name.placeholder;"
                   oninput="gEmailConfigWizard.onInputRealname();"
                   onblur="gEmailConfigWizard.onBlurRealname();"/>
          <hbox>
            <description id="nametext" class="initialDesc">&name.text;</description>
            <image id="nameerroricon"
                   hidden="true"
                   class="warningicon"/>
            <description id="nameerror" class="errordescription" hidden="true"/>
          </hbox>
        </row>
        <row align="center">
          <label accesskey="&email.accesskey;"
                 class="autoconfigLabel"
                 value="&email.label;"
                 control="email"/>
          <textbox id="email"
                   class="padded uri-element"
                   placeholder="&email.placeholder;"
                   oninput="gEmailConfigWizard.onInputEmail();"
                   onblur="gEmailConfigWizard.onBlurEmail();"/>
          <hbox>
            <image id="emailerroricon"
                   hidden="true"
                   class="warningicon"/>
            <description id="emailerror" class="errordescription" hidden="true"/>
          </hbox>
        </row>
        <row align="center">
          <!-- this starts out as text so the emptytext shows, but then
               changes to type=password once it's not empty -->
          <label accesskey="&password.accesskey;"
                 class="autoconfigLabel"
                 value="&password.label;"
                 control="password"
                 tooltip="optional-password"/>
          <textbox id="password"
                   class="padded"
                   placeholder="&password.placeholder;"
                   type="text"
                   oninput="gEmailConfigWizard.onInputPassword();"
                   onfocus="gEmailConfigWizard.onFocusPassword();"
                   onblur="gEmailConfigWizard.onBlurPassword();"/>
          <hbox>
            <image id="passworderroricon"
                   hidden="true"
                   class="warningicon"/>
            <description id="passworderror" class="errordescription" hidden="true"/>
          </hbox>
        </row>
        <row align="center" pack="start">
          <label class="autoconfigLabel"/>
          <checkbox id="remember_password"
                    label="&rememberPassword.label;"
                    accesskey="&rememberPassword.accesskey;"
                    checked="true"/>
        </row>
      </rows>
    </grid>
    <spacer flex="1" />

     <hbox id="status_area" flex="1">
      <vbox id="status_img_before" pack="start"/>
      <description id="status_msg">&#160;</description>
              <!-- Include 160 = nbsp, to make the element occupy the
                   full height, for at least one line. With a normal space,
                   it does not have sufficient height. -->
      <vbox id="status_img_after" pack="start"/>
    </hbox>

    <groupbox id="result_area" hidden="true">
      <radiogroup id="result_imappop" orient="horizontal">
        <radio id="result_select_imap" label="&imapLong.label;" value="1"
               oncommand="gEmailConfigWizard.onResultIMAPOrPOP3();"/>
        <radio id="result_select_pop3" label="&pop3Long.label;" value="2"
               oncommand="gEmailConfigWizard.onResultIMAPOrPOP3();"/>
      </radiogroup>
      <grid>
        <columns>
          <column/>
          <column flex="1"/>
        </columns>
        <rows>
          <row align="center">
            <label class="textbox-label" value="&incoming.label;"
                   control="result-incoming"/>
            <textbox id="result-incoming" disabled="true" flex="1"/>
          </row>
          <row align="center">
            <label class="textbox-label" value="&outgoing.label;"
                   control="result-outgoing"/>
            <textbox id="result-outgoing" disabled="true" flex="1"/>
          </row>
          <row align="center">
            <label class="textbox-label" value="&username.label;"
                   control="result-username"/>
            <textbox id="result-username" disabled="true" flex="1"/>
          </row>
        </rows>
      </grid>
    </groupbox>

    <groupbox id="manual-edit_area" hidden="true">
      <grid>
        <columns>
          <column/><!-- row label, e.g. "incoming" -->
          <column/><!-- protocol, e.g. "IMAP" -->
          <column flex="1"/><!-- hostname / username -->
          <column/><!-- port -->
          <column/><!-- SSL -->
          <column/><!-- auth method -->
        </columns>
        <rows>
          <row id="labels_row" align="center">
            <spacer/>
            <spacer/>
            <label value="&hostname.label;" class="columnHeader"/>
            <label value="&port.label;" class="columnHeader"/>
            <label value="&ssl.label;" class="columnHeader"/>
            <label value="&auth.label;" class="columnHeader"/>
          </row>
          <row id="incoming_server_area" align="center">
            <label class="textbox-label"
                   value="&incoming.label;"
                   control="incoming_hostname"/>
            <menulist id="incoming_protocol"
                      oncommand="gEmailConfigWizard.onChangedProtocolIncoming();"
                      sizetopopup="always">
              <menupopup>
                <menuitem label="&imap.label;" value="1"/>
                <menuitem label="&pop3.label;" value="2"/>
              </menupopup>
            </menulist>
            <textbox id="incoming_hostname"
                     oninput="gEmailConfigWizard.onInputHostname();"
                     class="host uri-element"/>
            <menulist id="incoming_port"
                      editable="true"
                      oninput="gEmailConfigWizard.onChangedPortIncoming();"
                      oncommand="gEmailConfigWizard.onChangedPortIncoming();"
                      class="port">
              <menupopup/>
            </menulist>
            <menulist id="incoming_ssl"
                      class="security"
                      oncommand="gEmailConfigWizard.onChangedSSLIncoming();"
                      sizetopopup="always">
              <menupopup>
                <!-- values defined in nsMsgSocketType -->
                <menuitem label="&autodetect.label;" value="0"/>
                <menuitem label="&noEncryption.label;" value="1"/>
                <menuitem label="&starttls.label;" value="3"/>
                <menuitem label="&sslTls.label;" value="2"/>
              </menupopup>
            </menulist>
            <menulist id="incoming_authMethod"
                      class="auth"
                      oncommand="gEmailConfigWizard.onChangedInAuth();"
                      sizetopopup="always">
              <menupopup>
                <menuitem label="&autodetect.label;" value="0"/>
                <!-- values defined in nsMsgAuthMethod -->
                <!-- labels set from messenger.properties
                     to avoid duplication -->
                <menuitem id="in-authMethod-password-cleartext" value="3"/>
                <menuitem id="in-authMethod-password-encrypted" value="4"/>
                <menuitem id="in-authMethod-kerberos" value="5"/>
                <menuitem id="in-authMethod-ntlm" value="6"/>
                <menuitem id="in-authMethod-oauth2" value="10" hidden="true"/>
              </menupopup>
            </menulist>
          </row>
          <row id="outgoing_server_area" align="center">
            <label class="textbox-label"
                   value="&outgoing.label;"
                   control="outgoing_hostname"/>
            <label id="outgoing_protocol"
                   value="&smtp.label;"/>
            <menulist id="outgoing_hostname"
                editable="true"
                sizetopopup="none"
                oninput="gEmailConfigWizard.onInputHostname();"
                oncommand="gEmailConfigWizard.onChangedOutgoingDropdown();"
                onpopupshowing="gEmailConfigWizard.onOpenOutgoingDropdown();"
                class="host uri-element">
              <menupopup id="outgoing_hostname_popup"/>
            </menulist>
            <menulist id="outgoing_port"
                      editable="true"
                      oninput="gEmailConfigWizard.onChangedPortOutgoing();"
                      oncommand="gEmailConfigWizard.onChangedPortOutgoing();"
                      class="port">
              <menupopup/>
            </menulist>
            <menulist id="outgoing_ssl"
                      class="security"
                      oncommand="gEmailConfigWizard.onChangedSSLOutgoing();"
                      sizetopopup="always">
              <menupopup>
                <!-- @see incoming -->
                <menuitem label="&autodetect.label;" value="0"/>
                <menuitem label="&noEncryption.label;" value="1"/>
                <menuitem label="&starttls.label;" value="3"/>
                <menuitem label="&sslTls.label;" value="2"/>
              </menupopup>
            </menulist>
            <menulist id="outgoing_authMethod"
                      class="auth"
                      oncommand="gEmailConfigWizard.onChangedOutAuth(this.selectedItem);"
                      sizetopopup="always">
              <menupopup>
                <menuitem label="&autodetect.label;" value="0"/>
                <!-- @see incoming -->
                <menuitem id="out-authMethod-no" value="1"/>
                <menuitem id="out-authMethod-password-cleartext" value="3"/>
                <menuitem id="out-authMethod-password-encrypted" value="4"/>
                <menuitem id="out-authMethod-kerberos" value="5"/>
                <menuitem id="out-authMethod-ntlm" value="6"/>
                <menuitem id="out-authMethod-oauth2" value="10" hidden="true"/>
              </menupopup>
            </menulist>
          </row>
          <row id="username_area" align="center">
            <label class="textbox-label"
                   value="&username.label;"/>
            <label class="columnHeader"
                   value="&incoming.label;"
                   control="incoming_username"/>
            <textbox id="incoming_username"
                     oninput="gEmailConfigWizard.onInputInUsername();"
                     class="username"/>
            <spacer/>
            <label class="columnHeader"
                   id="outgoing_label"
                   value="&outgoing.label;"
                   control="outgoing_username"/>
            <textbox id="outgoing_username"
                     oninput="gEmailConfigWizard.onInputOutUsername();"
                     class="username"/>
          </row>
        </rows>
      </grid>
    </groupbox>

    <spacer flex="1" />
    <hbox id="buttons_area">
      <hbox id="left_buttons_area" align="center" pack="start">
        <button id="provisioner_button"
                label="&switch-to-provisioner.label;"
                accesskey="&switch-to-provisioner.accesskey;"
                class="larger-button"
                oncommand="gEmailConfigWizard.onSwitchToProvisioner();"/>
        <button id="manual-edit_button"
                label="&manual-edit.label;"
                accesskey="&manual-edit.accesskey;"
                hidden="true"
                oncommand="gEmailConfigWizard.onManualEdit();"/>
        <button id="advanced-setup_button"
                label="&advancedSetup.label;"
                accesskey="&advancedSetup.accesskey;"
                disabled="true"
                hidden="true"
                oncommand="gEmailConfigWizard.onAdvancedSetup();"/>
      </hbox>
      <spacer flex="1"/>
      <hbox id="right_buttons_area" align="center" pack="end">
        <button id="stop_button"
                label="&stop.label;"
                accesskey="&stop.accesskey;"
                hidden="true"
                oncommand="gEmailConfigWizard.onStop();"/>
        <button id="cancel_button"
                label="&cancel.label;"
                accesskey="&cancel.accesskey;"
                oncommand="gEmailConfigWizard.onCancel();"/>
        <button id="half-manual-test_button"
                label="&half-manual-test.label;"
                accesskey="&half-manual-test.accesskey;"
                hidden="true"
                oncommand="gEmailConfigWizard.onHalfManualTest();"/>
        <button id="next_button"
                label="&continue.label;"
                accesskey="&continue.accesskey;"
                hidden="false"
                oncommand="gEmailConfigWizard.onNext();"/>
        <button id="create_button"
                label="&doneAccount.label;"
                accesskey="&doneAccount.accesskey;"
                class="important-button"
                hidden="true"
                oncommand="gEmailConfigWizard.onCreate();"/>
      </hbox>
    </hbox>
  </vbox>


  <vbox id="warningbox" hidden="true" flex="1">
    <hbox class="warning" flex="1">
      <vbox class="larrybox">
        <image id="insecure_larry" class="insecureLarry"/>
      </vbox>
      <vbox flex="1" class="warning_text">
        <label class="warning-heading">&warning.label;</label>
        <vbox id="incoming_box">
          <hbox>
            <label class="warning_settings" value="&incomingSettings.label;"/>
            <description id="warning_incoming"/>
          </hbox>
          <label id="incoming_technical"
                 class="technical_details"
                 value="&technicaldetails.label;"
                 onclick="gSecurityWarningDialog.toggleDetails('incoming');"/>
          <description id="incoming_details" collapsed="true"/>
        </vbox>
        <vbox id="outgoing_box">
          <hbox>
            <label class="warning_settings" value="&outgoingSettings.label;"/>
            <description id="warning_outgoing"/>
          </hbox>
          <label id="outgoing_technical"
                 class="technical_details"
                 value="&technicaldetails.label;"
                 onclick="gSecurityWarningDialog.toggleDetails('outgoing');"/>
          <description id="outgoing_details" collapsed="true"/>
        </vbox>
        <spacer flex="10"/>
        <description id="findoutmore">
            &contactYourProvider.description;</description>
        <spacer flex="100"/>
        <checkbox id="acknowledge_warning"
                  label="&confirmWarning.label;"
                  accesskey="&confirmWarning.accesskey;"
                  class="acknowledge_checkbox"
                  oncommand="gSecurityWarningDialog.toggleAcknowledge()"/>
        <hbox>
          <button id="getmeoutofhere"
                  label="&changeSettings.label;"
                  accesskey="&changeSettings.accesskey;"
                  oncommand="gSecurityWarningDialog.onCancel()"/>
          <spacer flex="1"/>
          <button id="iknow"
                  label="&doneAccount.label;"
                  accesskey="&doneAccount.accesskey;"
                  disabled="true"
                  oncommand="gSecurityWarningDialog.onOK()"/>
        </hbox>
      </vbox>
    </hbox>
  </vbox>
</window>
