<?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://messenger/skin/accountManage.css" type="text/css"?>
<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
<?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
<?xml-stylesheet href="chrome://messenger/content/charsetList.css" type="text/css"?>

<!DOCTYPE page [
<!ENTITY % trashDTD SYSTEM "chrome://messenger/locale/am-server-top.dtd">
%trashDTD;
]>

<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      title="&serverSettings.label;"
      onload="parent.onPanelLoaded('am-server.xul');">

  <vbox flex="1" style="overflow: auto;">
    <script type="application/javascript" src="chrome://messenger/content/AccountManager.js"/>
    <script type="application/javascript" src="chrome://messenger/content/am-server.js"/>
    <script type="application/javascript" src="chrome://messenger/content/am-prefs.js"/>
    <script type="application/javascript" src="chrome://messenger/content/amUtils.js"/>
    <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>

    <label hidden="true" wsm_persist="true" id="server.type"/>
    <label hidden="true"
           wsm_persist="true"
           preftype="string"
           prefattribute="value"
           prefstring="mail.server.%serverkey%.storeContractID"
           genericattr="true"
           id="server.storeContractID"/>

    <dialogheader title="&serverSettings.label;"/>

    <grid>
      <columns>
        <column/>
        <column flex="1"/>
        <column/>
      </columns>
      <rows>
        <row align="center">
          <label value="&serverType.label;"/>
          <label id="servertype.verbose"/>
        </row>
        <row align="center">
          <hbox>
              <label value="&serverName.label;" accesskey="&serverName.accesskey;"
                     control="server.realHostName"/>
          </hbox>
          <hbox align="center">
              <label id="fixedServerName" collapsed="true" use="server.realHostName"/>
              <textbox wsm_persist="true"
                       size="20"
                       flex="1"
                       id="server.realHostName"
                       prefstring="mail.server.%serverkey%.realhostname"
                       class="uri-element"/>
          </hbox>
          <hbox align="center">
              <label hidefor="movemail" value="&port.label;"
                     accesskey="&port.accesskey;" control="server.port"/>
              <label id="fixedServerPort" hidefor="movemail"
                     collapsed="true" use="server.port"/>
              <textbox wsm_persist="true" size="3" id="server.port"
                       preftype="int" hidefor="movemail"
                       prefstring="mail.server.%serverkey%.port"
                       type="number" min="1" max="65535" increment="1"/>
              <label value="&serverPortDefault.label;" hidefor="movemail"/>
              <label id="defaultPort" hidefor="movemail"/>
          </hbox>
        </row>
        <row align="center">
          <hbox align="center" hidefor="nntp">
              <label value="&userName.label;"
                     accesskey="&userName.accesskey;"
                     control="server.realUsername"/>
          </hbox>
          <hbox align="center" hidefor="nntp">
              <label id="fixedUserName" collapsed="true" use="server.realUsername"/>
              <textbox wsm_persist="true"
                       size="20"
                       flex="1"
                       id="server.realUsername"
                       prefstring="mail.server.%serverkey%.realusername"/>
          </hbox>
        </row>
      </rows>
    </grid>

    <separator class="thin"/>
  
    <groupbox hidefor="movemail">
      <caption label="&securitySettings.label;"/>

      <grid flex="1">
        <columns>
          <column/>
          <column/>
        </columns>
        <rows>
          <row align="center">
            <label value="&connectionSecurity.label;"
                   accesskey="&connectionSecurity.accesskey;"
                   control="server.socketType"/>
            <menulist wsm_persist="true" id="server.socketType"
                      oncommand="secureSelect();">
              <menupopup id="server.socketTypePopup">
                <menuitem value="0" label="&connectionSecurityType-0.label;"/>
                <menuitem id="connectionSecurityType-1"
                          value="1" label="&connectionSecurityType-1.label;"
                          disabled="true"/>
                <menuitem value="2" label="&connectionSecurityType-2.label;"
                          hidefor="nntp"/>
                <menuitem value="3" label="&connectionSecurityType-3.label;"/>
              </menupopup>
            </menulist>
          </row>
          <row align="center" hidefor="nntp,movemail">
            <label value="&authMethod.label;"
                   accesskey="&authMethod.accesskey;"
                   control="server.authMethod"/>
            <!-- same in smtpEditOverlay.xul/js -->
            <menulist id="server.authMethod"
                      wsm_persist="true"
                      preftype="int" type="number"
                      prefstring="mail.server.%serverkey%.authMethod">
              <menupopup id="server.authMethodPopup">
                <menuitem id="authMethod-no" value="1"/>
                <menuitem id="authMethod-old" value="2"/>
                <menuitem id="authMethod-password-cleartext" value="3"/>
                <menuitem id="authMethod-password-encrypted" value="4"/>
                <menuitem id="authMethod-kerberos" value="5"/>
                <menuitem id="authMethod-ntlm" value="6"/>
                <menuitem id="authMethod-external" value="7"/>
                <menuitem id="authMethod-oauth2" value="10"/>
                <menuitem id="authMethod-anysecure" value="8"/>
                <menuitem id="authMethod-any" value="9"/>
              </menupopup>
            </menulist>
          </row>
        </rows>
      </grid>
    </groupbox>

    <groupbox>
      <caption label="&serverSettings.label;"/>
      <vbox align="start">
      <checkbox wsm_persist="true"
                id="server.loginAtStartUp" 
                label="&loginAtStartup.label;"
                accesskey="&loginAtStartup.accesskey;"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.login_at_startup"/>
    </vbox>
    <hbox align="center">
      <checkbox wsm_persist="true" id="server.doBiff" label="&biffStart.label;"
                accesskey="&biffStart.accesskey;"
                oncommand="onCheckItem('server.biffMinutes', [this.id]);"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.check_new_mail"/>
      <textbox wsm_persist="true" id="server.biffMinutes"
               type="number" size="3" min="1" increment="1"
               aria-labelledby="server.doBiff server.biffMinutes biffEnd"
               preftype="int"
               prefstring="mail.server.%serverkey%.check_time"/>
      <label id="biffEnd" control="server.biffMinutes" value="&biffEnd.label;"/>
    </hbox>
    <!-- Necessary for POP3 and Movemail (Bug 480945) -->
    <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=480945 -->
    <vbox align="start" hidefor="imap,nntp">
      <checkbox wsm_persist="true" id="server.downloadOnBiff"
                label="&downloadOnBiff.label;" prefattribute="value"
                accesskey="&downloadOnBiff.accesskey;"
                prefstring="mail.server.%serverkey%.download_on_biff"/>
    </vbox>
    <!-- POP3 -->
    <vbox align="start" hidefor="imap,nntp,movemail">
      <checkbox wsm_persist="true" id="pop3.headersOnly"
                label="&headersOnly.label;"
                accesskey="&headersOnly.accesskey;"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.headers_only"/>

      <checkbox wsm_persist="true" id="pop3.leaveMessagesOnServer"
                label="&leaveOnServer.label;" oncommand="setupMailOnServerUI();"
                accesskey="&leaveOnServer.accesskey;"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.leave_on_server"/>

      <hbox align="center">
        <checkbox wsm_persist="true" id="pop3.deleteByAgeFromServer" class="indent"
                  label="&deleteByAgeFromServer.label;" oncommand="setupAgeMsgOnServerUI();"
                  accesskey="&deleteByAgeFromServer.accesskey;"
                  prefattribute="value"
                  prefstring="mail.server.%serverkey%.delete_by_age_from_server"/>
        <textbox wsm_persist="true" id="pop3.numDaysToLeaveOnServer" size="3"
                 aria-labelledby="pop3.deleteByAgeFromServer pop3.numDaysToLeaveOnServer daysEnd"
                 preftype="int" type="number" min="1" increment="1"
                 prefstring="mail.server.%serverkey%.num_days_to_leave_on_server"/>
        <label id="daysEnd" control="pop3.numDaysToLeaveOnServer" value="&daysEnd.label;"/>
      </hbox>

      <checkbox wsm_persist="true" id="pop3.deleteMailLeftOnServer" class="indent"
                label="&deleteOnServer2.label;"
                accesskey="&deleteOnServer2.accesskey;"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.delete_mail_left_on_server"/>

    <!-- hidden elements for data transfer to and from advanced... dialog -->
    <hbox flex="1" hidefor="imap,nntp,movemail" hidden="true">
      <checkbox hidden="true" wsm_persist="true" id="pop3.deferGetNewMail"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.deferGetNewMail"/>
      <label hidden="true" wsm_persist="true" id="pop3.deferredToAccount"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.deferredToAccount"/>

    </hbox>
    </vbox>
    <!-- IMAP -->
    <label hidden="true" wsm_persist="true" id="imap.trashFolderName" 
                  prefattribute="value"
                  prefstring="mail.server.%serverkey%.trash_folder_name"/>

    <hbox align="center" hidefor="pop3,nntp,movemail">
      <label value="&deleteMessagePrefix.label;" align="left"
             control="imap.deleteModel"/>
    </hbox>
    <vbox>
      <hbox align="center"
            id="imap.deleteModel.box"
            hidefor="pop3,nntp,movemail"
            flex="1">
        <radiogroup id="imap.deleteModel"
                    wsm_persist="true"
                    oncommand="selectImapDeleteModel(this.value);"
                    prefstring="mail.server.%serverkey%.delete_model">
          <grid class="specialFolderPickerGrid">
            <columns>
              <column/>
              <column flex="1"/>
            </columns>
            <rows>
              <row align="center">
                <radio id="modelMoveToTrash"
                       value="1"
                       label="&modelMoveToTrash.label;"
                       accesskey="&modelMoveToTrash.accesskey;"/>
                <menulist id="msgTrashFolderPicker" flex="1"
                          class="folderMenuItem"
                          maxwidth="300" crop="center"
                          aria-labelledby="modelMoveToTrash"
                          displayformat="verbose">
                  <menupopup id="msgTrashFolderPopup"
                             type="folder"
                             mode="filing"
                             showFileHereLabel="true"
                             oncommand="folderPickerChange(event);"/>
                </menulist>
              </row>
              <row align="center">
                <radio id="modelMarkDeleted"
                       value="0"
                       label="&modelMarkDeleted.label;"
                       accesskey="&modelMarkDeleted.accesskey;"/>
              </row>
              <row align="center">
                <radio id="modelDeleteImmediately"
                       value="2"
                       label="&modelDeleteImmediately.label;"
                       accesskey="&modelDeleteImmediately.accesskey;"/>
              </row>
            </rows>
          </grid>
        </radiogroup>
      </hbox>
      <hbox pack="end">
        <!-- This button should have identical attributes to the
             server.popAdvancedButton except the hidefor attribute. -->
        <button label="&advancedButton.label;"
                accesskey="&advancedButton.accesskey;"
                oncommand="onAdvanced();"
                wsm_persist="true"
                id="server.imapAdvancedButton"
                prefstring="mail.server.%serverkey%.advanced.disable"
                hidefor="pop3,nntp,movemail"/>
      </hbox>
    </vbox>

    <!-- Advanced IMAP settings -->
    <hbox flex="1" hidefor="pop3,nntp,movemail" hidden="true">
      <checkbox hidden="true" wsm_persist="true" id="imap.dualUseFolders"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.dual_use_folders"/>
      <checkbox hidden="true" wsm_persist="true" id="imap.usingSubscription"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.using_subscription"/>
      <checkbox hidden="true" wsm_persist="true" id="imap.useIdle"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.use_idle"/>
      <label hidden="true" wsm_persist="true" id="imap.maximumConnectionsNumber"/>
      <label hidden="true" wsm_persist="true" id="imap.personalNamespace"/>
      <label hidden="true" wsm_persist="true" id="imap.publicNamespace"/>
      <label hidden="true" wsm_persist="true" id="imap.otherUsersNamespace"/>
      <label hidden="true" wsm_persist="true" id="imap.serverDirectory"/>
      <checkbox hidden="true" wsm_persist="true" id="imap.overrideNamespaces"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.override_namespaces"/>
    </hbox>

    <!-- NNTP -->
    <hbox hidefor="pop3,imap,movemail" align="center">
      <checkbox wsm_persist="true" id="nntp.notifyOn"
                label="&maxMessagesStart.label;"
                accesskey="&maxMessagesStart.accesskey;"
                oncommand="onCheckItem('nntp.maxArticles', [this.id]);"
                prefattribute="value"
                prefstring="mail.server.%serverkey%.notify.on"/>
      <textbox wsm_persist="true" id="nntp.maxArticles"
               type="number" size="4" min="1" increment="10"
               aria-labelledby="nntp.notifyOn nntp.maxArticles maxMessagesEnd"
               preftype="int"
               prefstring="mail.server.%serverkey%.max_articles"/>
      <label control="nntp.maxArticles" value="&maxMessagesEnd.label;" id="maxMessagesEnd"/>
    </hbox>
    <checkbox hidefor="pop3,imap,movemail" wsm_persist="true" id="nntp.pushAuth"
              label="&alwaysAuthenticate.label;"
              accesskey="&alwaysAuthenticate.accesskey;"
              prefattribute="value"
              prefstring="mail.server.%serverkey%.always_authenticate"/>

  <!-- take out for now - bug 45079
      <hbox flex="1" hidefor="pop3,imap,movemail">
        <groupbox>
           <caption class="header" label="&abbreviate.label;"/>
  
           <radiogroup wsm_persist="true" id="nntp.abbreviate">
             <radio wsm_persist="true" value="true"
                    label="&abbreviateOn.label;"/>
             <radio wsm_persist="true" value="false" 
                    label="&abbreviateOff.label;"/>
           </radiogroup>
        </groupbox>
      </hbox>
  -->

    </groupbox>

    <groupbox>
      <caption label="&messageStorage.label;"/>

      <hbox align="end">
        <vbox align="start" flex="1" id="exitHandlingBox=">
          <checkbox hidefor="pop3,nntp,movemail"
                    wsm_persist="true"
                    id="imap.cleanupInboxOnExit"
                    label="&expungeOnExit.label;"
                    accesskey="&expungeOnExit.accesskey;"
                    prefattribute="value"
                    prefstring="mail.server.%serverkey%.cleanup_inbox_on_exit"/>
          <checkbox hidefor="nntp"
                    wsm_persist="true"
                    id="server.emptyTrashOnExit"
                    label="&emptyTrashOnExit.label;"
                    accesskey="&emptyTrashOnExit.accesskey;"
                    prefattribute="value"
                    prefstring="mail.server.%serverkey%.empty_trash_on_exit"/>
        </vbox>
        <button label="&advancedButton.label;"
                accesskey="&advancedButton.accesskey;"
                oncommand="onAdvanced();"
                wsm_persist="true"
                id="server.popAdvancedButton"
                prefstring="mail.server.%serverkey%.advanced.disable"
                hidefor="imap,nntp,movemail"/>
      </hbox>
      <hbox align="center">
        <label value="&storeType.label;"
               accesskey="&storeType.accesskey;"
               control="server.storeTypeMenulist"/>
        <menulist id="server.storeTypeMenulist">
          <menupopup id="server.storeTypeMenupopup">
            <menuitem id="server.mboxStore"
                      value="@mozilla.org/msgstore/berkeleystore;1"
                      label="&mboxStore.label;"/>
            <menuitem id="server.maildirStore"
                      value="@mozilla.org/msgstore/maildirstore;1"
                      label="&maildirStore.label;"/>
          </menupopup>
        </menulist>
      </hbox>

      <vbox hidefor="imap,pop3,movemail">
        <label value="&newsrcFilePath.label;" control="nntp.newsrcFilePath"/>
        <hbox align="center">
          <textbox readonly="true"
                   wsm_persist="true"
                   flex="1"
                   id="nntp.newsrcFilePath"
                   datatype="nsILocalFile"
                   prefstring="mail.server.%serverkey%.newsrc.file"
                   class="uri-element"/>
          <button id="browseForNewsrc"
                  label="&browseNewsrc.label;"
                  filepickertitle="&newsrcPicker.label;"
                  accesskey="&browseNewsrc.accesskey;"
                  oncommand="BrowseForNewsrc();"/>
        </hbox>
      </vbox>

      <separator class="thin"/>

      <vbox>
      <label value="&localPath.label;" control="server.localPath"/>
        <hbox align="center">
          <textbox readonly="true"
                   wsm_persist="true"
                   flex="1"
                   id="server.localPath"
                   datatype="nsILocalFile"
                   prefstring="mail.server.%serverkey%.directory"
                   class="uri-element"/>
          <button id="browseForLocalFolder"
                  label="&browseFolder.label;"
                  filepickertitle="&localFolderPicker.label;"
                  accesskey="&browseFolder.accesskey;"
                  oncommand="BrowseForLocalFolders();"/>
        </hbox>
      </vbox>

    </groupbox>

    <separator class="thin"/>

    <hbox hidefor="imap,pop3,movemail" align="center" valign="middle" iscontrolcontainer="true">
      <label value="&serverDefaultCharset.label;" control="nntp.charset"/>
      <menulist hidable="true"
                type="charset"
                hidefor="imap,pop3,movemail"
                wsm_persist="true"
                id="nntp.charset"
                preftype="string"
                prefstring="mail.server.%serverkey%.charset"/>
    </hbox>
  </vbox>
</page>
