From d8c4b9f96a818955843f5339b03bca4ea1513cd7 Mon Sep 17 00:00:00 2001 From: Benoit Pradelle Date: Thu, 26 Jul 2007 10:46:37 +0000 Subject: [PATCH] new SIMPLE status (online, away, busy, on the phone and offline) + still trying to reduce the abnormal test failures --- .../sip/OperationSetPresenceSipImpl.java | 58 +++++++++---------- .../impl/protocol/sip/SipStatusEnum.java | 22 +++++-- .../sip/TestOperationSetPresence.java | 2 +- 3 files changed, 45 insertions(+), 37 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 8cbddeae1..c3e4cfd0a 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java @@ -221,6 +221,8 @@ public class OperationSetPresenceSipImpl private static final String NS_AWAY_ELT = "rpid:away"; private static final String BUSY_ELEMENT = "busy"; private static final String NS_BUSY_ELT = "rpid:busy"; + private static final String OTP_ELEMENT = "on-the-phone"; + private static final String NS_OTP_ELT = "rpid:on-the-phone"; /** * Creates an instance of this operation set keeping a reference to the @@ -3513,11 +3515,14 @@ public byte[] getPidfPresenceStatus(ContactSipImpl contact) if (contact.getPresenceStatus().equals(SipStatusEnum.AWAY)) { Element away = doc.createElement(NS_AWAY_ELT); activities.appendChild(away); - } else if (contact.getPresenceStatus() - .equals(SipStatusEnum.DO_NOT_DISTURB)) - { + } else if (contact.getPresenceStatus().equals(SipStatusEnum.BUSY)) { Element busy = doc.createElement(NS_BUSY_ELT); activities.appendChild(busy); + } else if (contact.getPresenceStatus() + .equals(SipStatusEnum.ON_THE_PHONE)) + { + Element otp = doc.createElement(NS_OTP_ELT); + activities.appendChild(otp); } // @@ -3632,20 +3637,18 @@ public void setPidfPresenceStatus(String presenceDoc) continue; } - if (activityNode.getNodeName().equals(AWAY_ELEMENT) - || activityNode.getNodeName().equals(BUSY_ELEMENT)) - { - activity = (Element) activityNode; - break; - } - } - - // convert the activity in a SC status - if (activity != null) { + activity = (Element) activityNode; + + // convert the activity in a SC status if (activity.getNodeName().equals(AWAY_ELEMENT)) { personStatus = SipStatusEnum.AWAY; + break; } else if (activity.getNodeName().equals(BUSY_ELEMENT)) { - personStatus = SipStatusEnum.DO_NOT_DISTURB; + personStatus = SipStatusEnum.BUSY; + break; + } else if (activity.getNodeName().equals(OTP_ELEMENT)) { + personStatus = SipStatusEnum.ON_THE_PHONE; + break; } } } @@ -3764,22 +3767,17 @@ public void setPidfPresenceStatus(String presenceDoc) Element note = (Element) noteNode; String state = getTextContent(note); - - // away ? - if (state.equalsIgnoreCase(SipStatusEnum.AWAY - .getStatusName())) - { - changed = true; - changePresenceStatusForContact(sipcontact, - SipStatusEnum.AWAY); - } - // do not disturb ? - else if (state.equalsIgnoreCase( - SipStatusEnum.DO_NOT_DISTURB.getStatusName())) - { - changed = true; - changePresenceStatusForContact(sipcontact, - SipStatusEnum.DO_NOT_DISTURB); + + Iterator states = SipStatusEnum.supportedStatusSet(); + while (states.hasNext()) { + SipStatusEnum current = (SipStatusEnum) states.next(); + + if (current.getStatusName().equalsIgnoreCase(state)) { + changed = true; + changePresenceStatusForContact(sipcontact, + current); + break; + } } } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java b/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java index 2a2305406..7ad787a50 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java @@ -34,13 +34,22 @@ public class SipStatusEnum , loadIcon("resources/images/sip/sip16x16-offline.png")); /** - * The DND status. Indicates that the user has connectivity but prefers - * not to be contacted. + * The busy status. Indicates that the user has connectivity but is doing + * something else. */ - public static final SipStatusEnum DO_NOT_DISTURB + public static final SipStatusEnum BUSY = new SipStatusEnum( - 30 - , "Do Not Disturb", + 30, + "Busy", + loadIcon("resources/images/sip/sip16x16-dnd.png")); + + /** + * The On the phone status. Indicates that the user is talking to the phone. + */ + public static final SipStatusEnum ON_THE_PHONE + = new SipStatusEnum( + 37, + "On the phone", loadIcon("resources/images/sip/sip16x16-dnd.png")); /** @@ -79,8 +88,9 @@ public class SipStatusEnum static { supportedStatusSet.add(ONLINE); - supportedStatusSet.add(DO_NOT_DISTURB); supportedStatusSet.add(AWAY); + supportedStatusSet.add(ON_THE_PHONE); + supportedStatusSet.add(BUSY); supportedStatusSet.add(OFFLINE); } diff --git a/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetPresence.java b/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetPresence.java index b32e464e1..7b1106715 100644 --- a/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetPresence.java +++ b/test/net/java/sip/communicator/slick/protocol/sip/TestOperationSetPresence.java @@ -275,7 +275,7 @@ private void pauseAfterStateChanges() { try { - Thread.currentThread().sleep(1500); + Thread.currentThread().sleep(2000); } catch (InterruptedException ex) {