Some rewriting in set_audio_state/set_video_state
This commit is contained in:
		
							parent
							
								
									bc90bc1157
								
							
						
					
					
						commit
						d495deaa02
					
				
					 1 changed files with 40 additions and 46 deletions
				
			
		| 
						 | 
					@ -1553,6 +1553,7 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
		self.update_toolbar()
 | 
							self.update_toolbar()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def update_video(self):
 | 
						def update_video(self):
 | 
				
			||||||
 | 
							#TODO: Share code with update_audio?
 | 
				
			||||||
		if self.video_state in (self.JINGLE_STATE_NOT_AVAILABLE,
 | 
							if self.video_state in (self.JINGLE_STATE_NOT_AVAILABLE,
 | 
				
			||||||
		self.JINGLE_STATE_AVAILABLE):
 | 
							self.JINGLE_STATE_AVAILABLE):
 | 
				
			||||||
			self._video_banner_image.hide()
 | 
								self._video_banner_image.hide()
 | 
				
			||||||
| 
						 | 
					@ -1588,34 +1589,31 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
				str += ', ' + _('reason: %s') % reason
 | 
									str += ', ' + _('reason: %s') % reason
 | 
				
			||||||
			self.print_conversation(str, 'info')
 | 
								self.print_conversation(str, 'info')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							states = {'not_available': self.JINGLE_STATE_NOT_AVAILABLE,
 | 
				
			||||||
 | 
								'available': self.JINGLE_STATE_AVAILABLE,
 | 
				
			||||||
 | 
								'connecting': self.JINGLE_STATE_CONNECTING,
 | 
				
			||||||
 | 
								'connection_received': self.JINGLE_STATE_CONNECTION_RECEIVED,
 | 
				
			||||||
 | 
								'connected': self.JINGLE_STATE_CONNECTED,
 | 
				
			||||||
 | 
								'stop': self.JINGLE_STATE_AVAILABLE,
 | 
				
			||||||
 | 
								'error': self.JINGLE_STATE_ERROR}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if state in states:
 | 
				
			||||||
 | 
								self.audio_state = states[state]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if state in ('not_available', 'available', 'stop'):
 | 
				
			||||||
 | 
								self.audio_sid = None
 | 
				
			||||||
 | 
							if state in ('connection_received', 'connecting'):
 | 
				
			||||||
 | 
								self.audio_sid = sid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if state in ('connecting', 'connected', 'connection_received'):
 | 
							if state in ('connecting', 'connected', 'connection_received'):
 | 
				
			||||||
			self._audio_button.set_active(True)
 | 
								self._audio_button.set_active(True)
 | 
				
			||||||
		elif state in ('not_available', 'stop'):
 | 
							elif state in ('not_available', 'stop'):
 | 
				
			||||||
 | 
								self._audio_button.set_active(False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# Destroy existing session with the user when he signs off
 | 
							# Destroy existing session with the user when he signs off
 | 
				
			||||||
		if state == 'not_available':
 | 
							if state == 'not_available':
 | 
				
			||||||
			gajim.connections[self.account].delete_jingle_session(
 | 
								gajim.connections[self.account].delete_jingle_session(
 | 
				
			||||||
				self.contact.get_full_jid(), self.audio_sid)
 | 
									self.contact.get_full_jid(), self.audio_sid)
 | 
				
			||||||
			self._audio_button.set_active(False)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if state == 'not_available':
 | 
					 | 
				
			||||||
			self.audio_state = self.JINGLE_STATE_NOT_AVAILABLE
 | 
					 | 
				
			||||||
			self.audio_sid = None
 | 
					 | 
				
			||||||
		elif state == 'available':
 | 
					 | 
				
			||||||
			self.audio_state = self.JINGLE_STATE_AVAILABLE
 | 
					 | 
				
			||||||
			self.audio_sid = None
 | 
					 | 
				
			||||||
		elif state == 'connecting':
 | 
					 | 
				
			||||||
			self.audio_state = self.JINGLE_STATE_CONNECTING
 | 
					 | 
				
			||||||
			self.audio_sid = sid
 | 
					 | 
				
			||||||
		elif state == 'connection_received':
 | 
					 | 
				
			||||||
			self.audio_state = self.JINGLE_STATE_CONNECTION_RECEIVED
 | 
					 | 
				
			||||||
			self.audio_sid = sid
 | 
					 | 
				
			||||||
		elif state == 'connected':
 | 
					 | 
				
			||||||
			self.audio_state = self.JINGLE_STATE_CONNECTED
 | 
					 | 
				
			||||||
		elif state == 'stop':
 | 
					 | 
				
			||||||
			self.audio_state = self.JINGLE_STATE_AVAILABLE
 | 
					 | 
				
			||||||
			self.audio_sid = None
 | 
					 | 
				
			||||||
		elif state == 'error':
 | 
					 | 
				
			||||||
			self.audio_state = self.JINGLE_STATE_ERROR
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		self.update_audio()
 | 
							self.update_audio()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1627,35 +1625,31 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
				str += ', ' + _('reason: %s') % reason
 | 
									str += ', ' + _('reason: %s') % reason
 | 
				
			||||||
			self.print_conversation(str, 'info')
 | 
								self.print_conversation(str, 'info')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							states = {'not_available': self.JINGLE_STATE_NOT_AVAILABLE,
 | 
				
			||||||
 | 
								'available': self.JINGLE_STATE_AVAILABLE,
 | 
				
			||||||
 | 
								'connecting': self.JINGLE_STATE_CONNECTING,
 | 
				
			||||||
 | 
								'connection_received': self.JINGLE_STATE_CONNECTION_RECEIVED,
 | 
				
			||||||
 | 
								'connected': self.JINGLE_STATE_CONNECTED,
 | 
				
			||||||
 | 
								'stop': self.JINGLE_STATE_AVAILABLE,
 | 
				
			||||||
 | 
								'error': self.JINGLE_STATE_ERROR}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if state in states:
 | 
				
			||||||
 | 
								self.video_state = states[state]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if state in ('not_available', 'available', 'stop'):
 | 
				
			||||||
 | 
								self.video_sid = None
 | 
				
			||||||
 | 
							if state in ('connection_received', 'connecting'):
 | 
				
			||||||
 | 
								self.video_sid = sid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if state in ('connecting', 'connected', 'connection_received'):
 | 
							if state in ('connecting', 'connected', 'connection_received'):
 | 
				
			||||||
			self._video_button.set_active(True)
 | 
								self._video_button.set_active(True)
 | 
				
			||||||
		elif state in ('not_available', 'stop'):
 | 
							elif state in ('not_available', 'stop'):
 | 
				
			||||||
 | 
								self._video_button.set_active(False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# Destroy existing session with the user when he signs off
 | 
							# Destroy existing session with the user when he signs off
 | 
				
			||||||
		if state == 'not_available':
 | 
							if state == 'not_available':
 | 
				
			||||||
			gajim.connections[self.account].delete_jingle_session(
 | 
								gajim.connections[self.account].delete_jingle_session(
 | 
				
			||||||
				self.contact.get_full_jid(), self.video_sid)
 | 
									self.contact.get_full_jid(), self.video_sid)
 | 
				
			||||||
			self._video_button.set_active(False)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if state == 'not_available':
 | 
					 | 
				
			||||||
			self.video_state = self.JINGLE_STATE_NOT_AVAILABLE
 | 
					 | 
				
			||||||
			self.video_sid = None
 | 
					 | 
				
			||||||
		elif state == 'available':
 | 
					 | 
				
			||||||
			self.video_state = self.JINGLE_STATE_AVAILABLE
 | 
					 | 
				
			||||||
			self.video_sid = None
 | 
					 | 
				
			||||||
		elif state == 'connecting':
 | 
					 | 
				
			||||||
			self.video_state = self.JINGLE_STATE_CONNECTING
 | 
					 | 
				
			||||||
			self.video_sid = sid
 | 
					 | 
				
			||||||
		elif state == 'connection_received':
 | 
					 | 
				
			||||||
			self.video_state = self.JINGLE_STATE_CONNECTION_RECEIVED
 | 
					 | 
				
			||||||
			self.video_sid = sid
 | 
					 | 
				
			||||||
		elif state == 'connected':
 | 
					 | 
				
			||||||
			self.video_state = self.JINGLE_STATE_CONNECTED
 | 
					 | 
				
			||||||
		elif state == 'stop':
 | 
					 | 
				
			||||||
			self.video_state = self.JINGLE_STATE_AVAILABLE
 | 
					 | 
				
			||||||
			self.video_sid = None
 | 
					 | 
				
			||||||
			self._video_button.set_active(False)
 | 
					 | 
				
			||||||
		elif state == 'error':
 | 
					 | 
				
			||||||
			self.video_state = self.JINGLE_STATE_ERROR
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		self.update_video()
 | 
							self.update_video()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue