This commit is contained in:
ingvar1995 2016-06-17 15:19:38 +03:00
parent 0e86fd66df
commit 6a7a38ef02
4 changed files with 15 additions and 16 deletions

View File

@ -70,20 +70,22 @@ class IncomingCallWidget(widgets.CenteredWidget):
def __init__(self, fl): def __init__(self, fl):
self.stop = False self.stop = False
self.wf = wave.open(fl, 'rb') self.fl = fl
self.wf = wave.open(self.fl, 'rb')
self.p = pyaudio.PyAudio() self.p = pyaudio.PyAudio()
self.stream = self.p.open( self.stream = self.p.open(
format=self.p.get_format_from_width(self.wf.getsampwidth()), format=self.p.get_format_from_width(self.wf.getsampwidth()),
channels=self.wf.getnchannels(), channels=self.wf.getnchannels(),
rate=self.wf.getframerate(), rate=self.wf.getframerate(),
output=True output=True)
)
def play(self): def play(self):
while not self.stop:
data = self.wf.readframes(self.chunk) data = self.wf.readframes(self.chunk)
while data and not self.stop: while data and not self.stop:
self.stream.write(data) self.stream.write(data)
data = self.wf.readframes(self.chunk) data = self.wf.readframes(self.chunk)
self.wf = wave.open(self.fl, 'rb')
def close(self): def close(self):
self.stream.close() self.stream.close()

View File

@ -355,7 +355,7 @@ class FileTransferItem(QtGui.QListWidget):
self.pb.setValue(int(progress * 100)) self.pb.setValue(int(progress * 100))
if time + 1: if time + 1:
m, s = divmod(time, 60) m, s = divmod(time, 60)
self.time_left.setText('{0:02d}:{0:02d}'.format(m, s)) self.time_left.setText('{0:02d}:{1:02d}'.format(m, s))
if self.state != state: if self.state != state:
if state == TOX_FILE_TRANSFER_STATE['CANCELLED']: if state == TOX_FILE_TRANSFER_STATE['CANCELLED']:
self.setStyleSheet('QListWidget { border: 1px solid #B40404; }') self.setStyleSheet('QListWidget { border: 1px solid #B40404; }')

View File

@ -251,8 +251,6 @@ class Profile(contact.Contact, Singleton):
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
def send_files(self, friend_number): def send_files(self, friend_number):
# for key in filter(lambda x: x[0] == friend_number, self._file_transfers.keys()):
# self.resume_transfer(key[0], key[1], True)
friend = self.get_friend_by_number(friend_number) friend = self.get_friend_by_number(friend_number)
files = friend.get_unsent_files() files = friend.get_unsent_files()
try: try:
@ -277,11 +275,6 @@ class Profile(contact.Contact, Singleton):
self.friend_typing(friend_number, False) self.friend_typing(friend_number, False)
if friend_number in self._call: if friend_number in self._call:
self._call.finish_call(friend_number, True) self._call.finish_call(friend_number, True)
# for key in filter(lambda x: x[0] == friend_number, self._file_transfers.keys()):
# if type(self._file_transfers[key]) in (ReceiveAvatar, SendAvatar):
# self._file_transfers[key].cancelled()
# else:
# self._file_transfers[key].pause(False)
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# Typing notifications # Typing notifications
@ -454,8 +447,12 @@ class Profile(contact.Contact, Singleton):
continue continue
item = self.create_file_transfer_item(message, False) item = self.create_file_transfer_item(message, False)
if message.get_status() in ACTIVE_FILE_TRANSFERS: # active file transfer if message.get_status() in ACTIVE_FILE_TRANSFERS: # active file transfer
try:
ft = self._file_transfers[(message.get_friend_number(), message.get_file_number())] ft = self._file_transfers[(message.get_friend_number(), message.get_file_number())]
ft.set_state_changed_handler(item.update) ft.set_state_changed_handler(item.update)
ft.signal()
except:
print 'Incoming not started transfer - no info found'
elif message.get_type() == MESSAGE_TYPE['INLINE']: # inline elif message.get_type() == MESSAGE_TYPE['INLINE']: # inline
self.create_inline_item(message.get_data()) self.create_inline_item(message.get_data())
else: # info message else: # info message

Binary file not shown.