remove privacy list from dialog only when server return the result, else show an error dialog. fixes #2853
This commit is contained in:
		
							parent
							
								
									2f857047d3
								
							
						
					
					
						commit
						3567a8c20f
					
				
					 4 changed files with 22 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -561,7 +561,16 @@ class Connection(ConnectionHandlers):
 | 
			
		|||
	def del_privacy_list(self, privacy_list):
 | 
			
		||||
		if not self.connection:
 | 
			
		||||
			return
 | 
			
		||||
		common.xmpp.features_nb.delPrivacyList(self.connection, privacy_list)
 | 
			
		||||
		def _on_del_privacy_list_result(result):
 | 
			
		||||
			if result:
 | 
			
		||||
				self.dispatch('PRIVACY_LIST_REMOVED', privacy_list)
 | 
			
		||||
			else:
 | 
			
		||||
				self.dispatch('ERROR', (_('Error while removing privacy list'),
 | 
			
		||||
					_('Privacy list %s has not been removed. It is maybe active in '
 | 
			
		||||
					'one of your connected resources. Desactivate it and try '
 | 
			
		||||
					'again.') % privacy_list))
 | 
			
		||||
		common.xmpp.features_nb.delPrivacyList(self.connection, privacy_list,
 | 
			
		||||
			_on_del_privacy_list_result)
 | 
			
		||||
	
 | 
			
		||||
	def get_privacy_list(self, title):
 | 
			
		||||
		if not self.connection:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -249,7 +249,7 @@ def setPrivacyList(disp, listname, tags):
 | 
			
		|||
				item_tag.setTag(child_tag)
 | 
			
		||||
	_on_default_response(disp, iq, None)
 | 
			
		||||
 | 
			
		||||
def delPrivacyList(disp,listname):
 | 
			
		||||
def delPrivacyList(disp,listname,cb=None):
 | 
			
		||||
	""" Deletes privacy list 'listname'. Returns true on success."""
 | 
			
		||||
	iq = Iq('set',NS_PRIVACY,payload=[Node('list',{'name':listname})])
 | 
			
		||||
	_on_default_response(disp, iq, None)
 | 
			
		||||
	_on_default_response(disp, iq, cb)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2187,6 +2187,8 @@ class PrivacyListsWindow:
 | 
			
		|||
		active_list = self.privacy_lists_save[
 | 
			
		||||
			self.list_of_privacy_lists_combobox.get_active()]
 | 
			
		||||
		gajim.connections[self.account].del_privacy_list(active_list)
 | 
			
		||||
	
 | 
			
		||||
	def privacy_list_removed(self, active_list):
 | 
			
		||||
		self.privacy_lists_save.remove(active_list)
 | 
			
		||||
		self.privacy_lists_received({'lists': self.privacy_lists_save})
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1621,6 +1621,13 @@ class Interface:
 | 
			
		|||
			if win.startswith('privacy_list_'):
 | 
			
		||||
				self.instances[account][win].check_active_default(data)
 | 
			
		||||
 | 
			
		||||
	def handle_event_privacy_list_removed(self, account, name):
 | 
			
		||||
		# ('PRIVACY_LISTS_REMOVED', account, name)
 | 
			
		||||
		if not self.instances.has_key(account):
 | 
			
		||||
			return
 | 
			
		||||
		if self.instances[account].has_key('privacy_lists'):
 | 
			
		||||
			self.instances[account]['privacy_lists'].privacy_list_removed(name)
 | 
			
		||||
 | 
			
		||||
	def handle_event_zc_name_conflict(self, account, data):
 | 
			
		||||
		dlg = dialogs.InputDialog(_('Username Conflict'),
 | 
			
		||||
			_('Please type a new username for your local account'), 
 | 
			
		||||
| 
						 | 
				
			
			@ -1946,6 +1953,7 @@ class Interface:
 | 
			
		|||
			'PRIVACY_LIST_RECEIVED': self.handle_event_privacy_list_received,
 | 
			
		||||
			'PRIVACY_LISTS_ACTIVE_DEFAULT': \
 | 
			
		||||
				self.handle_event_privacy_lists_active_default,
 | 
			
		||||
			'PRIVACY_LIST_REMOVED': self.handle_event_privacy_list_removed,
 | 
			
		||||
			'ZC_NAME_CONFLICT': self.handle_event_zc_name_conflict,
 | 
			
		||||
		}
 | 
			
		||||
		gajim.handlers = self.handlers
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue