# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# def YesNo(b):
#   if b:
#     return xlt("Yes")
#   else:
#     return xlt("No")


import adm
from wh import xlt, YesNo
from _imap import ImapServer

  
  class Dlg(adm.ServerPropertyDialog):
    def __init__(self, parentWin, node):
      adm.PropertyDialog.__init__(self, parentWin, node, None)
      self['Security'].Append( { ' ': xlt("No security"), 'TLS-req': xlt("TLS required"), 'TLS-pref': xlt("TLS if available"), 'SSL': xlt("SSL") } )
      self.Bind("HostName HostAddress Port User Password Autoconnect")
      self.Bind("Security", self.OnChangeSecurity)

    def OnChangeSecurity(self, evt):
      if self.security == "SSL":
        self.port=993
      else:
        self.port=143
      
      self.Check()

    def Go(self):
      if self.node:
        self.SetSettings(self.node.settings)
        self["HostName"].Disable()
      else:
        self.Security="TLS-req"
      self.OnCheck()

    def Check(self):
      ok=True
      if not self.node:
        ok=self.CheckValid(ok, self.Hostname, xlt("Host name cannot be empty"))
        ok=self.CheckValid(ok, not adm.config.existsServer(self, self.HostName), xlt("Host name already in use"))

# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# def YesNo(b):
#   if b:
#     return xlt("Yes")
#   else:
#     return xlt("No")


# Path: modImap/Server.py
import adm
from wh import xlt, YesNo
from _imap import ImapServer


  
  class Dlg(adm.ServerPropertyDialog):
    def __init__(self, parentWin, node):
      adm.PropertyDialog.__init__(self, parentWin, node, None)
      self['Security'].Append( { ' ': xlt("No security"), 'TLS-req': xlt("TLS required"), 'TLS-pref': xlt("TLS if available"), 'SSL': xlt("SSL") } )
      self.Bind("HostName HostAddress Port User Password Autoconnect")
      self.Bind("Security", self.OnChangeSecurity)

    def OnChangeSecurity(self, evt):
      if self.security == "SSL":
        self.port=993
      else:
        self.port=143
      
      self.Check()

    def Go(self):
      if self.node:
        self.SetSettings(self.node.settings)
        self["HostName"].Disable()
      else:
        self.Security="TLS-req"
      self.OnCheck()

    def Check(self):
      ok=True
      if not self.node:
        ok=self.CheckValid(ok, self.Hostname, xlt("Host name cannot be empty"))
        ok=self.CheckValid(ok, not adm.config.existsServer(self, self.HostName), xlt("Host name already in use"))

      ok=self.CheckValid(ok, self.HostAddress, xlt("Host address cannot be empty"))