def parse(self, chunk): HTTPMessage.parse(self, chunk) content_type = self.headers.get("Content-Type", "null") raw_body = self.body self.body = SLPMessageBody.build(content_type, raw_body)
def _handle_MSG(self, command): message = Message(None, command.payload) content_type = message.content_type if content_type[0] == 'text/x-msmsgsprofile': self._client.profile._server_property_changed("profile", command.payload) if self._protocol_version < 15: #self._send_command('SYN', ('0', '0')) raise NotImplementedError, "Missing Implementation, please fix" else: self._send_command("BLP", (self._client.profile.privacy,)) self._state = ProtocolState.SYNCHRONIZING self._client.address_book.sync() elif content_type[0] in \ ('text/x-msmsgsinitialemailnotification', \ 'text/x-msmsgsemailnotification'): self.emit("mail-received", message) elif content_type[0] in \ ('text/x-msmsgsinitialmdatanotification', \ 'text/x-msmsgsoimnotification'): if self._client.oim_box is not None: self._client.oim_box._state = \ OIM.OfflineMessagesBoxState.NOT_SYNCHRONIZED m = HTTPMessage() m.parse(message.body) mail_data = m.get_header('Mail-Data').strip() if mail_data == 'too-large': mail_data = None self._client.oim_box.sync(mail_data) elif content_type[0] == 'text/x-msmsgsactivemailnotification': pass
def parse(self, data): if len(data) == 0: return data.rstrip('\x00') HTTPMessage.parse(self, data)