inlines fix
This commit is contained in:
parent
42aa102d1d
commit
fb74ea4455
5 changed files with 11 additions and 10 deletions
|
@ -121,7 +121,7 @@ class SendTransfer(FileTransfer):
|
|||
super(SendTransfer, self).__init__(path, tox, friend_number, size)
|
||||
self.state = TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED']
|
||||
self._file_number = tox.file_send(friend_number, kind, size, file_id,
|
||||
basename(path) if path else '')
|
||||
bytes(basename(path), 'utf-8') if path else '')
|
||||
|
||||
def send_chunk(self, position, size):
|
||||
"""
|
||||
|
@ -167,7 +167,8 @@ class SendFromBuffer(FileTransfer):
|
|||
super(SendFromBuffer, self).__init__(None, tox, friend_number, len(data))
|
||||
self.state = TOX_FILE_TRANSFER_STATE['OUTGOING_NOT_STARTED']
|
||||
self._data = data
|
||||
self._file_number = tox.file_send(friend_number, TOX_FILE_KIND['DATA'], len(data), None, file_name)
|
||||
self._file_number = tox.file_send(friend_number, TOX_FILE_KIND['DATA'],
|
||||
len(data), None, bytes(file_name, 'utf-8'))
|
||||
|
||||
def get_data(self):
|
||||
return self._data
|
||||
|
@ -246,7 +247,7 @@ class ReceiveToBuffer(FileTransfer):
|
|||
|
||||
def __init__(self, tox, friend_number, size, file_number):
|
||||
super(ReceiveToBuffer, self).__init__(None, tox, friend_number, size, file_number)
|
||||
self._data = ''
|
||||
self._data = bytes()
|
||||
self._data_size = 0
|
||||
|
||||
def get_data(self):
|
||||
|
@ -257,12 +258,11 @@ class ReceiveToBuffer(FileTransfer):
|
|||
self._creation_time = time()
|
||||
if data is None:
|
||||
self.state = TOX_FILE_TRANSFER_STATE['FINISHED']
|
||||
self.signal()
|
||||
else:
|
||||
data = ''.join(chr(x) for x in data)
|
||||
data = bytes(data)
|
||||
l = len(data)
|
||||
if self._data_size < position:
|
||||
self._data += ('\0' * (position - self._data_size))
|
||||
self._data += (b'\0' * (position - self._data_size))
|
||||
self._data = self._data[:position] + data + self._data[position + l:]
|
||||
if position + l > self._data_size:
|
||||
self._data_size = position + l
|
||||
|
|
|
@ -430,7 +430,7 @@ class InlineImageItem(QtGui.QScrollArea):
|
|||
self.setWidget(self._image_label)
|
||||
self._image_label.setScaledContents(False)
|
||||
self._pixmap = QtGui.QPixmap()
|
||||
self._pixmap.loadFromData(QtCore.QByteArray(str(data)), "PNG")
|
||||
self._pixmap.loadFromData(data, 'PNG')
|
||||
self._max_size = width - 30
|
||||
self._resize_needed = not (self._pixmap.width() <= self._max_size)
|
||||
self._full_size = not self._resize_needed
|
||||
|
|
|
@ -109,7 +109,7 @@ class ScreenShotWindow(QtGui.QWidget):
|
|||
buffer = QtCore.QBuffer(byte_array)
|
||||
buffer.open(QtCore.QIODevice.WriteOnly)
|
||||
p.save(buffer, 'PNG')
|
||||
Profile.get_instance().send_screenshot(str(byte_array.data()))
|
||||
Profile.get_instance().send_screenshot(bytes(byte_array.data()))
|
||||
self.close()
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
|
|
|
@ -912,6 +912,7 @@ class Profile(contact.Contact, Singleton):
|
|||
self.send_inline(data, 'sticker.png')
|
||||
|
||||
def send_inline(self, data, file_name, friend_number=None, is_resend=False):
|
||||
print('Send inline:' + str(type(data)))
|
||||
friend_number = friend_number or self.get_active_number()
|
||||
friend = self.get_friend_by_number(friend_number)
|
||||
if friend.status is None and not is_resend:
|
||||
|
|
|
@ -1202,7 +1202,7 @@ class Tox(object):
|
|||
result = self.libtoxcore.tox_file_send(self._tox_pointer, c_uint32(friend_number), c_uint32(kind),
|
||||
c_uint64(file_size),
|
||||
string_to_bin(file_id),
|
||||
c_char_p(bytes(filename, 'utf-8')),
|
||||
c_char_p(filename),
|
||||
c_size_t(len(filename)), byref(tox_err_file_send))
|
||||
tox_err_file_send = tox_err_file_send.value
|
||||
if tox_err_file_send == TOX_ERR_FILE_SEND['OK']:
|
||||
|
|
Loading…
Reference in a new issue