14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
60
61
attachment_mime_subtype=mime_subtype)
63
class Thunderbird(MailClient):
64
class Evolution(MailClient):
65
"""Evolution mail client."""
67
_client_commands = ['evolution']
69
def compose(self, prompt, to, subject, attachment, mime_subtype,
71
fd, pathname = tempfile.mkstemp(extension, 'bzr-mail-')
73
os.write(fd, attachment)
76
for name in self._client_commands:
78
cmdline.extend(self._get_compose_commandline(to, subject,
81
subprocess.call(cmdline)
83
if e.errno != errno.ENOENT:
88
raise errors.MailClientNotFound(self._client_commands)
90
def _get_compose_commandline(self, to, subject, attach_path):
92
if subject is not None:
93
message_options['subject'] = subject
94
if attach_path is not None:
95
message_options['attach'] = attach_path
96
options_list = ['%s=%s' % (k, urlutils.escape(v)) for (k, v) in
97
message_options.iteritems()]
98
return ['mailto:%s?%s' % (to or '', '&'.join(options_list))]
101
class Thunderbird(Evolution):
64
102
"""Mozilla Thunderbird (or Icedove)
66
104
Note that Thunderbird 1.5 is buggy and does not support setting
73
def compose(self, prompt, to, subject, attachment, mime_subtype,
75
fd, pathname = tempfile.mkstemp(extension, 'bzr-mail-')
77
os.write(fd, attachment)
80
cmdline = ['thunderbird']
81
cmdline.extend(self._get_compose_commandline(to, subject, pathname))
82
subprocess.call(cmdline)
111
_client_commands = ['thunderbird', 'mozilla-thunderbird', 'icedove']
84
113
def _get_compose_commandline(self, to, subject, attach_path):
85
114
message_options = {}
93
122
options_list = ["%s='%s'" % (k, v) for k, v in
94
123
sorted(message_options.iteritems())]
95
124
return ['-compose', ','.join(options_list)]
98
class Evolution(MailClient):
99
"""Evolution mail client."""
101
def compose(self, prompt, to, subject, attachment, mime_subtype,
103
fd, pathname = tempfile.mkstemp(extension, 'bzr-mail-')
105
os.write(fd, attachment)
108
cmdline = ['evolution']
109
cmdline.append(self._get_compose_commandline(to, subject, pathname))
110
subprocess.call(cmdline)
112
def _get_compose_commandline(self, to, subject, attach_path):
114
if subject is not None:
115
message_options['subject'] = subject
116
if attach_path is not None:
117
message_options['attach'] = attach_path
118
options_list = ['%s=%s' % (k, urlutils.escape(v)) for (k, v) in
119
message_options.iteritems()]
120
return 'mailto:%s?%s' % (to or '', '&'.join(options_list))