History action, some chatstate stuff moved over, etc.
This commit is contained in:
		
							parent
							
								
									1360933ba9
								
							
						
					
					
						commit
						b239d4ff00
					
				
					 4 changed files with 80 additions and 62 deletions
				
			
		| 
						 | 
					@ -292,7 +292,7 @@ class ChatControlBase(MessageControl):
 | 
				
			||||||
			if gajim.interface.systray_enabled and\
 | 
								if gajim.interface.systray_enabled and\
 | 
				
			||||||
				gajim.config.get('trayicon_notification_on_new_messages'):
 | 
									gajim.config.get('trayicon_notification_on_new_messages'):
 | 
				
			||||||
				gajim.interface.systray.add_jid(jid, self.account, self.type)
 | 
									gajim.interface.systray.add_jid(jid, self.account, self.type)
 | 
				
			||||||
			self.redraw_tab(jid)
 | 
								self.parent_win.redraw_tab(jid)
 | 
				
			||||||
			self.show_title(urgent)
 | 
								self.show_title(urgent)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def toggle_emoticons(self):
 | 
						def toggle_emoticons(self):
 | 
				
			||||||
| 
						 | 
					@ -393,6 +393,16 @@ class ChatControlBase(MessageControl):
 | 
				
			||||||
			del self.print_time_timeout_id
 | 
								del self.print_time_timeout_id
 | 
				
			||||||
		return False
 | 
							return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def on_history_menuitem_clicked(self, widget = None, jid = None):
 | 
				
			||||||
 | 
							'''When history menuitem is pressed: call history window'''
 | 
				
			||||||
 | 
							# FIXME for GC, jid is None
 | 
				
			||||||
 | 
							print widget, jid
 | 
				
			||||||
 | 
							if gajim.interface.instances['logs'].has_key(jid):
 | 
				
			||||||
 | 
								gajim.interface.instances['logs'][jid].window.present()
 | 
				
			||||||
 | 
							else:
 | 
				
			||||||
 | 
								gajim.interface.instances['logs'][jid] = history_window.HistoryWindow(
 | 
				
			||||||
 | 
									jid, self.account)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
################################################################################
 | 
					################################################################################
 | 
				
			||||||
class ChatControl(ChatControlBase):
 | 
					class ChatControl(ChatControlBase):
 | 
				
			||||||
	'''A control for standard 1-1 chat'''
 | 
						'''A control for standard 1-1 chat'''
 | 
				
			||||||
| 
						 | 
					@ -423,6 +433,7 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
		ChatControlBase.draw_widgets(self)
 | 
							ChatControlBase.draw_widgets(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def _update_banner_state_image(self):
 | 
						def _update_banner_state_image(self):
 | 
				
			||||||
 | 
							# FIXME: The cyling of contact_list ... is this necessary if I have the contact
 | 
				
			||||||
		contact = self.contact
 | 
							contact = self.contact
 | 
				
			||||||
		show = contact.show
 | 
							show = contact.show
 | 
				
			||||||
		jid = contact.jid
 | 
							jid = contact.jid
 | 
				
			||||||
| 
						 | 
					@ -453,9 +464,12 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		self._update_gpg()
 | 
							self._update_gpg()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def draw_banner(self):
 | 
						def draw_banner(self, chatstate = None):
 | 
				
			||||||
		'''Draw the fat line at the top of the window that 
 | 
							'''Draw the fat line at the top of the window that 
 | 
				
			||||||
		houses the status icon, name, jid, and avatar'''
 | 
							houses the status icon, name, jid, and avatar.  The chatstate arg should
 | 
				
			||||||
 | 
							only be used if the control's chatstate member is NOT to be use, such as
 | 
				
			||||||
 | 
							composing, paused, etc.
 | 
				
			||||||
 | 
							'''
 | 
				
			||||||
		ChatControlBase.draw_banner(self)
 | 
							ChatControlBase.draw_banner(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		contact = self.contact
 | 
							contact = self.contact
 | 
				
			||||||
| 
						 | 
					@ -686,8 +700,7 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
		if color:
 | 
							if color:
 | 
				
			||||||
			color = gtk.gdk.colormap_get_system().alloc_color(color)
 | 
								color = gtk.gdk.colormap_get_system().alloc_color(color)
 | 
				
			||||||
			# We set the color for when it's the current tab or not
 | 
								# We set the color for when it's the current tab or not
 | 
				
			||||||
			nickname.modify_fg(gtk.STATE_NORMAL, color)
 | 
								# FIXME: why was this only happening for inactive or gone
 | 
				
			||||||
			# FIXME
 | 
					 | 
				
			||||||
			#if chatstate in ('inactive', 'gone'):
 | 
								#if chatstate in ('inactive', 'gone'):
 | 
				
			||||||
			# In inactive tab color to be lighter against the darker inactive
 | 
								# In inactive tab color to be lighter against the darker inactive
 | 
				
			||||||
			# background
 | 
								# background
 | 
				
			||||||
| 
						 | 
					@ -697,7 +710,6 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
				color.red = int((color.red * p) + (mask * (1 - p)))
 | 
									color.red = int((color.red * p) + (mask * (1 - p)))
 | 
				
			||||||
				color.green = int((color.green * p) + (mask * (1 - p)))
 | 
									color.green = int((color.green * p) + (mask * (1 - p)))
 | 
				
			||||||
				color.blue = int((color.blue * p) + (mask * (1 - p)))
 | 
									color.blue = int((color.blue * p) + (mask * (1 - p)))
 | 
				
			||||||
			nickname.modify_fg(gtk.STATE_ACTIVE, color)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if num_unread: # if unread, text in the label becomes bold
 | 
							if num_unread: # if unread, text in the label becomes bold
 | 
				
			||||||
			label_str = '<b>' + unread + label_str + '</b>'
 | 
								label_str = '<b>' + unread + label_str + '</b>'
 | 
				
			||||||
| 
						 | 
					@ -746,7 +758,7 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
		issensitive = gpg_btn.get_property('sensitive')
 | 
							issensitive = gpg_btn.get_property('sensitive')
 | 
				
			||||||
		childs[3].set_active(isactive)
 | 
							childs[3].set_active(isactive)
 | 
				
			||||||
		childs[3].set_property('sensitive', issensitive)
 | 
							childs[3].set_property('sensitive', issensitive)
 | 
				
			||||||
		# If we don't have resource, we can't do file transfert
 | 
							# If we don't have resource, we can't do file transfer
 | 
				
			||||||
		if not contact.resource:
 | 
							if not contact.resource:
 | 
				
			||||||
			childs[2].set_sensitive(False)
 | 
								childs[2].set_sensitive(False)
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
| 
						 | 
					@ -887,3 +899,10 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
				return True #stop the propagation of the event
 | 
									return True #stop the propagation of the event
 | 
				
			||||||
		return False
 | 
							return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def handle_incoming_chatstate(self):
 | 
				
			||||||
 | 
							''' handle incoming chatstate that jid SENT TO us '''
 | 
				
			||||||
 | 
							self.draw_banner()
 | 
				
			||||||
 | 
							# update chatstate in tab for this chat
 | 
				
			||||||
 | 
							self.parent_win.redraw_tab(self.contact, self.contact.chatstate)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,16 +24,23 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import common.gajim
 | 
					import common.gajim
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Contact:
 | 
					class ContactBase:
 | 
				
			||||||
 | 
						def __init__(self, jid='', name='', show='', status=''):
 | 
				
			||||||
 | 
							self.jid = jid
 | 
				
			||||||
 | 
							self.name = name
 | 
				
			||||||
 | 
							self.show = show
 | 
				
			||||||
 | 
							self.status = status
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def get_full_jid(self):
 | 
				
			||||||
 | 
							pass # Derived types MUST implement this method
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Contact(ContactBase):
 | 
				
			||||||
	'''Information concerning each contact'''
 | 
						'''Information concerning each contact'''
 | 
				
			||||||
	def __init__(self, jid='', name='', groups=[], show='', status='', sub='',
 | 
						def __init__(self, jid='', name='', groups=[], show='', status='', sub='',
 | 
				
			||||||
			ask='', resource='', priority=5, keyID='', our_chatstate=None,
 | 
								ask='', resource='', priority=5, keyID='', our_chatstate=None,
 | 
				
			||||||
			chatstate=None):
 | 
								chatstate=None):
 | 
				
			||||||
		self.jid = jid
 | 
							ContactBase.__init__(self, jid = jid, name = name, status = status, show = show)
 | 
				
			||||||
		self.name = name
 | 
					 | 
				
			||||||
		self.groups = groups
 | 
							self.groups = groups
 | 
				
			||||||
		self.show = show
 | 
					 | 
				
			||||||
		self.status = status
 | 
					 | 
				
			||||||
		self.sub = sub
 | 
							self.sub = sub
 | 
				
			||||||
		self.ask = ask
 | 
							self.ask = ask
 | 
				
			||||||
		self.resource = resource
 | 
							self.resource = resource
 | 
				
			||||||
| 
						 | 
					@ -56,17 +63,14 @@ class Contact:
 | 
				
			||||||
			return self.jid + '/' + self.resource
 | 
								return self.jid + '/' + self.resource
 | 
				
			||||||
		return self.jid
 | 
							return self.jid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class GC_Contact:
 | 
					class GC_Contact(ContactBase):
 | 
				
			||||||
	'''Information concerning each groupchat contact'''
 | 
						'''Information concerning each groupchat contact'''
 | 
				
			||||||
	def __init__(self, room_jid='', name='', show='', status='', role='',
 | 
						def __init__(self, room_jid='', name='', show='', status='', role='',
 | 
				
			||||||
			affiliation='', jid = ''):
 | 
								affiliation='', jid = ''):
 | 
				
			||||||
 | 
							ContactBase.__init__(self, jid = jid, name = name, status = status, show = show)
 | 
				
			||||||
		self.room_jid = room_jid
 | 
							self.room_jid = room_jid
 | 
				
			||||||
		self.name = name
 | 
					 | 
				
			||||||
		self.show = show
 | 
					 | 
				
			||||||
		self.status = status
 | 
					 | 
				
			||||||
		self.role = role
 | 
							self.role = role
 | 
				
			||||||
		self.affiliation = affiliation
 | 
							self.affiliation = affiliation
 | 
				
			||||||
		self.jid = jid
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def get_full_jid(self):
 | 
						def get_full_jid(self):
 | 
				
			||||||
		return self.room_jid + '/' + self.name
 | 
							return self.room_jid + '/' + self.name
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										77
									
								
								src/gajim.py
									
										
									
									
									
								
							
							
						
						
									
										77
									
								
								src/gajim.py
									
										
									
									
									
								
							| 
						 | 
					@ -344,8 +344,7 @@ class Interface:
 | 
				
			||||||
				if gajim.config.get_per('soundevents', 'contact_connected',
 | 
									if gajim.config.get_per('soundevents', 'contact_connected',
 | 
				
			||||||
					'enabled') and gajim.allow_notifications[account]:
 | 
										'enabled') and gajim.allow_notifications[account]:
 | 
				
			||||||
					helpers.play_sound('contact_connected')
 | 
										helpers.play_sound('contact_connected')
 | 
				
			||||||
				# FIXME
 | 
									if not gajim.interface.msg_win_mgr.has_window(jid) and \
 | 
				
			||||||
				if not self.instances[account]['chats'].has_key(jid) and \
 | 
					 | 
				
			||||||
					not gajim.awaiting_events[account].has_key(jid) and \
 | 
										not gajim.awaiting_events[account].has_key(jid) and \
 | 
				
			||||||
					gajim.config.get('notify_on_signin') and \
 | 
										gajim.config.get('notify_on_signin') and \
 | 
				
			||||||
					gajim.allow_notifications[account]:
 | 
										gajim.allow_notifications[account]:
 | 
				
			||||||
| 
						 | 
					@ -365,8 +364,7 @@ class Interface:
 | 
				
			||||||
				if gajim.config.get_per('soundevents', 'contact_disconnected',
 | 
									if gajim.config.get_per('soundevents', 'contact_disconnected',
 | 
				
			||||||
						'enabled'):
 | 
											'enabled'):
 | 
				
			||||||
					helpers.play_sound('contact_disconnected')
 | 
										helpers.play_sound('contact_disconnected')
 | 
				
			||||||
				# FIXME
 | 
									if not gajim.interface.msg_win_mgr.has_window(jid) and \
 | 
				
			||||||
				if not self.instances[account]['chats'].has_key(jid) and \
 | 
					 | 
				
			||||||
					not gajim.awaiting_events[account].has_key(jid) and \
 | 
										not gajim.awaiting_events[account].has_key(jid) and \
 | 
				
			||||||
					gajim.config.get('notify_on_signout'):
 | 
										gajim.config.get('notify_on_signout'):
 | 
				
			||||||
					show_notification = False
 | 
										show_notification = False
 | 
				
			||||||
| 
						 | 
					@ -408,8 +406,7 @@ class Interface:
 | 
				
			||||||
		if self.instances[account]['gc'].has_key(jid): # it's a Private Message
 | 
							if self.instances[account]['gc'].has_key(jid): # it's a Private Message
 | 
				
			||||||
			nick = gajim.get_nick_from_fjid(array[0])
 | 
								nick = gajim.get_nick_from_fjid(array[0])
 | 
				
			||||||
			fjid = array[0]
 | 
								fjid = array[0]
 | 
				
			||||||
			# FIXME
 | 
								if not gajim.interface.msg_win_mgr.has_window(fjid) and \
 | 
				
			||||||
			if not self.instances[account]['chats'].has_key(fjid) and \
 | 
					 | 
				
			||||||
				not gajim.awaiting_events[account].has_key(fjid):
 | 
									not gajim.awaiting_events[account].has_key(fjid):
 | 
				
			||||||
				if show_notification:
 | 
									if show_notification:
 | 
				
			||||||
					notify.notify(_('New Private Message'), fjid, account, 'pm')
 | 
										notify.notify(_('New Private Message'), fjid, account, 'pm')
 | 
				
			||||||
| 
						 | 
					@ -424,15 +421,14 @@ class Interface:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# Handle chat states  
 | 
							# Handle chat states  
 | 
				
			||||||
		contact = gajim.contacts.get_first_contact_from_jid(account, jid)
 | 
							contact = gajim.contacts.get_first_contact_from_jid(account, jid)
 | 
				
			||||||
		# FIXME
 | 
							if gajim.interface.msg_win_mgr.has_window(jid):
 | 
				
			||||||
		if self.instances[account]['chats'].has_key(jid):
 | 
								chat_ctl = gajim.interface.msg_win_mgr.get_control(jid)
 | 
				
			||||||
			chat_win = self.instances[account]['chats'][jid]
 | 
					 | 
				
			||||||
			if chatstate is not None: # he or she sent us reply, so he supports jep85
 | 
								if chatstate is not None: # he or she sent us reply, so he supports jep85
 | 
				
			||||||
				contact.chatstate = chatstate
 | 
									contact.chatstate = chatstate
 | 
				
			||||||
				if contact.our_chatstate == 'ask': # we were jep85 disco?
 | 
									if contact.our_chatstate == 'ask': # we were jep85 disco?
 | 
				
			||||||
					contact.our_chatstate = 'active' # no more
 | 
										contact.our_chatstate = 'active' # no more
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
				chat_win.handle_incoming_chatstate(account, contact)
 | 
									chat_ctl.handle_incoming_chatstate()
 | 
				
			||||||
			elif contact.chatstate != 'active':
 | 
								elif contact.chatstate != 'active':
 | 
				
			||||||
				# got no valid jep85 answer, peer does not support it
 | 
									# got no valid jep85 answer, peer does not support it
 | 
				
			||||||
				contact.chatstate = False
 | 
									contact.chatstate = False
 | 
				
			||||||
| 
						 | 
					@ -445,8 +441,7 @@ class Interface:
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		first = False
 | 
							first = False
 | 
				
			||||||
		# FIXME
 | 
							if not gajim.interface.msg_win_mgr.has_window(jid) and \
 | 
				
			||||||
		if not self.instances[account]['chats'].has_key(jid) and \
 | 
					 | 
				
			||||||
			not gajim.awaiting_events[account].has_key(jid):
 | 
								not gajim.awaiting_events[account].has_key(jid):
 | 
				
			||||||
			first = True
 | 
								first = True
 | 
				
			||||||
			if gajim.config.get('notify_on_new_message'):
 | 
								if gajim.config.get('notify_on_new_message'):
 | 
				
			||||||
| 
						 | 
					@ -483,8 +478,7 @@ class Interface:
 | 
				
			||||||
		if jid in gcs:
 | 
							if jid in gcs:
 | 
				
			||||||
			if len(jids) > 1: # it's a pm
 | 
								if len(jids) > 1: # it's a pm
 | 
				
			||||||
				nick = jids[1]
 | 
									nick = jids[1]
 | 
				
			||||||
				# FIXME
 | 
									if not gajim.interface.msg_win_mgr.has_window(fjid):
 | 
				
			||||||
				if not self.instances[account]['chats'].has_key(fjid):
 | 
					 | 
				
			||||||
					gc = gcs[jid]
 | 
										gc = gcs[jid]
 | 
				
			||||||
					tv = gc.list_treeview[jid]
 | 
										tv = gc.list_treeview[jid]
 | 
				
			||||||
					model = tv.get_model()
 | 
										model = tv.get_model()
 | 
				
			||||||
| 
						 | 
					@ -497,10 +491,11 @@ class Interface:
 | 
				
			||||||
						name = nick, show = show)
 | 
											name = nick, show = show)
 | 
				
			||||||
					c = gajim.contacts.contact_from_gc_contct(c)
 | 
										c = gajim.contacts.contact_from_gc_contct(c)
 | 
				
			||||||
					self.roster.new_chat(c, account)
 | 
										self.roster.new_chat(c, account)
 | 
				
			||||||
				# FIXME
 | 
									ctl = gajim.interface.msg_win_mgr.get_control(fjid)
 | 
				
			||||||
				self.instances[account]['chats'][fjid].print_conversation(
 | 
									ctl.print_conversation('Error %s: %s' % (array[1], array[2]),
 | 
				
			||||||
					'Error %s: %s' % (array[1], array[2]), fjid, 'status')
 | 
												'status')
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
 | 
								# FIXME
 | 
				
			||||||
			gcs[jid].print_conversation('Error %s: %s' % \
 | 
								gcs[jid].print_conversation('Error %s: %s' % \
 | 
				
			||||||
				(array[1], array[2]), jid)
 | 
									(array[1], array[2]), jid)
 | 
				
			||||||
			if gcs[jid].get_active_jid() == jid:
 | 
								if gcs[jid].get_active_jid() == jid:
 | 
				
			||||||
| 
						 | 
					@ -651,14 +646,17 @@ class Interface:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# show avatar in chat
 | 
							# show avatar in chat
 | 
				
			||||||
		win = None
 | 
							win = None
 | 
				
			||||||
		# FIXME
 | 
							ctl = None
 | 
				
			||||||
		if self.instances[account]['chats'].has_key(jid):
 | 
							if gajim.interface.msg_win_mgr.has_window(jid):
 | 
				
			||||||
			win = self.instances[account]['chats'][jid]
 | 
								win = gajim.interface.msg_type.get_window(jid)
 | 
				
			||||||
		elif resource and self.instances[account]['chats'].has_key(
 | 
								ctl = win.get_control(jid)
 | 
				
			||||||
			jid + '/' + resource):
 | 
							# FIXME: Why is this needed
 | 
				
			||||||
			win = self.instances[account]['chats'][jid + '/' + resource]
 | 
							elif resource and gajim.interface.msg_win_mgr.has_window(jid + '/' + resource):
 | 
				
			||||||
 | 
								win = gajim.interface.msg_type.get_window(jid + '/' + resource)
 | 
				
			||||||
 | 
								ctl = win.get_control(jid + '/' + resource)
 | 
				
			||||||
		if win:
 | 
							if win:
 | 
				
			||||||
			win.show_avatar(jid, resource)
 | 
								# FIXME: Are these args needed
 | 
				
			||||||
 | 
								ctl.show_avatar(jid, resource)
 | 
				
			||||||
		# Show avatar in roster
 | 
							# Show avatar in roster
 | 
				
			||||||
		self.roster.draw_avatar(jid, account)
 | 
							self.roster.draw_avatar(jid, account)
 | 
				
			||||||
		if self.remote_ctrl:
 | 
							if self.remote_ctrl:
 | 
				
			||||||
| 
						 | 
					@ -686,17 +684,16 @@ class Interface:
 | 
				
			||||||
		show = array[1]
 | 
							show = array[1]
 | 
				
			||||||
		status = array[2]
 | 
							status = array[2]
 | 
				
			||||||
		# print status in chat window and update status/GPG image
 | 
							# print status in chat window and update status/GPG image
 | 
				
			||||||
		# FIXME
 | 
							if gajim.interface.msg_win_mgr.has_window(fjid):
 | 
				
			||||||
		if self.instances[account]['chats'].has_key(fjid):
 | 
								ctl = gajim.interface.msg_win_mgr.get_control(fjid)
 | 
				
			||||||
			contact = self.instances[account]['chats'][fjid].contacts[fjid]
 | 
								contact = ctl.contact
 | 
				
			||||||
			contact.show = show
 | 
								contact.show = show
 | 
				
			||||||
			contact.status = status
 | 
								contact.status = status
 | 
				
			||||||
			self.instances[account]['chats'][fjid].set_state_image(fjid)
 | 
								ctl.update_state()
 | 
				
			||||||
			uf_show = helpers.get_uf_show(show)
 | 
								uf_show = helpers.get_uf_show(show)
 | 
				
			||||||
			self.instances[account]['chats'][fjid].print_conversation(
 | 
								ctl.print_conversation(_('%s is now %s (%s)') % (nick, uf_show, status),
 | 
				
			||||||
				_('%s is now %s (%s)') % (nick, uf_show, status), fjid,
 | 
					 | 
				
			||||||
						'status')
 | 
											'status')
 | 
				
			||||||
			self.instances[account]['chats'][fjid].draw_name_banner(contact)
 | 
								ctl.draw_banner()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if self.instances[account]['gc'].has_key(room_jid):
 | 
							if self.instances[account]['gc'].has_key(room_jid):
 | 
				
			||||||
			self.instances[account]['gc'][room_jid].chg_contact_status(room_jid,
 | 
								self.instances[account]['gc'][room_jid].chg_contact_status(room_jid,
 | 
				
			||||||
| 
						 | 
					@ -1244,26 +1241,24 @@ class Interface:
 | 
				
			||||||
			sys.exit()
 | 
								sys.exit()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def handle_event(self, account, jid, typ):
 | 
						def handle_event(self, account, jid, typ):
 | 
				
			||||||
		wins = self.instances[account]
 | 
					 | 
				
			||||||
		w = None
 | 
							w = None
 | 
				
			||||||
		if typ == 'gc':
 | 
							if typ == 'gc':
 | 
				
			||||||
			if wins['gc'].has_key(jid):
 | 
								if wins['gc'].has_key(jid):
 | 
				
			||||||
				w = wins['gc'][jid]
 | 
									w = wins['gc'][jid]
 | 
				
			||||||
		elif typ == 'chat':
 | 
							elif typ == 'chat':
 | 
				
			||||||
			# FIXME
 | 
								if gajim.interface.msg_win_mgr.has_window(jid):
 | 
				
			||||||
			if wins['chats'].has_key(jid):
 | 
									w = gajim.interface.msg_win_mgr.get_window(jid)
 | 
				
			||||||
				w = wins['chats'][jid]
 | 
					 | 
				
			||||||
			else:
 | 
								else:
 | 
				
			||||||
				contact = gajim.contacts.get_first_contact_from_jid(account, jid)
 | 
									contact = gajim.contacts.get_first_contact_from_jid(account, jid)
 | 
				
			||||||
				self.roster.new_chat(contact, account)
 | 
									self.roster.new_chat(contact, account)
 | 
				
			||||||
				w = wins['chats'][jid]
 | 
									w = gajim.interface.msg_win_mgr.get_window(jid)
 | 
				
			||||||
		elif typ == 'pm':
 | 
							elif typ == 'pm':
 | 
				
			||||||
			# FIXME
 | 
								if gajim.interface.msg_win_mgr.has_window(jid):
 | 
				
			||||||
			if wins['chats'].has_key(jid):
 | 
									w = gajim.interface.msg_win_mgr.get_window(jid)
 | 
				
			||||||
				w = wins['chats'][jid]
 | 
					 | 
				
			||||||
			else:
 | 
								else:
 | 
				
			||||||
				room_jid, nick = jid.split('/', 1)
 | 
									room_jid, nick = jid.split('/', 1)
 | 
				
			||||||
				gc_contact = gajim.contacts.get_gc_contact(account, room_jid, nick)
 | 
									gc_contact = gajim.contacts.get_gc_contact(account, room_jid,
 | 
				
			||||||
 | 
															nick)
 | 
				
			||||||
				if gc_contact:
 | 
									if gc_contact:
 | 
				
			||||||
					show = gc_contact.show
 | 
										show = gc_contact.show
 | 
				
			||||||
				else:
 | 
									else:
 | 
				
			||||||
| 
						 | 
					@ -1272,7 +1267,7 @@ class Interface:
 | 
				
			||||||
						name = nick, show = show)
 | 
											name = nick, show = show)
 | 
				
			||||||
				c = gajim.contacts.contact_from_gc_contct(gc_contact)
 | 
									c = gajim.contacts.contact_from_gc_contct(gc_contact)
 | 
				
			||||||
				self.roster.new_chat(c, account)
 | 
									self.roster.new_chat(c, account)
 | 
				
			||||||
				w = wins['chats'][jid]
 | 
									w = gajim.interface.msg_win_mgr.get_window(jid)
 | 
				
			||||||
		elif typ in ('normal', 'file-request', 'file-request-error',
 | 
							elif typ in ('normal', 'file-request', 'file-request-error',
 | 
				
			||||||
			'file-send-error', 'file-error', 'file-stopped', 'file-completed'):
 | 
								'file-send-error', 'file-error', 'file-stopped', 'file-completed'):
 | 
				
			||||||
			# Get the first single message event
 | 
								# Get the first single message event
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1942,16 +1942,16 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
 | 
				
			||||||
			recent = False
 | 
								recent = False
 | 
				
			||||||
			if self.nb_unread > 0:
 | 
								if self.nb_unread > 0:
 | 
				
			||||||
				unread = True
 | 
									unread = True
 | 
				
			||||||
			for win in gajim.interface.msg_win_mgr.windows.values():
 | 
								for win in gajim.interface.msg_win_mgr.windows():
 | 
				
			||||||
				unrd = 0
 | 
									unrd = 0
 | 
				
			||||||
				for ctl in win.controls():
 | 
									for ctl in win.controls():
 | 
				
			||||||
					unrd += ctl.nb_unread
 | 
										unrd += ctl.nb_unread
 | 
				
			||||||
				if unrd:
 | 
									if unrd:
 | 
				
			||||||
					unread = True
 | 
										unread = True
 | 
				
			||||||
					break
 | 
										break
 | 
				
			||||||
				for ctl in win.control():
 | 
									for ctl in win.controls():
 | 
				
			||||||
					jid = ctl.contact.jid
 | 
										jid = ctl.contact.jid
 | 
				
			||||||
					if time.time() - gajim.last_message_time[account][ji] < 2:
 | 
										if time.time() - gajim.last_message_time[acct][jid] < 2:
 | 
				
			||||||
						recent = True
 | 
											recent = True
 | 
				
			||||||
						break
 | 
											break
 | 
				
			||||||
			if unread:
 | 
								if unread:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue