aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/util
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2014-03-14 16:59:32 +0200
committerDamian Minkov <damencho@jitsi.org>2014-03-14 17:02:18 +0200
commit0bf621360b14a0060a4cded64d3168ed95394524 (patch)
tree298a611156aaa3c33c5af3d97937c6639fa0bb94 /src/net/java/sip/communicator/util
parentac886ebbed3606140f5ec7806399558a48345c30 (diff)
downloadjitsi-0bf621360b14a0060a4cded64d3168ed95394524.zip
jitsi-0bf621360b14a0060a4cded64d3168ed95394524.tar.gz
jitsi-0bf621360b14a0060a4cded64d3168ed95394524.tar.bz2
Fixes initial status set for protocols and UI to reflect changes.
Diffstat (limited to 'src/net/java/sip/communicator/util')
-rw-r--r--src/net/java/sip/communicator/util/account/AccountStatusUtils.java91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/util/account/AccountStatusUtils.java b/src/net/java/sip/communicator/util/account/AccountStatusUtils.java
index bc32980..728fc83 100644
--- a/src/net/java/sip/communicator/util/account/AccountStatusUtils.java
+++ b/src/net/java/sip/communicator/util/account/AccountStatusUtils.java
@@ -10,6 +10,8 @@ import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.globalstatus.*;
import net.java.sip.communicator.util.*;
+import java.util.*;
+
/**
* The <tt>AccountStatusUtils</tt> provides utility methods for account status
* management.
@@ -76,6 +78,95 @@ public class AccountStatusUtils
}
/**
+ * Returns the current status for protocol provider.
+ *
+ * @param protocolProvider the protocol provider
+ * @return the current status for protocol provider
+ */
+ public static PresenceStatus getPresenceStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ PresenceStatus status = null;
+
+ OperationSetPresence opSet
+ = protocolProvider.getOperationSet(OperationSetPresence.class);
+
+ if(opSet != null)
+ status = opSet.getPresenceStatus();
+
+ return status;
+ }
+
+ /**
+ * Returns the online status of provider.
+ * @param protocolProvider the protocol provider
+ * @return the online status of provider.
+ */
+ public static PresenceStatus getOnlineStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ PresenceStatus onlineStatus = null;
+
+ OperationSetPresence presence
+ = protocolProvider.getOperationSet(OperationSetPresence.class);
+
+ // presence can be not supported
+ if(presence != null)
+ {
+ Iterator<PresenceStatus> statusIterator
+ = presence.getSupportedStatusSet();
+ while (statusIterator.hasNext())
+ {
+ PresenceStatus status = statusIterator.next();
+ int connectivity = status.getStatus();
+
+ if ((onlineStatus != null
+ && (onlineStatus.getStatus() < connectivity))
+ || (onlineStatus == null
+ && (connectivity > 50 && connectivity < 80)))
+ {
+ onlineStatus = status;
+ }
+ }
+ }
+
+ return onlineStatus;
+ }
+
+ /**
+ * Returns the offline status of provider.
+ * @param protocolProvider the protocol provider
+ * @return the offline status of provider.
+ */
+ public static PresenceStatus getOfflineStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ PresenceStatus offlineStatus = null;
+
+ OperationSetPresence presence
+ = protocolProvider.getOperationSet(OperationSetPresence.class);
+
+ // presence can be not supported
+ if(presence != null)
+ {
+ Iterator<PresenceStatus> statusIterator
+ = presence.getSupportedStatusSet();
+ while (statusIterator.hasNext())
+ {
+ PresenceStatus status = statusIterator.next();
+ int connectivity = status.getStatus();
+
+ if (connectivity < 1)
+ {
+ offlineStatus = status;
+ }
+ }
+ }
+
+ return offlineStatus;
+ }
+
+ /**
* Returns the last contact status saved in the configuration.
*
* @param protocolProvider the protocol provider to which the status