~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-05-21 14:06:43 UTC
  • mfrom: (4370.2.1 submit-format)
  • Revision ID: pqm@pqm.ubuntu.com-20090521140643-e0igtobdd3k832wb
(Jelmer) Add child_submit_format option used by 'bzr send'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
                      extension, **kwargs)
156
156
 
157
157
    def _compose(self, prompt, to, subject, attach_path, mime_subtype,
158
 
                 extension, body=None, from_=None):
 
158
                extension, body=None):
159
159
        """Invoke a mail client as a commandline process.
160
160
 
161
161
        Overridden by MAPIClient.
166
166
            "text", but the precise subtype can be specified here
167
167
        :param extension: A file extension (including period) associated with
168
168
            the attachment type.
169
 
        :param body: Optional body text.
170
 
        :param from_: Optional From: header.
171
169
        """
172
170
        for name in self._get_client_commands():
173
171
            cmdline = [self._encode_path(name, 'executable')]
175
173
                kwargs = {'body': body}
176
174
            else:
177
175
                kwargs = {}
178
 
            if from_ is not None:
179
 
                kwargs['from_'] = from_
180
176
            cmdline.extend(self._get_compose_commandline(to, subject,
181
177
                                                         attach_path,
182
178
                                                         **kwargs))
335
331
class Claws(ExternalMailClient):
336
332
    """Claws mail client."""
337
333
 
338
 
    supports_body = True
339
 
 
340
334
    _client_commands = ['claws-mail']
341
335
 
342
 
    def _get_compose_commandline(self, to, subject, attach_path, body=None,
343
 
                                 from_=None):
 
336
    def _get_compose_commandline(self, to, subject, attach_path):
344
337
        """See ExternalMailClient._get_compose_commandline"""
345
 
        compose_url = []
346
 
        if from_ is not None:
347
 
            compose_url.append('from=' + urllib.quote(from_))
 
338
        compose_url = ['mailto:']
 
339
        if to is not None:
 
340
            compose_url.append(self._encode_safe(to))
 
341
        compose_url.append('?')
348
342
        if subject is not None:
349
343
            # Don't use urllib.quote_plus because Claws doesn't seem
350
344
            # to recognise spaces encoded as "+".
351
345
            compose_url.append(
352
 
                'subject=' + urllib.quote(self._encode_safe(subject)))
353
 
        if body is not None:
354
 
            compose_url.append(
355
 
                'body=' + urllib.quote(self._encode_safe(body)))
356
 
        # to must be supplied for the claws-mail --compose syntax to work.
357
 
        if to is None:
358
 
            raise errors.NoMailAddressSpecified()
359
 
        compose_url = 'mailto:%s?%s' % (
360
 
            self._encode_safe(to), '&'.join(compose_url))
 
346
                'subject=%s' % urllib.quote(self._encode_safe(subject)))
361
347
        # Collect command-line options.
362
 
        message_options = ['--compose', compose_url]
 
348
        message_options = ['--compose', ''.join(compose_url)]
363
349
        if attach_path is not None:
364
350
            message_options.extend(
365
351
                ['--attach', self._encode_path(attach_path, 'attachment')])
366
352
        return message_options
367
 
 
368
 
    def _compose(self, prompt, to, subject, attach_path, mime_subtype,
369
 
                 extension, body=None, from_=None):
370
 
        """See ExternalMailClient._compose"""
371
 
        if from_ is None:
372
 
            from_ = self.config.get_user_option('email')
373
 
        super(Claws, self)._compose(prompt, to, subject, attach_path,
374
 
                                    mime_subtype, extension, body, from_)
375
 
 
376
 
 
377
353
mail_client_registry.register('claws', Claws,
378
354
                              help=Claws.__doc__)
379
355
 
530
506
    """Default mail handling.  Tries XDGEmail (or MAPIClient on Windows),
531
507
    falls back to Editor"""
532
508
 
533
 
    supports_body = True
534
 
 
535
509
    def _mail_client(self):
536
510
        """Determine the preferred mail client for this platform"""
537
511
        if osutils.supports_mapi():