status message in the banner instaed of jid; remove_user => remove_contact
This commit is contained in:
		
							parent
							
								
									4ec127aa92
								
							
						
					
					
						commit
						ef6643b24d
					
				
					 5 changed files with 43 additions and 42 deletions
				
			
		| 
						 | 
					@ -63,7 +63,7 @@ class EditGroupsDialog:
 | 
				
			||||||
				self.user.name, self.user.groups)
 | 
									self.user.name, self.user.groups)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def update_contact(self):
 | 
						def update_contact(self):
 | 
				
			||||||
		self.plugin.roster.remove_user(self.user, self.account)
 | 
							self.plugin.roster.remove_contact(self.user, self.account)
 | 
				
			||||||
		self.plugin.roster.add_contact_to_roster(self.user.jid, self.account)
 | 
							self.plugin.roster.add_contact_to_roster(self.user.jid, self.account)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def on_add_button_clicked(self, widget):
 | 
						def on_add_button_clicked(self, widget):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -280,7 +280,7 @@ class Interface:
 | 
				
			||||||
						gajim.newly_added[account].remove(user1.jid)
 | 
											gajim.newly_added[account].remove(user1.jid)
 | 
				
			||||||
					self.roster.draw_contact(user1.jid, account)
 | 
										self.roster.draw_contact(user1.jid, account)
 | 
				
			||||||
					if not gajim.awaiting_messages[account].has_key(jid):
 | 
										if not gajim.awaiting_messages[account].has_key(jid):
 | 
				
			||||||
						gobject.timeout_add(5000, self.roster.really_remove_user, \
 | 
											gobject.timeout_add(5000, self.roster.really_remove_contact, \
 | 
				
			||||||
							user1, account)
 | 
												user1, account)
 | 
				
			||||||
			user1.show = array[1]
 | 
								user1.show = array[1]
 | 
				
			||||||
			user1.status = array[2]
 | 
								user1.status = array[2]
 | 
				
			||||||
| 
						 | 
					@ -478,7 +478,7 @@ class Interface:
 | 
				
			||||||
		if gajim.contacts[account].has_key(jid):
 | 
							if gajim.contacts[account].has_key(jid):
 | 
				
			||||||
			u = gajim.contacts[account][jid][0]
 | 
								u = gajim.contacts[account][jid][0]
 | 
				
			||||||
			u.resource = array[1]
 | 
								u.resource = array[1]
 | 
				
			||||||
			self.roster.remove_user(u, account)
 | 
								self.roster.remove_contact(u, account)
 | 
				
			||||||
			if _('not in the roster') in u.groups:
 | 
								if _('not in the roster') in u.groups:
 | 
				
			||||||
				u.groups.remove(_('not in the roster'))
 | 
									u.groups.remove(_('not in the roster'))
 | 
				
			||||||
			if len(u.groups) == 0:
 | 
								if len(u.groups) == 0:
 | 
				
			||||||
| 
						 | 
					@ -653,7 +653,7 @@ class Interface:
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		users = gajim.contacts[account][jid]
 | 
							users = gajim.contacts[account][jid]
 | 
				
			||||||
		if not (array[2] or array[3]):
 | 
							if not (array[2] or array[3]):
 | 
				
			||||||
			self.roster.remove_user(users[0], account)
 | 
								self.roster.remove_contact(users[0], account)
 | 
				
			||||||
			del gajim.contacts[account][jid]
 | 
								del gajim.contacts[account][jid]
 | 
				
			||||||
			#TODO if it was the only one in its group, remove the group
 | 
								#TODO if it was the only one in its group, remove the group
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -207,7 +207,7 @@ class GroupchatWindow(chat.Chat):
 | 
				
			||||||
		'''get nicks of contacts in a room'''
 | 
							'''get nicks of contacts in a room'''
 | 
				
			||||||
		return self.contacts[room_jid].keys()
 | 
							return self.contacts[room_jid].keys()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def remove_user(self, room_jid, nick):
 | 
						def remove_contact(self, room_jid, nick):
 | 
				
			||||||
		"""Remove a user from the contacts_list"""
 | 
							"""Remove a user from the contacts_list"""
 | 
				
			||||||
		model = self.list_treeview[room_jid].get_model()
 | 
							model = self.list_treeview[room_jid].get_model()
 | 
				
			||||||
		iter = self.get_contact_iter(room_jid, nick)
 | 
							iter = self.get_contact_iter(room_jid, nick)
 | 
				
			||||||
| 
						 | 
					@ -299,7 +299,7 @@ class GroupchatWindow(chat.Chat):
 | 
				
			||||||
					new_nick), room_jid)
 | 
										new_nick), room_jid)
 | 
				
			||||||
				if nick == self.nicks[room_jid]: # We changed our nick
 | 
									if nick == self.nicks[room_jid]: # We changed our nick
 | 
				
			||||||
					self.nicks[room_jid] = new_nick
 | 
										self.nicks[room_jid] = new_nick
 | 
				
			||||||
			self.remove_user(room_jid, nick)
 | 
								self.remove_contact(room_jid, nick)
 | 
				
			||||||
			if nick == self.nicks[room_jid] and statusCode != '303': # We became offline
 | 
								if nick == self.nicks[room_jid] and statusCode != '303': # We became offline
 | 
				
			||||||
				model.clear()
 | 
									model.clear()
 | 
				
			||||||
				self.contacts[room_jid] = {}
 | 
									self.contacts[room_jid] = {}
 | 
				
			||||||
| 
						 | 
					@ -310,7 +310,7 @@ class GroupchatWindow(chat.Chat):
 | 
				
			||||||
			else:
 | 
								else:
 | 
				
			||||||
				actual_role = self.get_role(room_jid, nick)
 | 
									actual_role = self.get_role(room_jid, nick)
 | 
				
			||||||
				if role != actual_role:
 | 
									if role != actual_role:
 | 
				
			||||||
					self.remove_user(room_jid, nick)
 | 
										self.remove_contact(room_jid, nick)
 | 
				
			||||||
					self.add_contact_to_roster(room_jid, nick, show, role, jid,
 | 
										self.add_contact_to_roster(room_jid, nick, show, role, jid,
 | 
				
			||||||
						affiliation)
 | 
											affiliation)
 | 
				
			||||||
				else:
 | 
									else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -158,7 +158,7 @@ class RosterWindow:
 | 
				
			||||||
							False)
 | 
												False)
 | 
				
			||||||
		self.draw_contact(jid, account)
 | 
							self.draw_contact(jid, account)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	def really_remove_user(self, user, account):
 | 
						def really_remove_contact(self, user, account):
 | 
				
			||||||
		if user.jid in gajim.newly_added[account]:
 | 
							if user.jid in gajim.newly_added[account]:
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		if user.jid.find('@') < 1 and gajim.connections[account].connected > 1: # It's an agent
 | 
							if user.jid.find('@') < 1 and gajim.connections[account].connected > 1: # It's an agent
 | 
				
			||||||
| 
						 | 
					@ -168,9 +168,9 @@ class RosterWindow:
 | 
				
			||||||
		if gajim.config.get('showoffline'):
 | 
							if gajim.config.get('showoffline'):
 | 
				
			||||||
			self.draw_contact(user.jid, account)
 | 
								self.draw_contact(user.jid, account)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		self.remove_user(user, account)
 | 
							self.remove_contact(user, account)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	def remove_user(self, user, account):
 | 
						def remove_contact(self, user, account):
 | 
				
			||||||
		'''Remove a user from the roster'''
 | 
							'''Remove a user from the roster'''
 | 
				
			||||||
		if user.jid in gajim.to_be_removed[account]:
 | 
							if user.jid in gajim.to_be_removed[account]:
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
| 
						 | 
					@ -593,37 +593,40 @@ class RosterWindow:
 | 
				
			||||||
					ishidden = True
 | 
										ishidden = True
 | 
				
			||||||
				gajim.groups[account][g] = { 'expand': ishidden }
 | 
									gajim.groups[account][g] = { 'expand': ishidden }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def chg_contact_status(self, user, show, status, account):
 | 
						def chg_contact_status(self, contact, show, status, account):
 | 
				
			||||||
		'''When a contact changes his status'''
 | 
							'''When a contact changes his status'''
 | 
				
			||||||
		showOffline = gajim.config.get('showoffline')
 | 
							showOffline = gajim.config.get('showoffline')
 | 
				
			||||||
		model = self.tree.get_model()
 | 
							model = self.tree.get_model()
 | 
				
			||||||
		luser = gajim.contacts[account][user.jid]
 | 
							contact_instances = gajim.contacts[account][contact.jid]
 | 
				
			||||||
		user.show = show
 | 
							contact.show = show
 | 
				
			||||||
		user.status = status
 | 
							contact.status = status
 | 
				
			||||||
		if (show == 'offline' or show == 'error') and \
 | 
							if (show == 'offline' or show == 'error') and \
 | 
				
			||||||
		   not gajim.awaiting_messages[account].has_key(user.jid):
 | 
							   not gajim.awaiting_messages[account].has_key(contact.jid):
 | 
				
			||||||
			if len(luser) > 1:
 | 
								if len(contact_instances) > 1: # if multiple resources
 | 
				
			||||||
				luser.remove(user)
 | 
									contact_instances.remove(contact)
 | 
				
			||||||
				self.draw_contact(user.jid, account)
 | 
									self.draw_contact(contact.jid, account)
 | 
				
			||||||
			elif not showOffline:
 | 
								elif not showOffline:
 | 
				
			||||||
				self.remove_user(user, account)
 | 
									self.remove_contact(contact, account)
 | 
				
			||||||
			else:
 | 
								else:
 | 
				
			||||||
				self.draw_contact(user.jid, account)
 | 
									self.draw_contact(contact.jid, account)
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			if not self.get_contact_iter(user.jid, account):
 | 
								if not self.get_contact_iter(contact.jid, account):
 | 
				
			||||||
				self.add_contact_to_roster(user.jid, account)
 | 
									self.add_contact_to_roster(contact.jid, account)
 | 
				
			||||||
			self.draw_contact(user.jid, account)
 | 
								self.draw_contact(contact.jid, account)
 | 
				
			||||||
		#print status in chat window and update status/GPG image
 | 
							#print status in chat window and update status/GPG image
 | 
				
			||||||
		if self.plugin.windows[account]['chats'].has_key(user.jid):
 | 
							if self.plugin.windows[account]['chats'].has_key(contact.jid):
 | 
				
			||||||
			jid = user.jid
 | 
								jid = contact.jid
 | 
				
			||||||
			self.plugin.windows[account]['chats'][jid].set_state_image(jid)
 | 
								self.plugin.windows[account]['chats'][jid].set_state_image(jid)
 | 
				
			||||||
			name = user.name
 | 
								name = contact.name
 | 
				
			||||||
			if user.resource != '':
 | 
								if contact.resource != '':
 | 
				
			||||||
				name += '/' + user.resource
 | 
									name += '/' + contact.resource
 | 
				
			||||||
			uf_show = helpers.get_uf_show(show)
 | 
								uf_show = helpers.get_uf_show(show)
 | 
				
			||||||
			self.plugin.windows[account]['chats'][jid].print_conversation(
 | 
								self.plugin.windows[account]['chats'][jid].print_conversation(
 | 
				
			||||||
				_('%s is now %s (%s)') % (name, uf_show, status), jid, 'status')
 | 
									_('%s is now %s (%s)') % (name, uf_show, status), jid, 'status')
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
 | 
								self.plugin.windows[account]['chats'][jid].draw_name_banner(
 | 
				
			||||||
 | 
									contact, chatstate = None)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def on_info(self, widget, user, account):
 | 
						def on_info(self, widget, user, account):
 | 
				
			||||||
		'''Call vcard_information_window class to display user's information'''
 | 
							'''Call vcard_information_window class to display user's information'''
 | 
				
			||||||
		info = self.plugin.windows[account]['infos']
 | 
							info = self.plugin.windows[account]['infos']
 | 
				
			||||||
| 
						 | 
					@ -684,7 +687,7 @@ class RosterWindow:
 | 
				
			||||||
			gajim.connections[account].unsubscribe_agent(contact.jid + '/' \
 | 
								gajim.connections[account].unsubscribe_agent(contact.jid + '/' \
 | 
				
			||||||
																		+ contact.resource)
 | 
																							+ contact.resource)
 | 
				
			||||||
			# remove transport from treeview
 | 
								# remove transport from treeview
 | 
				
			||||||
			self.remove_user(contact, account)
 | 
								self.remove_contact(contact, account)
 | 
				
			||||||
			# remove transport's contacts from treeview
 | 
								# remove transport's contacts from treeview
 | 
				
			||||||
			for jid, contacts in gajim.contacts[account].items():
 | 
								for jid, contacts in gajim.contacts[account].items():
 | 
				
			||||||
				contact = contacts[0]
 | 
									contact = contacts[0]
 | 
				
			||||||
| 
						 | 
					@ -692,7 +695,7 @@ class RosterWindow:
 | 
				
			||||||
					gajim.log.debug(
 | 
										gajim.log.debug(
 | 
				
			||||||
					'Removing contact %s due to unregistered transport %s'\
 | 
										'Removing contact %s due to unregistered transport %s'\
 | 
				
			||||||
						% (contact.jid, contact.name))
 | 
											% (contact.jid, contact.name))
 | 
				
			||||||
					self.remove_user(contact, account)
 | 
										self.remove_contact(contact, account)
 | 
				
			||||||
			del gajim.contacts[account][contact.jid]
 | 
								del gajim.contacts[account][contact.jid]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def on_rename(self, widget, iter, path):
 | 
						def on_rename(self, widget, iter, path):
 | 
				
			||||||
| 
						 | 
					@ -1021,7 +1024,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			user1.groups = [group]
 | 
								user1.groups = [group]
 | 
				
			||||||
			user1.name = pseudo
 | 
								user1.name = pseudo
 | 
				
			||||||
			self.remove_user(user1, account)
 | 
								self.remove_contact(user1, account)
 | 
				
			||||||
		self.add_contact_to_roster(jid, account)
 | 
							self.add_contact_to_roster(jid, account)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def on_roster_treeview_scroll_event(self, widget, event):
 | 
						def on_roster_treeview_scroll_event(self, widget, event):
 | 
				
			||||||
| 
						 | 
					@ -1146,7 +1149,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
 | 
				
			||||||
		if window.get_response() == gtk.RESPONSE_OK:
 | 
							if window.get_response() == gtk.RESPONSE_OK:
 | 
				
			||||||
			gajim.connections[account].unsubscribe(user.jid)
 | 
								gajim.connections[account].unsubscribe(user.jid)
 | 
				
			||||||
			for u in gajim.contacts[account][user.jid]:
 | 
								for u in gajim.contacts[account][user.jid]:
 | 
				
			||||||
				self.remove_user(u, account)
 | 
									self.remove_contact(u, account)
 | 
				
			||||||
			del gajim.contacts[account][u.jid]
 | 
								del gajim.contacts[account][u.jid]
 | 
				
			||||||
			if user.jid in self.plugin.windows[account]['chats']:
 | 
								if user.jid in self.plugin.windows[account]['chats']:
 | 
				
			||||||
				user1 = Contact(jid = user.jid, name = user.name,
 | 
									user1 = Contact(jid = user.jid, name = user.name,
 | 
				
			||||||
| 
						 | 
					@ -1663,7 +1666,7 @@ _('If "%s" accepts this request you will know his status.') %jid).get_response()
 | 
				
			||||||
				user = gajim.contacts[account][jid][0]
 | 
									user = gajim.contacts[account][jid][0]
 | 
				
			||||||
				if old_name in user.groups:
 | 
									if old_name in user.groups:
 | 
				
			||||||
					#set them in the new one and remove it from the old
 | 
										#set them in the new one and remove it from the old
 | 
				
			||||||
					self.remove_user(user, account)
 | 
										self.remove_contact(user, account)
 | 
				
			||||||
					user.groups.remove(old_name)
 | 
										user.groups.remove(old_name)
 | 
				
			||||||
					user.groups.append(new_text)
 | 
										user.groups.append(new_text)
 | 
				
			||||||
					self.add_contact_to_roster(user.jid, account)
 | 
										self.add_contact_to_roster(user.jid, account)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,6 +117,10 @@ class TabbedChatWindow(chat.Chat):
 | 
				
			||||||
			'<','<')
 | 
								'<','<')
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		jid = contact.jid
 | 
							jid = contact.jid
 | 
				
			||||||
 | 
							status = contact.status
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if status is None:
 | 
				
			||||||
 | 
								status = ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		#FIXME: uncomment me when we support sending messages to specific resource
 | 
							#FIXME: uncomment me when we support sending messages to specific resource
 | 
				
			||||||
		# composing full jid
 | 
							# composing full jid
 | 
				
			||||||
| 
						 | 
					@ -128,10 +132,10 @@ class TabbedChatWindow(chat.Chat):
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if chatstate:
 | 
							if chatstate:
 | 
				
			||||||
			label_text = '<span weight="heavy" size="x-large">%s</span> (chat state: %s)\n%s' \
 | 
								label_text = '<span weight="heavy" size="x-large">%s</span> (chat state: %s)\n%s' \
 | 
				
			||||||
				% (name, chatstate, jid)
 | 
									% (name, chatstate, status)
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
 | 
								label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
 | 
				
			||||||
				% (name, jid)
 | 
									% (name, status)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# setup the label that holds name and jid
 | 
							# setup the label that holds name and jid
 | 
				
			||||||
		banner_name_label = self.xmls[jid].get_widget('banner_name_label')
 | 
							banner_name_label = self.xmls[jid].get_widget('banner_name_label')
 | 
				
			||||||
| 
						 | 
					@ -294,12 +298,6 @@ class TabbedChatWindow(chat.Chat):
 | 
				
			||||||
		self.redraw_tab(contact.jid)
 | 
							self.redraw_tab(contact.jid)
 | 
				
			||||||
		self.draw_widgets(contact)
 | 
							self.draw_widgets(contact)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		uf_show = helpers.get_uf_show(contact.show)
 | 
					 | 
				
			||||||
		s = _('%s is %s') % (contact.name, uf_show)
 | 
					 | 
				
			||||||
		if contact.status:
 | 
					 | 
				
			||||||
			s += ' (' + contact.status + ')'
 | 
					 | 
				
			||||||
		self.print_conversation(s, contact.jid, 'status')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		#restore previous conversation
 | 
							#restore previous conversation
 | 
				
			||||||
		self.restore_conversation(contact.jid)
 | 
							self.restore_conversation(contact.jid)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -567,7 +565,7 @@ class TabbedChatWindow(chat.Chat):
 | 
				
			||||||
		if (user.show == 'offline' or user.show == 'error') and \
 | 
							if (user.show == 'offline' or user.show == 'error') and \
 | 
				
			||||||
			not showOffline:
 | 
								not showOffline:
 | 
				
			||||||
			if len(gajim.contacts[self.account][jid]) == 1:
 | 
								if len(gajim.contacts[self.account][jid]) == 1:
 | 
				
			||||||
				self.plugin.roster.really_remove_user(user, self.account)
 | 
									self.plugin.roster.really_remove_contact(user, self.account)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def print_conversation(self, text, jid, contact = '', tim = None,
 | 
						def print_conversation(self, text, jid, contact = '', tim = None,
 | 
				
			||||||
		encrypted = False, subject = None):
 | 
							encrypted = False, subject = None):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue