From a9999eedeef4bd233256d5e15069ebc654675a68 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Tue, 25 Oct 2011 13:50:57 +0000 Subject: [PATCH] Changes sip status dispatching behaviour (basic closed status, sets to offline even if we have additional presence info). --- .../sip/OperationSetPresenceSipImpl.java | 83 ++++--------------- 1 file changed, 18 insertions(+), 65 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java index eb17f3fc4..474d8b5a6 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java @@ -1852,19 +1852,6 @@ ContactSipImpl resolveContactID(String contactID) */ Document createDocument() { -// try -// { -// if (this.docBuilderFactory == null) -// this.docBuilderFactory = DocumentBuilderFactory.newInstance(); -// if (this.docBuilder == null) -// this.docBuilder = this.docBuilderFactory.newDocumentBuilder(); -// } -// catch (Exception e) -// { -// logger.error("can't create the new xml document", e); -// return null; -// } -// return this.docBuilder.newDocument(); try { return XMLUtils.createDocument(); @@ -1886,23 +1873,6 @@ Document createDocument() */ String convertDocument(Document document) { -// DOMSource source = new DOMSource(document); -// StringWriter stringWriter = new StringWriter(); -// StreamResult result = new StreamResult(stringWriter); -// try -// { -// if (this.transFactory == null) -// this.transFactory = TransformerFactory.newInstance(); -// if (this.transformer == null) -// this.transformer = this.transFactory.newTransformer(); -// this.transformer.transform(source, result); -// } -// catch (Exception e) -// { -// logger.error("can't convert the xml document into a string", e); -// return null; -// } -// return stringWriter.toString(); try { return XMLUtils.createXml(document); @@ -1924,26 +1894,6 @@ String convertDocument(Document document) */ Document convertDocument(String document) { -// StringReader reader = new StringReader(document); -// StreamSource source = new StreamSource(reader); -// Document doc = createDocument(); -// if (doc == null) -// return null; -// DOMResult result = new DOMResult(doc); -// try -// { -// if (this.transFactory == null) -// this.transFactory = TransformerFactory.newInstance(); -// if (this.transformer == null) -// this.transformer = this.transFactory.newTransformer(); -// this.transformer.transform(source, result); -// } -// catch (Exception e) -// { -// logger.error("can't convert the string into a xml document", e); -// return null; -// } -// return doc; try { return XMLUtils.createDocument(document); @@ -2332,7 +2282,7 @@ else if (statusname.equals(OTP_ELEMENT)) { Object[] tmp = sipcontact.get(k); - if (((Contact) tmp[0]).equals(tmpContact)) + if (tmp[0].equals(tmpContact)) { contactAlreadyListed = true; @@ -2362,16 +2312,6 @@ else if (statusname.equals(OTP_ELEMENT)) continue; } - // if we use RPID, simply ignore the standard PIDF status - if (personStatus != null) - { - newPresenceStates = setStatusForContacts( - personStatus, - sipcontact, - newPresenceStates); - continue; - } - // NodeList statusList = getPidfChilds(tuple, STATUS_ELEMENT); @@ -2470,14 +2410,27 @@ else if (statusname.equals(OTP_ELEMENT)) { if (getTextContent(basic).equalsIgnoreCase(ONLINE_STATUS)) { - newPresenceStates = setStatusForContacts( - sipStatusEnum.getStatus(SipStatusEnum.ONLINE), - sipcontact, - newPresenceStates); + // if its online(open) we use the person status + // if any, otherwise just mark as online + if(personStatus != null) + { + newPresenceStates = setStatusForContacts( + personStatus, + sipcontact, + newPresenceStates); + } + else + { + newPresenceStates = setStatusForContacts( + sipStatusEnum.getStatus(SipStatusEnum.ONLINE), + sipcontact, + newPresenceStates); + } } else if (getTextContent(basic).equalsIgnoreCase( OFFLINE_STATUS)) { + // if its offline we ignore person status newPresenceStates = setStatusForContacts( sipStatusEnum.getStatus(SipStatusEnum.OFFLINE), sipcontact,