~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
import errno
18
20
import os
19
21
import subprocess
20
22
import sys
21
23
import tempfile
22
 
import urllib
23
24
 
24
25
import bzrlib
25
26
from bzrlib import (
 
27
    config as _mod_config,
26
28
    email_message,
27
29
    errors,
28
30
    msgeditor,
110
112
        if body == '':
111
113
            raise errors.NoMessageSupplied()
112
114
        email_message.EmailMessage.send(self.config,
113
 
                                        self.config.username(),
 
115
                                        self.config.get('email'),
114
116
                                        to,
115
117
                                        subject,
116
118
                                        body,
310
312
            message_options['attachment'] = urlutils.local_path_to_url(
311
313
                attach_path)
312
314
        if body is not None:
313
 
            options_list = ['body=%s' % urllib.quote(self._encode_safe(body))]
 
315
            options_list = ['body=%s' % urlutils.quote(self._encode_safe(body))]
314
316
        else:
315
317
            options_list = []
316
318
        options_list.extend(["%s='%s'" % (k, v) for k, v in
352
354
        """See ExternalMailClient._get_compose_commandline"""
353
355
        compose_url = []
354
356
        if from_ is not None:
355
 
            compose_url.append('from=' + urllib.quote(from_))
 
357
            compose_url.append('from=' + urlutils.quote(from_))
356
358
        if subject is not None:
357
 
            # Don't use urllib.quote_plus because Claws doesn't seem
 
359
            # Don't use urlutils.quote_plus because Claws doesn't seem
358
360
            # to recognise spaces encoded as "+".
359
361
            compose_url.append(
360
 
                'subject=' + urllib.quote(self._encode_safe(subject)))
 
362
                'subject=' + urlutils.quote(self._encode_safe(subject)))
361
363
        if body is not None:
362
364
            compose_url.append(
363
 
                'body=' + urllib.quote(self._encode_safe(body)))
 
365
                'body=' + urlutils.quote(self._encode_safe(body)))
364
366
        # to must be supplied for the claws-mail --compose syntax to work.
365
367
        if to is None:
366
368
            raise errors.NoMailAddressSpecified()
377
379
                 extension, body=None, from_=None):
378
380
        """See ExternalMailClient._compose"""
379
381
        if from_ is None:
380
 
            from_ = self.config.get_user_option('email')
 
382
            from_ = self.config.get('email')
381
383
        super(Claws, self)._compose(prompt, to, subject, attach_path,
382
384
                                    mime_subtype, extension, body, from_)
383
385
 
616
618
        """See MailClient.compose"""
617
619
        try:
618
620
            return self._mail_client().compose(prompt, to, subject,
619
 
                                               attachment, mimie_subtype,
 
621
                                               attachment, mime_subtype,
620
622
                                               extension, basename, body)
621
623
        except errors.MailClientNotFound:
622
624
            return Editor(self.config).compose(prompt, to, subject,
623
 
                          attachment, mimie_subtype, extension, body)
 
625
                          attachment, mime_subtype, extension, body)
624
626
 
625
627
    def compose_merge_request(self, to, subject, directive, basename=None,
626
628
                              body=None):
635
637
                              help=DefaultMail.__doc__)
636
638
mail_client_registry.default_key = 'default'
637
639
 
638
 
 
 
640
opt_mail_client = _mod_config.RegistryOption('mail_client',
 
641
        mail_client_registry, help='E-mail client to use.', invalid='error')