Rev 4409: (warsaw) Add body and from address support to Claws mail client in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jun 4 22:05:48 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4409
revision-id: pqm at pqm.ubuntu.com-20090604210544-x6j63s03knqk7qfg
parent: pqm at pqm.ubuntu.com-20090604153442-l8uh9e64mkrri02f
parent: aaron at aaronbentley.com-20090604200730-nlabq9fbbsgifi6e
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-06-04 22:05:44 +0100
message:
(warsaw) Add body and from address support to Claws mail client
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/mail_client.py mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
------------------------------------------------------------
revno: 4401.2.4
revision-id: aaron at aaronbentley.com-20090604200730-nlabq9fbbsgifi6e
parent: barry at python.org-20090604195642-1scssnbhcv1xhs0a
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: claws
timestamp: Thu 2009-06-04 16:07:30 -0400
message:
Update NEWS
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 4401.2.3
revision-id: barry at python.org-20090604195642-1scssnbhcv1xhs0a
parent: barry at python.org-20090604192538-tac3fs21cihfvjqp
committer: Barry Warsaw <barry at python.org>
branch nick: claws
timestamp: Thu 2009-06-04 15:56:42 -0400
message:
Add test for including body text for Claws.
modified:
bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
------------------------------------------------------------
revno: 4401.2.2
revision-id: barry at python.org-20090604192538-tac3fs21cihfvjqp
parent: barry at python.org-20090603194052-odzlfgw06xrpfxdm
committer: Barry Warsaw <barry at python.org>
branch nick: claws
timestamp: Thu 2009-06-04 15:25:38 -0400
message:
Much simpler approach to support From: in Claws, after discussion with
abentley. This does not try to add the support to every mail client.
modified:
bzrlib/mail_client.py mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
------------------------------------------------------------
revno: 4401.2.1
revision-id: barry at python.org-20090603194052-odzlfgw06xrpfxdm
parent: pqm at pqm.ubuntu.com-20090603080435-2gbqwzvbx31zr7ok
committer: Barry Warsaw <barry at python.org>
branch nick: claws
timestamp: Wed 2009-06-03 15:40:52 -0400
message:
Make Claws mail client work, with bodies and setting the From field.
modified:
bzrlib/mail_client.py mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
=== modified file 'NEWS'
--- a/NEWS 2009-06-04 09:01:17 +0000
+++ b/NEWS 2009-06-04 21:05:44 +0000
@@ -20,6 +20,9 @@
New Features
************
+* mail_client=claws now supports --body (and message body hooks). Also uses
+ configured from address. (Barry Warsaw)
+
Improvements
************
=== modified file 'bzrlib/mail_client.py'
--- a/bzrlib/mail_client.py 2009-06-03 19:05:40 +0000
+++ b/bzrlib/mail_client.py 2009-06-04 21:05:44 +0000
@@ -155,7 +155,7 @@
extension, **kwargs)
def _compose(self, prompt, to, subject, attach_path, mime_subtype,
- extension, body=None):
+ extension, body=None, from_=None):
"""Invoke a mail client as a commandline process.
Overridden by MAPIClient.
@@ -166,6 +166,8 @@
"text", but the precise subtype can be specified here
:param extension: A file extension (including period) associated with
the attachment type.
+ :param body: Optional body text.
+ :param from_: Optional From: header.
"""
for name in self._get_client_commands():
cmdline = [self._encode_path(name, 'executable')]
@@ -173,6 +175,8 @@
kwargs = {'body': body}
else:
kwargs = {}
+ if from_ is not None:
+ kwargs['from_'] = from_
cmdline.extend(self._get_compose_commandline(to, subject,
attach_path,
**kwargs))
@@ -331,25 +335,45 @@
class Claws(ExternalMailClient):
"""Claws mail client."""
+ supports_body = True
+
_client_commands = ['claws-mail']
- def _get_compose_commandline(self, to, subject, attach_path):
+ def _get_compose_commandline(self, to, subject, attach_path, body=None,
+ from_=None):
"""See ExternalMailClient._get_compose_commandline"""
- compose_url = ['mailto:']
- if to is not None:
- compose_url.append(self._encode_safe(to))
- compose_url.append('?')
+ compose_url = []
+ if from_ is not None:
+ compose_url.append('from=' + urllib.quote(from_))
if subject is not None:
# Don't use urllib.quote_plus because Claws doesn't seem
# to recognise spaces encoded as "+".
compose_url.append(
- 'subject=%s' % urllib.quote(self._encode_safe(subject)))
+ 'subject=' + urllib.quote(self._encode_safe(subject)))
+ if body is not None:
+ compose_url.append(
+ 'body=' + urllib.quote(self._encode_safe(body)))
+ # to must be supplied for the claws-mail --compose syntax to work.
+ if to is None:
+ raise errors.NoMailAddressSpecified()
+ compose_url = 'mailto:%s?%s' % (
+ self._encode_safe(to), '&'.join(compose_url))
# Collect command-line options.
- message_options = ['--compose', ''.join(compose_url)]
+ message_options = ['--compose', compose_url]
if attach_path is not None:
message_options.extend(
['--attach', self._encode_path(attach_path, 'attachment')])
return message_options
+
+ def _compose(self, prompt, to, subject, attach_path, mime_subtype,
+ extension, body=None, from_=None):
+ """See ExternalMailClient._compose"""
+ if from_ is None:
+ from_ = self.config.get_user_option('email')
+ super(Claws, self)._compose(prompt, to, subject, attach_path,
+ mime_subtype, extension, body, from_)
+
+
mail_client_registry.register('claws', Claws,
help=Claws.__doc__)
=== modified file 'bzrlib/tests/test_mail_client.py'
--- a/bzrlib/tests/test_mail_client.py 2009-05-11 18:35:20 +0000
+++ b/bzrlib/tests/test_mail_client.py 2009-06-04 19:56:42 +0000
@@ -191,9 +191,10 @@
def test_commandline(self):
claws = mail_client.Claws(None)
commandline = claws._get_compose_commandline(
- None, None, 'file%')
+ 'jrandom at example.org', None, 'file%')
self.assertEqual(
- ['--compose', 'mailto:?', '--attach', 'file%'], commandline)
+ ['--compose', 'mailto:jrandom at example.org?', '--attach', 'file%'],
+ commandline)
commandline = claws._get_compose_commandline(
'jrandom at example.org', 'Hi there!', None)
self.assertEqual(
@@ -217,6 +218,30 @@
self.assertFalse(isinstance(item, unicode),
'Command-line item %r is unicode!' % item)
+ def test_with_from(self):
+ claws = mail_client.Claws(None)
+ cmdline = claws._get_compose_commandline(
+ u'jrandom at example.org', None, None, None, u'qrandom at example.com')
+ self.assertEqual(
+ ['--compose',
+ 'mailto:jrandom at example.org?from=qrandom%40example.com'],
+ cmdline)
+
+ def test_to_required(self):
+ claws = mail_client.Claws(None)
+ self.assertRaises(errors.NoMailAddressSpecified,
+ claws._get_compose_commandline,
+ None, None, 'file%')
+
+ def test_with_body(self):
+ claws = mail_client.Claws(None)
+ cmdline = claws._get_compose_commandline(
+ u'jrandom at example.org', None, None, 'This is some body text')
+ self.assertEqual(
+ ['--compose',
+ 'mailto:jrandom at example.org?body=This%20is%20some%20body%20text'],
+ cmdline)
+
class TestEditor(tests.TestCase):
More information about the bazaar-commits
mailing list