~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mail_client.py

  • Committer: John Arbash Meinel
  • Date: 2008-08-28 20:13:31 UTC
  • mfrom: (3658 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3688.
  • Revision ID: john@arbash-meinel.com-20080828201331-dqffxf54l2heokll
Merge bzr.dev 3658

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    msgeditor,
28
28
    osutils,
29
29
    urlutils,
 
30
    registry
30
31
    )
31
32
 
 
33
mail_client_registry = registry.Registry()
 
34
 
32
35
 
33
36
class MailClient(object):
34
37
    """A mail client that can send messages with attachements."""
109
112
                                        body,
110
113
                                        attachment,
111
114
                                        attachment_mime_subtype=mime_subtype)
 
115
mail_client_registry.register('editor', Editor,
 
116
                              help=Editor.__doc__)
112
117
 
113
118
 
114
119
class ExternalMailClient(MailClient):
222
227
                        sorted(message_options.iteritems())]
223
228
        return ['mailto:%s?%s' % (self._encode_safe(to or ''),
224
229
            '&'.join(options_list))]
 
230
mail_client_registry.register('evolution', Evolution,
 
231
                              help=Evolution.__doc__)
225
232
 
226
233
 
227
234
class Mutt(ExternalMailClient):
240
247
        if to is not None:
241
248
            message_options.append(self._encode_safe(to))
242
249
        return message_options
 
250
mail_client_registry.register('mutt', Mutt,
 
251
                              help=Mutt.__doc__)
243
252
 
244
253
 
245
254
class Thunderbird(ExternalMailClient):
253
262
    """
254
263
 
255
264
    _client_commands = ['thunderbird', 'mozilla-thunderbird', 'icedove',
256
 
        '/Applications/Mozilla/Thunderbird.app/Contents/MacOS/thunderbird-bin']
 
265
        '/Applications/Mozilla/Thunderbird.app/Contents/MacOS/thunderbird-bin',
 
266
        '/Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin']
257
267
 
258
268
    def _get_compose_commandline(self, to, subject, attach_path):
259
269
        """See ExternalMailClient._get_compose_commandline"""
268
278
        options_list = ["%s='%s'" % (k, v) for k, v in
269
279
                        sorted(message_options.iteritems())]
270
280
        return ['-compose', ','.join(options_list)]
 
281
mail_client_registry.register('thunderbird', Thunderbird,
 
282
                              help=Thunderbird.__doc__)
271
283
 
272
284
 
273
285
class KMail(ExternalMailClient):
286
298
        if to is not None:
287
299
            message_options.extend([self._encode_safe(to)])
288
300
        return message_options
 
301
mail_client_registry.register('kmail', KMail,
 
302
                              help=KMail.__doc__)
289
303
 
290
304
 
291
305
class XDGEmail(ExternalMailClient):
304
318
            commandline.extend(['--attach',
305
319
                self._encode_path(attach_path, 'attachment')])
306
320
        return commandline
 
321
mail_client_registry.register('xdg-email', XDGEmail,
 
322
                              help=XDGEmail.__doc__)
307
323
 
308
324
 
309
325
class EmacsMail(ExternalMailClient):
405
421
            commandline.append(rmform)
406
422
 
407
423
        return commandline
 
424
mail_client_registry.register('emacsclient', EmacsMail,
 
425
                              help=EmacsMail.__doc__)
408
426
 
409
427
 
410
428
class MAPIClient(ExternalMailClient):
423
441
            if e.code != simplemapi.MAPI_USER_ABORT:
424
442
                raise errors.MailClientNotFound(['MAPI supported mail client'
425
443
                                                 ' (error %d)' % (e.code,)])
 
444
mail_client_registry.register('mapi', MAPIClient,
 
445
                              help=MAPIClient.__doc__)
426
446
 
427
447
 
428
448
class DefaultMail(MailClient):
455
475
        except errors.MailClientNotFound:
456
476
            return Editor(self.config).compose_merge_request(to, subject,
457
477
                          directive, basename=basename)
 
478
mail_client_registry.register('default', DefaultMail,
 
479
                              help=DefaultMail.__doc__)
 
480
mail_client_registry.default_key = 'default'