VirtualMailManager/VirtualMailManager.py
changeset 9 e3d3dbeb5b84
parent 8 7e3ce56f49e6
child 12 44161dbb1518
equal deleted inserted replaced
8:7e3ce56f49e6 9:e3d3dbeb5b84
   190     def __getAccount(self, address, password=None):
   190     def __getAccount(self, address, password=None):
   191         address = self.__chkEmailAddress(address)
   191         address = self.__chkEmailAddress(address)
   192         self.__dbConnect()
   192         self.__dbConnect()
   193         if not password is None:
   193         if not password is None:
   194             password = self.__pwhash(password)
   194             password = self.__pwhash(password)
   195         return Account(self.__dbh, self.__Cfg.get('maildir', 'base'), address,
   195         return Account(self.__dbh, address, password)
   196                 password)
       
   197 
   196 
   198     def __getAlias(self, address, destination=None):
   197     def __getAlias(self, address, destination=None):
   199         address = self.__chkEmailAddress(address)
   198         address = self.__chkEmailAddress(address)
   200         if not destination is None:
   199         if not destination is None:
   201             if destination.count('@'):
   200             if destination.count('@'):
   202                 destination = self.__chkEmailAddress(destination)
   201                 destination = self.__chkEmailAddress(destination)
   203             else:
   202             else:
   204                 destination = self.__chkLocalpart(destination)
   203                 destination = self.__chkLocalpart(destination)
   205         self.__dbConnect()
   204         self.__dbConnect()
   206         return Alias(self.__dbh, address, self.__Cfg.get('maildir', 'base'),
   205         return Alias(self.__dbh, address, destination)
   207                 destination)
       
   208 
   206 
   209     def __getDomain(self, domainname, transport=None):
   207     def __getDomain(self, domainname, transport=None):
   210         domainname = self.__chkDomainname(domainname)
   208         domainname = self.__chkDomainname(domainname)
       
   209         if transport is None:
       
   210             transport = self.__Cfg.get('misc', 'transport')
   211         self.__dbConnect()
   211         self.__dbConnect()
   212         return Domain(self.__dbh, domainname,
   212         return Domain(self.__dbh, domainname,
   213                 self.__Cfg.get('maildir', 'base'), transport)
   213                 self.__Cfg.get('maildir', 'base'), transport)
   214 
   214 
   215     def __getDiskUsage(self, directory):
   215     def __getDiskUsage(self, directory):
   420 
   420 
   421     def user_info(self, emailaddress, diskusage=False):
   421     def user_info(self, emailaddress, diskusage=False):
   422         acc = self.__getAccount(emailaddress)
   422         acc = self.__getAccount(emailaddress)
   423         info = acc.getInfo()
   423         info = acc.getInfo()
   424         if self.__Cfg.getboolean('maildir', 'diskusage') or diskusage:
   424         if self.__Cfg.getboolean('maildir', 'diskusage') or diskusage:
   425             info['disk usage'] = self.__getDiskUsage('%(home)s/%(mail)s' % info)
   425             info['disk usage'] = self.__getDiskUsage('%(maildir)s' % info)
   426         return info
   426         return info
   427 
   427 
   428     def user_password(self, emailaddress, password):
   428     def user_password(self, emailaddress, password):
   429         acc = self.__getAccount(emailaddress)
   429         acc = self.__getAccount(emailaddress)
   430         acc.modify('password', self.__pwhash(password))
   430         acc.modify('password', self.__pwhash(password))