예제 #1
0
    def _get_incom_conf(self, cr, uid, ids, name, args, context=None):
        """
        Return configuration
        """
        res = {}
        for fetchmail in self.browse(cr, uid, ids, context=context):
            global_section_name = 'incoming_mail'

            key_types = {'port': int,
                         'is_ssl': lambda a: bool(int(a)),
                         'attach': lambda a: bool(int(a)),
                         'original': lambda a: bool(int(a)),
                         }

            # default vals
            config_vals = {'port': 993,
                           'is_ssl': 0,
                           'attach': 0,
                           'original': 0,
                           }
            if serv_config.has_section(global_section_name):
                config_vals.update(serv_config.items(global_section_name))

            custom_section_name = '.'.join((global_section_name,
                                            fetchmail.name))
            if serv_config.has_section(custom_section_name):
                config_vals.update(serv_config.items(custom_section_name))

            for key, to_type in key_types.iteritems():
                if config_vals.get(key):
                    config_vals[key] = to_type(config_vals[key])
            res[fetchmail.id] = config_vals
        return res
    def _get_incom_conf(self, cr, uid, ids, name, args, context=None):
        """
        Return configuration
        """
        res = {}
        for fetchmail in self.browse(cr, uid, ids, context=context):
            global_section_name = 'incoming_mail'

            key_types = {'port': int,
                         'is_ssl': lambda a: bool(int(a)),
                         'attach': lambda a: bool(int(a)),
                         'original': lambda a: bool(int(a)),
                         }

            # default vals
            config_vals = {'port': 993,
                           'is_ssl': 0,
                           'attach': 0,
                           'original': 0,
                           }
            if serv_config.has_section(global_section_name):
                config_vals.update(serv_config.items(global_section_name))

            custom_section_name = '.'.join((global_section_name,
                                            fetchmail.name))
            if serv_config.has_section(custom_section_name):
                config_vals.update(serv_config.items(custom_section_name))

            for key, to_type in key_types.iteritems():
                if config_vals.get(key):
                    config_vals[key] = to_type(config_vals[key])
            res[fetchmail.id] = config_vals
        return res
예제 #3
0
    def _get_cleanup_conf(self):
        """
        Return configuration
        """
        for fetchmail in self:
            global_section_name = 'incoming_mail'

            # default vals
            config_vals = {
                'cleanup_days': False,
                'purge_days': False,
                'cleanup_folder': False
            }
            if serv_config.has_section(global_section_name):
                config_vals.update(serv_config.items(global_section_name))

            custom_section_name = '.'.join(
                (global_section_name, fetchmail.name))
            if serv_config.has_section(custom_section_name):
                config_vals.update(serv_config.items(custom_section_name))

            # convert string values to integer
            if config_vals['cleanup_days']:
                config_vals['cleanup_days'] = int(config_vals['cleanup_days'])
            if config_vals['purge_days']:
                config_vals['purge_days'] = int(config_vals['purge_days'])

            for field in ['cleanup_days', 'purge_days', 'cleanup_folder']:
                fetchmail[field] = config_vals[field]
예제 #4
0
 def _get_provider_conf(self):
     for sms_provider in self:
         global_section_name = 'sms_provider'
         # default vals
         config_vals = {}
         if serv_config.has_section(global_section_name):
             config_vals.update((serv_config.items(global_section_name)))
             custom_section_name = '.'.join((global_section_name,
                                             sms_provider.name
                                             ))
             if serv_config.has_section(custom_section_name):
                 config_vals.update(serv_config.items(custom_section_name))
                 if config_vals.get('url_service'):
                     sms_provider.url = config_vals['url_service']
                 if config_vals.get('sms_account'):
                     sms_provider.sms_account = config_vals['sms_account']
                 if config_vals.get('login'):
                     sms_provider.login_provider = config_vals['login']
                 if config_vals.get('password'):
                     sms_provider.password_provider = config_vals['password']
                 if config_vals.get('from'):
                     sms_provider.from_provider = config_vals['from']
    def _get_smtp_conf(self, cr, uid, ids, name, args, context=None):
        """
        Return configuration
        """
        res = {}
        for mail_server in self.browse(cr, uid, ids, context=context):
            global_section_name = 'outgoing_mail'

            # default vals
            config_vals = {'smtp_port': 587}
            if serv_config.has_section(global_section_name):
                config_vals.update((serv_config.items(global_section_name)))

            custom_section_name = '.'.join((global_section_name,
                                            mail_server.name))
            if serv_config.has_section(custom_section_name):
                config_vals.update(serv_config.items(custom_section_name))

            if config_vals.get('smtp_port'):
                config_vals['smtp_port'] = int(config_vals['smtp_port'])

            res[mail_server.id] = config_vals
        return res
예제 #6
0
    def _get_smtp_conf(self, cr, uid, ids, name, args, context=None):
        """
        Return configuration
        """
        res = {}
        for mail_server in self.browse(cr, uid, ids, context=context):
            global_section_name = 'outgoing_mail'

            # default vals
            config_vals = {'smtp_port': 587}
            if serv_config.has_section(global_section_name):
                config_vals.update((serv_config.items(global_section_name)))

            custom_section_name = '.'.join(
                (global_section_name, mail_server.name))
            if serv_config.has_section(custom_section_name):
                config_vals.update(serv_config.items(custom_section_name))

            if config_vals.get('smtp_port'):
                config_vals['smtp_port'] = int(config_vals['smtp_port'])

            res[mail_server.id] = config_vals
        return res
예제 #7
0
 def _get_receipt_environment_part(self, part):
     section_name = 'pos_environment_%s' % part
     if serv_config.has_section(section_name):
         return '\n'.join([x[1] for x in serv_config.items(section_name)])
예제 #8
0
    def _get_smtp_conf(self, cr, uid, ids, name, args, context=None):
        """
        Return configuration
        """
        res = {}
        for mail_server in self.browse(cr, uid, ids, context=context):
            global_section_name = 'outgoing_mail'

            # default vals
            config_vals = {'smtp_port': 587}
            if serv_config.has_section(global_section_name):
                config_vals.update((serv_config.items(global_section_name)))

            custom_section_name = '.'.join((global_section_name,
                                            mail_server.name))
            if serv_config.has_section(custom_section_name):
                config_vals.update(serv_config.items(custom_section_name))

            if config_vals.get('smtp_port'):
                config_vals['smtp_port'] = int(config_vals['smtp_port'])

            res[mail_server.id] = config_vals
        return res


        'smtp_host': fields.Function(
            _get_smtp_conf,
            string='SMTP Server',
            type="char",
            multi='outgoing_mail_config',
            states={'draft': [('readonly', True)]},
            help="Hostname or IP of SMTP server"),
        'smtp_port': fields.Function(
            _get_smtp_conf,
            string='SMTP Port',
            type="integer",
            multi='outgoing_mail_config',
            states={'draft': [('readonly', True)]},
            help="SMTP Port. Usually 465 for SSL, "
                 "and 25 or 587 for other cases.",
            size=5),
        'smtp_user': fields.Function(
            _get_smtp_conf,
            string='Username',
            type="char",
            multi='outgoing_mail_config',
            states={'draft': [('readonly', True)]},
            help="Optional username for SMTP authentication",
            size=64),
        'smtp_pass': fields.Function(
            _get_smtp_conf,
            string='Password',
            type="char",
            multi='outgoing_mail_config',
            states={'draft': [('readonly', True)]},
            help="Optional password for SMTP authentication",
            size=64),
        'smtp_encryption': fields.Function(
            _get_smtp_conf,
            string='smtp_encryption',
            type="selection",
            multi='outgoing_mail_config',
            selection=[('none', 'None'),
                       ('starttls', 'TLS (STARTTLS)'),
                       ('ssl', 'SSL/TLS')],
            states={'draft': [('readonly', True)]},
            help="Choose the connection encryption scheme:\n"
                 "- none: SMTP sessions are done in cleartext.\n"
                 "- starttls: TLS encryption is requested at start "
                 "of SMTP session (Recommended)\n"
                 "- ssl: SMTP sessions are encrypted with SSL/TLS "
                 "through a dedicated port (default: 465)")