~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: Lukáš Lalinsky
  • Date: 2007-08-09 22:30:26 UTC
  • mto: (2681.1.17 send-bundle)
  • mto: This revision was merged to the branch mainline in revision 2736.
  • Revision ID: lalinsky@gmail.com-20070809223026-c1xray4fmphhkr39
Support for Evolution mail client.

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
        options_list = ["%s='%s'" % (k, v) for k, v in
94
94
                        sorted(message_options.iteritems())]
95
95
        return ['-compose', ','.join(options_list)]
 
96
 
 
97
 
 
98
class Evolution(MailClient):
 
99
    """Evolution mail client."""
 
100
 
 
101
    def compose(self, prompt, to, subject, attachment, mime_subtype,
 
102
                extension):
 
103
        fd, pathname = tempfile.mkstemp(extension, 'bzr-mail-')
 
104
        try:
 
105
            os.write(fd, attachment)
 
106
        finally:
 
107
            os.close(fd)
 
108
        cmdline = ['evolution']
 
109
        cmdline.append(self._get_compose_commandline(to, subject, pathname))
 
110
        subprocess.call(cmdline)
 
111
 
 
112
    def _get_compose_commandline(self, to, subject, attach_path):
 
113
        message_options = {}
 
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))