ability to block all contacts (from privacy list editor). Fixes #4831
This commit is contained in:
		
							parent
							
								
									d6095b6bab
								
							
						
					
					
						commit
						5834a2ae82
					
				
					 5 changed files with 28 additions and 16 deletions
				
			
		|  | @ -154,6 +154,7 @@ class Connection(ConnectionHandlers): | |||
| 		self.blocked_list = [] | ||||
| 		self.blocked_contacts = [] | ||||
| 		self.blocked_groups = [] | ||||
| 		self.blocked_all = False | ||||
| 		self.music_track_info = 0 | ||||
| 		self.pep_supported = False | ||||
| 		self.mood = {} | ||||
|  |  | |||
|  | @ -1287,4 +1287,12 @@ def update_optional_features(account = None): | |||
| 			gajim.connections[a].change_status(gajim.SHOW_LIST[connected], | ||||
| 				gajim.connections[a].status) | ||||
| 
 | ||||
| def jid_is_blocked(account, jid): | ||||
| 	return ((jid in gajim.connections[account].blocked_contacts) or \ | ||||
| 		gajim.connections[account].blocked_all) | ||||
| 
 | ||||
| def group_is_blocked(account, group): | ||||
| 	return ((group in gajim.connections[account].blocked_groups) or \ | ||||
| 		gajim.connections[account].blocked_all) | ||||
| 
 | ||||
| # vim: se ts=3: | ||||
|  |  | |||
|  | @ -1948,7 +1948,7 @@ class Interface: | |||
| 			self.instances[account]['privacy_lists'].privacy_lists_received(data) | ||||
| 
 | ||||
| 	def handle_event_privacy_list_received(self, account, data): | ||||
| 		# ('PRIVACY_LISTS_RECEIVED', account, (name, rules)) | ||||
| 		# ('PRIVACY_LIST_RECEIVED', account, (name, rules)) | ||||
| 		if account not in self.instances: | ||||
| 			return | ||||
| 		name = data[0] | ||||
|  | @ -1960,10 +1960,13 @@ class Interface: | |||
| 			gajim.connections[account].blocked_contacts = [] | ||||
| 			gajim.connections[account].blocked_groups = [] | ||||
| 			gajim.connections[account].blocked_list = [] | ||||
| 			gajim.connections[account].blocked_all = False | ||||
| 			for rule in rules: | ||||
| 				if rule['type'] == 'jid' and rule['action'] == 'deny': | ||||
| 				if not 'type' in rule: | ||||
| 					gajim.connections[account].blocked_all = True | ||||
| 				elif rule['type'] == 'jid' and rule['action'] == 'deny': | ||||
| 					gajim.connections[account].blocked_contacts.append(rule['value']) | ||||
| 				if rule['type'] == 'group' and rule['action'] == 'deny': | ||||
| 				elif rule['type'] == 'group' and rule['action'] == 'deny': | ||||
| 					gajim.connections[account].blocked_groups.append(rule['value']) | ||||
| 				gajim.connections[account].blocked_list.append(rule) | ||||
| 				#elif rule['type'] == "group" and action == "deny": | ||||
|  |  | |||
|  | @ -1017,7 +1017,7 @@ class RosterWindow: | |||
| 		else: | ||||
| 			accounts = [account] | ||||
| 		text = gobject.markup_escape_text(group) | ||||
| 		if group in gajim.connections[account].blocked_groups: | ||||
| 		if helpers.group_is_blocked(account, group): | ||||
| 			text = '<span strikethrough="true">%s</span>' % text | ||||
| 		if gajim.config.get('show_contacts_number'): | ||||
| 			nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( | ||||
|  | @ -1070,11 +1070,11 @@ class RosterWindow: | |||
| 
 | ||||
| 		# Strike name if blocked | ||||
| 		strike = False | ||||
| 		if jid in gajim.connections[account].blocked_contacts: | ||||
| 		if helpers.jid_is_blocked(account, jid): | ||||
| 			strike = True | ||||
| 		else: | ||||
| 			for group in contact.get_shown_groups(): | ||||
| 				if group in gajim.connections[account].blocked_groups: | ||||
| 				if helpers.group_is_blocked(account, group): | ||||
| 					strike = True | ||||
| 					break | ||||
| 		if strike: | ||||
|  | @ -5109,7 +5109,7 @@ class RosterWindow: | |||
| 			send_custom_status_menuitem = gtk.ImageMenuItem( | ||||
| 				_('Send Cus_tom Status')) | ||||
| 			# add a special img for this menuitem | ||||
| 			if group in gajim.connections[account].blocked_groups: | ||||
| 			if helpers.group_is_blocked(account, group): | ||||
| 				send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon( | ||||
| 					'offline')) | ||||
| 				send_custom_status_menuitem.set_sensitive(False) | ||||
|  | @ -5157,10 +5157,10 @@ class RosterWindow: | |||
| 			is_blocked = False | ||||
| 			if self.regroup: | ||||
| 				for g_account in gajim.connections: | ||||
| 					if group in gajim.connections[g_account].blocked_groups: | ||||
| 					if helpers.group_is_blocked(g_account, group): | ||||
| 						is_blocked = True | ||||
| 			else: | ||||
| 				if group in gajim.connections[account].blocked_groups: | ||||
| 				if helpers.group_is_blocked(account, group): | ||||
| 					is_blocked = True | ||||
| 
 | ||||
| 			if is_blocked and gajim.connections[account].privacy_rules_supported: | ||||
|  | @ -5366,11 +5366,11 @@ class RosterWindow: | |||
| 
 | ||||
| 		# send custom status icon | ||||
| 		blocked = False | ||||
| 		if jid in gajim.connections[account].blocked_contacts: | ||||
| 		if helpers.jid_is_blocked(account, jid): | ||||
| 			blocked = True | ||||
| 		else: | ||||
| 			for group in contact.get_shown_groups(): | ||||
| 				if group in gajim.connections[account].blocked_groups: | ||||
| 				if helpers.group_is_blocked(account, group): | ||||
| 					blocked = True | ||||
| 					break | ||||
| 		if gajim.get_transport_name_from_jid(jid, use_config_setting=False): | ||||
|  | @ -5535,7 +5535,7 @@ class RosterWindow: | |||
| 
 | ||||
| 		if gajim.connections[account] and gajim.connections[account].\ | ||||
| 		privacy_rules_supported: | ||||
| 			if jid in gajim.connections[account].blocked_contacts: | ||||
| 			if helpers.jid_is_blocked(account, jid): | ||||
| 				block_menuitem.set_no_show_all(True) | ||||
| 				block_menuitem.hide() | ||||
| 				if gajim.get_transport_name_from_jid(jid, use_config_setting=False): | ||||
|  | @ -5589,7 +5589,7 @@ class RosterWindow: | |||
| 				privacy_rules_supported = False | ||||
| 			contact = gajim.contacts.get_contact_with_highest_priority(account, | ||||
| 				jid) | ||||
| 			if jid not in gajim.connections[account].blocked_contacts: | ||||
| 			if helpers.jid_is_blocked(account, jid): | ||||
| 				is_blocked = False | ||||
| 			list_.append((contact, account)) | ||||
| 
 | ||||
|  | @ -5691,7 +5691,7 @@ class RosterWindow: | |||
| 		menu.append(item) | ||||
| 
 | ||||
| 		blocked = False | ||||
| 		if jid in gajim.connections[account].blocked_contacts: | ||||
| 		if helpers.jid_is_blocked(account, jid): | ||||
| 			blocked = True | ||||
| 
 | ||||
| 		# Send Custom Status | ||||
|  |  | |||
|  | @ -427,8 +427,8 @@ class RosterTooltip(NotificationAreaTooltip): | |||
| 		name_markup = u'<span weight="bold">' + \ | ||||
| 			gobject.markup_escape_text(prim_contact.get_shown_name())\ | ||||
| 			+ '</span>' | ||||
| 		if self.account and prim_contact.jid in gajim.connections[ | ||||
| 		self.account].blocked_contacts: | ||||
| 		if self.account and helpers.jid_is_blocked(self.account, | ||||
| 		prim_contact.jid): | ||||
| 			name_markup += _(' [blocked]') | ||||
| 		if self.account and \ | ||||
| 		self.account in gajim.interface.minimized_controls and \ | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue