parse all delayed tags. use min date
This commit is contained in:
		
							parent
							
								
									e973117aed
								
							
						
					
					
						commit
						6ccdd1227e
					
				| @ -22,19 +22,27 @@ public abstract class AbstractParser { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public static Long parseTimestamp(Element element, Long d) { | 	public static Long parseTimestamp(Element element, Long d) { | ||||||
| 		Element delay = element.findChild("delay","urn:xmpp:delay"); | 		long min = Long.MAX_VALUE; | ||||||
| 		if (delay != null) { | 		boolean returnDefault = true; | ||||||
| 			String stamp = delay.getAttribute("stamp"); | 		for(Element child : element.getChildren()) { | ||||||
|  | 			if ("delay".equals(child.getName()) && "urn:xmpp:delay".equals(child.getNamespace())) { | ||||||
|  | 				String stamp = child.getAttribute("stamp"); | ||||||
| 				if (stamp != null) { | 				if (stamp != null) { | ||||||
| 					try { | 					try { | ||||||
| 					return AbstractParser.parseTimestamp(delay.getAttribute("stamp")); | 						min = Math.min(min,AbstractParser.parseTimestamp(stamp)); | ||||||
|  | 						returnDefault = false; | ||||||
| 					} catch (ParseException e) { | 					} catch (ParseException e) { | ||||||
|  | 						//ignore | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		if (returnDefault) { | ||||||
| 			return d; | 			return d; | ||||||
|  | 		} else { | ||||||
|  | 			return min; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 		} |  | ||||||
| 		return d; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	public static long parseTimestamp(Element element) { | 	public static long parseTimestamp(Element element) { | ||||||
| 		return parseTimestamp(element, System.currentTimeMillis()); | 		return parseTimestamp(element, System.currentTimeMillis()); | ||||||
|  | |||||||
| @ -215,12 +215,14 @@ public class PresenceParser extends AbstractParser implements | |||||||
| 
 | 
 | ||||||
| 			final Element idle = packet.findChild("idle", Namespace.IDLE); | 			final Element idle = packet.findChild("idle", Namespace.IDLE); | ||||||
| 			if (idle != null) { | 			if (idle != null) { | ||||||
| 				contact.flagInactive(); |  | ||||||
| 				final String since = idle.getAttribute("since"); |  | ||||||
| 				try { | 				try { | ||||||
|  | 					final String since = idle.getAttribute("since"); | ||||||
| 					contact.setLastseen(AbstractParser.parseTimestamp(since)); | 					contact.setLastseen(AbstractParser.parseTimestamp(since)); | ||||||
|  | 					contact.flagInactive(); | ||||||
| 				} catch (NullPointerException | ParseException e) { | 				} catch (NullPointerException | ParseException e) { | ||||||
| 					contact.setLastseen(System.currentTimeMillis()); | 					if (contact.setLastseen(AbstractParser.parseTimestamp(packet))) { | ||||||
|  | 						contact.flagActive(); | ||||||
|  | 					} | ||||||
| 				} | 				} | ||||||
| 			} else { | 			} else { | ||||||
| 				if (contact.setLastseen(AbstractParser.parseTimestamp(packet))) { | 				if (contact.setLastseen(AbstractParser.parseTimestamp(packet))) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch