home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / plugins / provider_aol / aol_sp.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  3.2 KB  |  87 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import logging
  5. log = logging.getLogger('aol_sp')
  6. import hooks
  7. import util.net as net
  8. import mail.smtp as smtp
  9. import services.service_provider as SP
  10.  
  11. class AOLServiceProvider(SP.EmailPasswordServiceProvider):
  12.     
  13.     def update_info(self, kwds):
  14.         super(AOLServiceProvider, self).update_info(kwds)
  15.         self.updatefreq = kwds.get('updatefreq', 300)
  16.  
  17.     
  18.     def get_options(self, type):
  19.         options = super(AOLServiceProvider, self).get_options(type)
  20.         if type == 'email':
  21.             email_address = options.get('email_address', None)
  22.             if email_address is not None:
  23.                 options['username'] = email_address
  24.             
  25.             username = options.get('username', options.get('name'))
  26.             if username is not None:
  27.                 username = ''.join(username.split()).lower()
  28.                 username = str(net.EmailAddress(username, 'aol.com'))
  29.                 options['name'] = options['username'] = username
  30.             
  31.         elif type == 'im':
  32.             email_address = options.get('username', options.get('name'))
  33.             pinfo = self.get_metainfo().info.provider_info
  34.             
  35.             try:
  36.                 email_addr_obj = net.EmailAddress(email_address, pinfo['default_domain'])
  37.                 username = email_addr_obj.name
  38.                 domain = email_addr_obj.domain
  39.             except ValueError:
  40.                 username = email_address
  41.                 domain = None
  42.  
  43.             domains = pinfo['equivalent_domains']
  44.             domains.append(pinfo['default_domain'])
  45.             if domain is None or domain in domains:
  46.                 options['username'] = options['name'] = username
  47.             else:
  48.                 options['username'] = options['name'] = email_address
  49.         
  50.         options['updatefreq'] = self.updatefreq
  51.         log.info('got options for type=%r: %r', type, options)
  52.         return options
  53.  
  54.     
  55.     def add_account_email(self, acct):
  56.         retval = super(AOLServiceProvider, self).add_account_email(acct = acct)
  57.         log.info("Changing %r's username from %r to %r", acct, acct.username, self.email_address)
  58.         acct.name = self.email_address
  59.         
  60.         try:
  61.             (pw, smtppw) = smtp.SMTPEmailAccount._unglue_pw(acct.password)
  62.         except ValueError:
  63.             pass
  64.  
  65.         self.password = pw
  66.         return retval
  67.  
  68.     
  69.     def add_account_im(self, acct):
  70.         retval = super(AOLServiceProvider, self).add_account_im(acct = acct)
  71.         options = self.get_options('im')
  72.         log.info("Changing %r's username from %r to %r", acct, acct.username, options['username'])
  73.         acct.name = options['username']
  74.         return retval
  75.  
  76.  
  77.  
  78. def validate_icq(info, MSP, is_new):
  79.     valid = hooks.first('digsby.services.validate', info, MSP, is_new, impl = 'digsby_service_editor', raise_hook_exceptions = True)
  80.     password = info.get('_real_password_')
  81.     if password is not None:
  82.         if len(password) > 8:
  83.             raise SP.AccountException(_('Password should be 8 characters or less.'), fatal = False)
  84.         len(password) > 8
  85.     
  86.  
  87.