pm bugfix
This commit is contained in:
		
							parent
							
								
									be0af1a56b
								
							
						
					
					
						commit
						1962b231e6
					
				
					 5 changed files with 48 additions and 42 deletions
				
			
		|  | @ -1846,6 +1846,7 @@ class ChatControl(ChatControlBase): | |||
| 		self.contact.chatstate = None | ||||
| 		self.contact.our_chatstate = None | ||||
| 
 | ||||
| 		# terminate session | ||||
| 		self.session.control = None | ||||
| 
 | ||||
| 		# Disconnect timer callbacks | ||||
|  | @ -2077,12 +2078,11 @@ class ChatControl(ChatControlBase): | |||
| 		# reset to status image in gc if it is a pm | ||||
| 		# Is it a pm ? | ||||
| 		room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) | ||||
| # XXX fixme somehow | ||||
| #		control = gajim.interface.msg_win_mgr.get_control(room_jid, self.account) | ||||
| #		if control and control.type_id == message_control.TYPE_GC: | ||||
| #			control.update_ui() | ||||
| #			control.parent_win.show_title() | ||||
| #			typ = 'pm' | ||||
| 		control = gajim.interface.msg_win_mgr.get_gc_control(room_jid, self.account) | ||||
| 		if control and control.type_id == message_control.TYPE_GC: | ||||
| 			control.update_ui() | ||||
| 			control.parent_win.show_title() | ||||
| 			typ = 'pm' | ||||
| 
 | ||||
| 		self.redraw_after_event_removed(jid) | ||||
| 		if (self.contact.show in ('offline', 'error')): | ||||
|  | @ -2093,8 +2093,8 @@ class ChatControl(ChatControlBase): | |||
| 			len(gajim.contacts.get_contacts(self.account, jid)) < 2): | ||||
| 				gajim.interface.roster.really_remove_contact(self.contact, | ||||
| 					self.account) | ||||
| #			elif typ == 'pm': | ||||
| #				control.remove_contact(nick) | ||||
| 			elif typ == 'pm': | ||||
| 				control.remove_contact(nick) | ||||
| 
 | ||||
| 	def show_bigger_avatar(self, small_avatar): | ||||
| 		'''resizes the avatar, if needed, so it has at max half the screen size | ||||
|  |  | |||
|  | @ -1924,6 +1924,7 @@ class Interface: | |||
| 			if ctrl: | ||||
| 				new_sess = gajim.connections[account].make_new_session(str(jid)) | ||||
| 				ctrl.set_session(new_sess) | ||||
| 				gajim.connections[account].delete_session(str(jid), session.thread_id) | ||||
| 
 | ||||
| 				if was_encrypted: | ||||
| 					ctrl.print_esession_details() | ||||
|  |  | |||
|  | @ -604,7 +604,7 @@ class GroupchatControl(ChatControlBase): | |||
| 		no_queue = len(gajim.events.get_events(self.account, fjid)) == 0 | ||||
| 
 | ||||
| 		# We print if window is opened | ||||
| 		pm_control = gajim.interface.msg_win_mgr.get_control(fjid, self.account, session) | ||||
| 		pm_control = session.control | ||||
| 
 | ||||
| 		if pm_control: | ||||
| 			pm_control.print_conversation(msg, tim = tim, xhtml = xhtml) | ||||
|  | @ -632,7 +632,7 @@ class GroupchatControl(ChatControlBase): | |||
| 				self.parent_win.show_title() | ||||
| 				self.parent_win.redraw_tab(self) | ||||
| 		else: | ||||
| 			self._start_private_message(nick, session) | ||||
| 			self._start_private_message(nick) | ||||
| 		# Scroll to line | ||||
| 		self.list_treeview.expand_row(path[0:1], False) | ||||
| 		self.list_treeview.scroll_to_cell(path) | ||||
|  | @ -891,10 +891,9 @@ class GroupchatControl(ChatControlBase): | |||
| 			nick = model[iter][C_NICK].decode('utf-8') | ||||
| 		fjid = gajim.construct_fjid(self.room_jid, nick) # 'fake' jid | ||||
| 
 | ||||
| 		self._start_private_message(nick) | ||||
| 		ctrl = self._start_private_message(nick) | ||||
| 		if msg: | ||||
| 			gajim.interface.msg_win_mgr.get_control(fjid, self.account).\ | ||||
| 				send_message(msg) | ||||
| 			ctrl.send_message(msg) | ||||
| 
 | ||||
| 	def on_send_file(self, widget, gc_contact): | ||||
| 		'''sends a file to a contact in the room''' | ||||
|  | @ -2041,6 +2040,8 @@ class GroupchatControl(ChatControlBase): | |||
| 		win.set_active_tab(ctrl) | ||||
| 		win.window.present() | ||||
| 
 | ||||
| 		return ctrl | ||||
| 
 | ||||
| 	def on_row_activated(self, widget, path): | ||||
| 		'''When an iter is activated (dubblick or single click if gnome is set | ||||
| 		this way''' | ||||
|  |  | |||
|  | @ -117,25 +117,24 @@ class MessageControl: | |||
| 		return len(gajim.events.get_events(self.account, self.contact.jid)) | ||||
| 
 | ||||
| 	def set_session(self, session): | ||||
| 		if hasattr(self, 'session') and session == self.session: | ||||
| 		oldsession = None | ||||
| 		if hasattr(self, 'session'): | ||||
| 			oldsession = self.session | ||||
| 
 | ||||
| 		if oldsession and session == oldsession: | ||||
| 			return | ||||
| 
 | ||||
| 		was_encrypted = False | ||||
| 
 | ||||
| 		if hasattr(self, 'session') and self.session: | ||||
| 			if self.session.enable_encryption: | ||||
| 				was_encrypted = True | ||||
| 
 | ||||
| 			gajim.connections[self.account].delete_session(self.session.jid, | ||||
| 									self.session.thread_id) | ||||
| 
 | ||||
| 		self.session = session | ||||
| 
 | ||||
| 		if session: | ||||
| 			session.control = self | ||||
| 
 | ||||
| 			if was_encrypted: | ||||
| 				self.print_esession_details() | ||||
| 			if oldsession: | ||||
| 				self.parent_win.change_thread_key(self.contact.jid, | ||||
| 						self.account, oldsession.thread_id, session.thread_id) | ||||
| 
 | ||||
| 				if oldsession.enable_encryption: | ||||
| 					self.print_esession_details() | ||||
| 
 | ||||
| 	def send_message(self, message, keyID = '', type = 'chat', | ||||
| 	chatstate = None, msg_id = None, composing_xep = None, resource = None, | ||||
|  | @ -144,13 +143,6 @@ class MessageControl: | |||
| 		''' | ||||
| 		jid = self.contact.jid | ||||
| 
 | ||||
| 		if not self.session: | ||||
| 			print('uhoh new session') | ||||
| 			fjid = self.contact.get_full_jid() | ||||
| 			new_session = gajim.connections[self.account].make_new_session(fjid) | ||||
| 
 | ||||
| 			self.set_session(new_session) | ||||
| 
 | ||||
| 		# Send and update history | ||||
| 		return gajim.connections[self.account].send_message(jid, message, keyID, | ||||
| 			type = type, chatstate = chatstate, msg_id = msg_id, | ||||
|  |  | |||
|  | @ -429,6 +429,7 @@ class MessageWindow(object): | |||
| 
 | ||||
| 		fjid = ctrl.get_full_jid() | ||||
| 		thread_id = ctrl.session.thread_id | ||||
| 
 | ||||
| 		del self._controls[ctrl.account][fjid][thread_id] | ||||
| 
 | ||||
| 		if len(self._controls[ctrl.account][fjid]) == 0: | ||||
|  | @ -567,19 +568,30 @@ class MessageWindow(object): | |||
| 			return [] | ||||
| 
 | ||||
| 	def change_key(self, old_jid, new_jid, acct): | ||||
| 		'''Change the key of a control''' | ||||
| 		'''Change the JID key of a control''' | ||||
| 		try: | ||||
| 			# Check if control exists | ||||
| 			ctrl = self._controls[acct][old_jid] | ||||
| 		except: | ||||
| 			# Check if controls exists | ||||
| 			ctrls = self._controls[acct][old_jid] | ||||
| 		except KeyError: | ||||
| 			return | ||||
| 		self._controls[acct][new_jid] = self._controls[acct][old_jid] | ||||
| 		self._controls[acct][new_jid] = ctrls | ||||
| 		del self._controls[acct][old_jid] | ||||
| 		if old_jid in gajim.last_message_time[acct]: | ||||
| 			gajim.last_message_time[acct][new_jid] = \ | ||||
| 				gajim.last_message_time[acct][old_jid] | ||||
| 			del gajim.last_message_time[acct][old_jid] | ||||
| 
 | ||||
| 	def change_thread_key(self, jid, acct, old_thread_id, new_thread_id): | ||||
| 		'''Change the thread_id key of a control''' | ||||
| 		try: | ||||
| 			# Check if control exists | ||||
| 			ctrl = self._controls[acct][jid][old_thread_id] | ||||
| 		except KeyError: | ||||
| 			return | ||||
| 
 | ||||
| 		self._controls[acct][jid][new_thread_id] = ctrl | ||||
| 		del self._controls[acct][jid][old_thread_id] | ||||
| 
 | ||||
| 	def controls(self): | ||||
| 		for jid_dict in self._controls.values(): | ||||
| 			for ctrl_dict in jid_dict.values(): | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue