def parse(self, data): stream = BytesIO(data) msgType = Uint16LE.unpack(stream) msgFlags = Uint16LE.unpack(stream) dataLen = Uint32LE.unpack(stream) payload = stream.read(dataLen) if msgFlags == ClipboardMessageFlags.CB_RESPONSE_OK and msgType == ClipboardMessageType.CB_FORMAT_DATA_RESPONSE: self.getFileName(payload) if msgType == ClipboardMessageType.CB_FORMAT_DATA_RESPONSE: clipboardPDU = self.parseFormatDataResponse(payload, msgFlags) elif msgType == ClipboardMessageType.CB_FORMAT_LIST: clipboardPDU = self.parseFormatList(payload, msgFlags) elif msgType == ClipboardMessageType.CB_FILECONTENTS_RESPONSE and ClipboardMessageFlags.CB_RESPONSE_OK: self.writeFileFromClipBoard(payload) clipboardPDU = ClipboardPDU(ClipboardMessageType(msgType), msgFlags, payload) else: clipboardPDU = ClipboardPDU(ClipboardMessageType(msgType), msgFlags, payload) return clipboardPDU
def parse(self, data): stream = BytesIO(data) msgType = Uint16LE.unpack(stream) msgFlags = Uint16LE.unpack(stream) dataLen = Uint32LE.unpack(stream) payload = stream.read(dataLen) if msgType in self.dispatch: clipboardPDU = self.dispatch[msgType](payload, msgFlags) else: clipboardPDU = ClipboardPDU(ClipboardMessageType(msgType), msgFlags, payload) return clipboardPDU
def parse(self, data): stream = BytesIO(data) msgType = Uint16LE.unpack(stream) msgFlags = Uint16LE.unpack(stream) dataLen = Uint32LE.unpack(stream) payload = stream.read(dataLen) if msgType == ClipboardMessageType.CB_FORMAT_DATA_RESPONSE: clipboardPDU = self.parseFormatDataResponse(payload, msgFlags) elif msgType == ClipboardMessageType.CB_FORMAT_LIST: clipboardPDU = self.parseFormatList(payload, msgFlags) else: clipboardPDU = ClipboardPDU(ClipboardMessageType(msgType), msgFlags, payload) return clipboardPDU