diff options
author | Kali Kaneko <kali@leap.se> | 2015-02-19 00:58:52 -0400 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2015-02-20 17:35:29 -0300 |
commit | e5097fa8c3aa1ec9a09bca853dacf9c7930c7b8d (patch) | |
tree | c44f6743041e4ff29dddba83fd57fd6cabf5f55e /mail/src/leap | |
parent | 6218f04f08c90b6cd3b250d725e0cb55a81b505f (diff) |
fix broken multipart attachment rendering
Diffstat (limited to 'mail/src/leap')
-rw-r--r-- | mail/src/leap/mail/imap/mailbox.py | 7 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/service/imap-server.tac | 2 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/service/imap.py | 4 | ||||
-rw-r--r-- | mail/src/leap/mail/mail.py | 25 | ||||
-rw-r--r-- | mail/src/leap/mail/outgoing/service.py | 5 |
5 files changed, 30 insertions, 13 deletions
diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py index 2f33aa0..499226c 100644 --- a/mail/src/leap/mail/imap/mailbox.py +++ b/mail/src/leap/mail/imap/mailbox.py @@ -463,6 +463,13 @@ class IMAPMailbox(object): # switch to content-hash based index + local UID table. is_sequence = True if uid == 0 else False + + # XXX DEBUG --- if you attempt to use the `getmail` utility under + # imap/tests, it will choke until we implement sequence numbers. This + # is an easy hack meanwhile. + # is_sequence = False + # ----------------------------------------------------------------- + getmsg = self.collection.get_message_by_uid getimapmsg = self.get_imap_message diff --git a/mail/src/leap/mail/imap/service/imap-server.tac b/mail/src/leap/mail/imap/service/imap-server.tac index 49a29b1..2045757 100644 --- a/mail/src/leap/mail/imap/service/imap-server.tac +++ b/mail/src/leap/mail/imap/service/imap-server.tac @@ -124,8 +124,6 @@ km_kwargs = { } keymanager = KeyManager(*km_args, **km_kwargs) -# XXX Do we need to wait until keymanager is properly initialized? - ################################################## # Ok, let's expose the application object for the twistd application diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py index cc76e3a..3a6b7b8 100644 --- a/mail/src/leap/mail/imap/service/imap.py +++ b/mail/src/leap/mail/imap/service/imap.py @@ -136,7 +136,9 @@ def run_service(store, **kwargs): :returns: the port as returned by the reactor when starts listening, and the factory for the protocol. """ - leap_assert_type(store, Soledad) + leap_check(store, "store cannot be None") + # XXX this can also be a ProxiedObject, FIXME + # leap_assert_type(store, Soledad) port = kwargs.get('port', IMAP_PORT) userid = kwargs.get('userid', None) diff --git a/mail/src/leap/mail/mail.py b/mail/src/leap/mail/mail.py index b7b0981..47c8cba 100644 --- a/mail/src/leap/mail/mail.py +++ b/mail/src/leap/mail/mail.py @@ -63,7 +63,7 @@ class MessagePart(object): # TODO support arbitrarily nested multiparts (right now we only support # the trivial case) - def __init__(self, part_map, index=1, cdocs={}): + def __init__(self, part_map, cdocs={}): """ :param part_map: a dictionary mapping the subparts for this MessagePart (1-indexed). @@ -71,24 +71,29 @@ class MessagePart(object): The format for the part_map is as follows: - {u'1': {u'ctype': u'text/plain', + {u'ctype': u'text/plain', u'headers': [[u'Content-Type', u'text/plain; charset="utf-8"'], [u'Content-Transfer-Encoding', u'8bit']], u'multi': False, u'parts': 1, u'phash': u'02D82B29F6BB0C8612D1C', - u'size': 132}} + u'size': 132} - :param index: which index in the content-doc is this subpart - representing. :param cdocs: optional, a reference to the top-level dict of wrappers for content-docs (1-indexed). """ - # TODO: Pass only the cdoc wrapper for this part. self._pmap = part_map - self._index = index self._cdocs = cdocs + index = 1 + phash = part_map.get('phash', None) + if phash: + for i, cdoc_wrapper in self._cdocs.items(): + if cdoc_wrapper.phash == phash: + index = i + break + self._index = index + def get_size(self): return self._pmap['size'] @@ -121,7 +126,7 @@ class MessagePart(object): except KeyError: logger.debug("getSubpart for %s: KeyError" % (part,)) raise IndexError - return MessagePart(part_map, cdocs={1: self._cdocs.get(1, {})}) + return MessagePart(part_map, cdocs={1: self._cdocs.get(part + 1, {})}) def _get_payload(self, index): cdoc_wrapper = self._cdocs.get(index, None) @@ -245,8 +250,10 @@ class Message(object): except KeyError: raise IndexError + # FIXME instead of passing the index, let the MessagePart figure it out + # by getting the phash and iterating through the cdocs return MessagePart( - subpart_dict, index=part_index, cdocs=self._wrapper.cdocs) + subpart_dict, cdocs=self._wrapper.cdocs) # Custom methods. diff --git a/mail/src/leap/mail/outgoing/service.py b/mail/src/leap/mail/outgoing/service.py index c881830..f3c2320 100644 --- a/mail/src/leap/mail/outgoing/service.py +++ b/mail/src/leap/mail/outgoing/service.py @@ -91,7 +91,10 @@ class OutgoingMail: # assert params leap_assert_type(from_address, str) leap_assert('@' in from_address) - leap_assert_type(keymanager, KeyManager) + + # XXX it can be a zope.proxy too + # leap_assert_type(keymanager, KeyManager) + leap_assert_type(host, str) leap_assert(host != '') leap_assert_type(port, int) |