cleaning up crypto targets when conference member is getting removed
This commit is contained in:
		
							parent
							
								
									b48bf39e08
								
							
						
					
					
						commit
						4c6ef3b24e
					
				| @ -624,6 +624,15 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece | |||||||
| 							mXmppConnectionService.getAvatarService().clear(conversation); | 							mXmppConnectionService.getAvatarService().clear(conversation); | ||||||
| 							mXmppConnectionService.updateMucRosterUi(); | 							mXmppConnectionService.updateMucRosterUi(); | ||||||
| 							mXmppConnectionService.updateConversationUi(); | 							mXmppConnectionService.updateConversationUi(); | ||||||
|  | 							if (!user.getAffiliation().ranks(MucOptions.Affiliation.MEMBER)) { | ||||||
|  | 								Jid jid = user.getRealJid(); | ||||||
|  | 								List<Jid> cryptoTargets = conversation.getAcceptedCryptoTargets(); | ||||||
|  | 								if (cryptoTargets.remove(user.getRealJid())) { | ||||||
|  | 									Log.d(Config.LOGTAG,account.getJid().toBareJid()+": removed "+jid+" from crypto targets of "+conversation.getName()); | ||||||
|  | 									conversation.setAcceptedCryptoTargets(cryptoTargets); | ||||||
|  | 									mXmppConnectionService.updateConversation(conversation); | ||||||
|  | 								} | ||||||
|  | 							} | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
|  | |||||||
| @ -55,6 +55,7 @@ import java.util.HashSet; | |||||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||||
| import java.util.Iterator; | import java.util.Iterator; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.ListIterator; | ||||||
| import java.util.Locale; | import java.util.Locale; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.concurrent.CopyOnWriteArrayList; | import java.util.concurrent.CopyOnWriteArrayList; | ||||||
| @ -2140,6 +2141,7 @@ public class XmppConnectionService extends Service { | |||||||
| 		OnIqPacketReceived callback = new OnIqPacketReceived() { | 		OnIqPacketReceived callback = new OnIqPacketReceived() { | ||||||
| 
 | 
 | ||||||
| 			private int i = 0; | 			private int i = 0; | ||||||
|  | 			private boolean success = true; | ||||||
| 
 | 
 | ||||||
| 			@Override | 			@Override | ||||||
| 			public void onIqPacketReceived(Account account, IqPacket packet) { | 			public void onIqPacketReceived(Account account, IqPacket packet) { | ||||||
| @ -2155,10 +2157,28 @@ public class XmppConnectionService extends Service { | |||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| 				} else { | 				} else { | ||||||
|  | 					success = false; | ||||||
| 					Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not request affiliation "+affiliations[i]+" in "+conversation.getJid().toBareJid()); | 					Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not request affiliation "+affiliations[i]+" in "+conversation.getJid().toBareJid()); | ||||||
| 				} | 				} | ||||||
| 				++i; | 				++i; | ||||||
| 				if (i >= affiliations.length) { | 				if (i >= affiliations.length) { | ||||||
|  | 					List<Jid> members = conversation.getMucOptions().getMembers(); | ||||||
|  | 					if (success) { | ||||||
|  | 						List<Jid> cryptoTargets = conversation.getAcceptedCryptoTargets(); | ||||||
|  | 						boolean changed = false; | ||||||
|  | 						for(ListIterator<Jid> iterator = cryptoTargets.listIterator(); iterator.hasNext();) { | ||||||
|  | 							Jid jid = iterator.next(); | ||||||
|  | 							if (!members.contains(jid)) { | ||||||
|  | 								iterator.remove(); | ||||||
|  | 								Log.d(Config.LOGTAG,account.getJid().toBareJid()+": removed "+jid+" from crypto targets of "+conversation.getName()); | ||||||
|  | 								changed = true; | ||||||
|  | 							} | ||||||
|  | 						} | ||||||
|  | 						if (changed) { | ||||||
|  | 							conversation.setAcceptedCryptoTargets(cryptoTargets); | ||||||
|  | 							updateConversation(conversation); | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
| 					Log.d(Config.LOGTAG,account.getJid().toBareJid()+": retrieved members for "+conversation.getJid().toBareJid()+": "+conversation.getMucOptions().getMembers()); | 					Log.d(Config.LOGTAG,account.getJid().toBareJid()+": retrieved members for "+conversation.getJid().toBareJid()+": "+conversation.getMucOptions().getMembers()); | ||||||
| 					getAvatarService().clear(conversation); | 					getAvatarService().clear(conversation); | ||||||
| 					updateMucRosterUi(); | 					updateMucRosterUi(); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch