aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2010-06-14 09:59:49 +0000
committerDamian Minkov <damencho@jitsi.org>2010-06-14 09:59:49 +0000
commit1d107272cec4fbfca0c23307b00d4bff64dade29 (patch)
tree83e3e2fbd53496acc0515a42203d36ac374a5517 /src/net/java/sip/communicator
parent7ebed9c6a99d660b0acf01767ea4faef74c89d9f (diff)
downloadjitsi-1d107272cec4fbfca0c23307b00d4bff64dade29.zip
jitsi-1d107272cec4fbfca0c23307b00d4bff64dade29.tar.gz
jitsi-1d107272cec4fbfca0c23307b00d4bff64dade29.tar.bz2
Add standby detection and handling in reconnect plugin. Fix some more root group contacts handling in SIP protocol.
Diffstat (limited to 'src/net/java/sip/communicator')
-rw-r--r--src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java36
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java74
2 files changed, 106 insertions, 4 deletions
diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java b/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
index d071fc8..fcd08d3 100644
--- a/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
+++ b/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
@@ -91,8 +91,42 @@ public class NetworkConfigurationWatcher
{
long curr = System.currentTimeMillis();
+ // if time spent between checks is more than 2 times
+ // longer than the check interval we consider it as a
+ // new check after standby
if(!isAfterStandby && last != 0)
- isAfterStandby = (last + CHECK_INTERVAL + 100 - curr) < 0;
+ isAfterStandby = (last + 2*CHECK_INTERVAL - curr) < 0;
+
+ if(isAfterStandby)
+ {
+ // oo standby lets fire down to all interfaces
+ // so they can reconnect
+ Iterator<NetworkInterface> iter = activeInterfaces.iterator();
+ while (iter.hasNext())
+ {
+ NetworkInterface niface = iter.next();
+ fireChangeEvent(new ChangeEvent(niface,
+ ChangeEvent.IFACE_DOWN, isAfterStandby));
+ }
+ activeInterfaces.clear();
+
+ // we have fired events for standby, make it to false now
+ // so we can calculate it again next time
+ isAfterStandby = false;
+
+ last = curr;
+
+ // give time to interfaces
+ synchronized(this)
+ {
+ try{
+ wait(CHECK_INTERVAL);
+ }
+ catch (Exception e){}
+ }
+
+ continue;
+ }
try
{
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 24a22f8..dd01de0 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java
@@ -2562,9 +2562,27 @@ public class OperationSetPresenceSipImpl
logger.debug("trying to unsubscribe to every contact");
// send event notifications saying that all our buddies are
- // offline. SIMPLE does not implement top level buddies
- // nor subgroups for top level groups so a simple nested loop
- // is enough.
+ // offline.
+ Iterator<Contact> rootContactsIter
+ = getServerStoredContactListRoot().contacts();
+
+ while (rootContactsIter.hasNext())
+ {
+ ContactSipImpl contact = (ContactSipImpl) rootContactsIter.next();
+
+ try
+ {
+ unsubscribe(contact, false);
+ }
+ catch (OperationFailedException ex)
+ {
+ logger.error(
+ "Failed to unsubscribe to contact " + contact,
+ ex);
+ return;
+ }
+ }
+
Iterator<ContactGroup> groupsIter
= getServerStoredContactListRoot().subgroups();
@@ -2676,6 +2694,18 @@ public class OperationSetPresenceSipImpl
public void run()
{
// send a subscription for every contact
+ Iterator<Contact> rootContactsIter
+ = getServerStoredContactListRoot().contacts();
+
+ while (rootContactsIter.hasNext())
+ {
+ ContactSipImpl contact =
+ (ContactSipImpl) rootContactsIter.next();
+
+ // poll this contact
+ forcePollContact(contact);
+ }
+
Iterator<ContactGroup> groupsIter
= getServerStoredContactListRoot().subgroups();
@@ -2828,6 +2858,44 @@ public class OperationSetPresenceSipImpl
{
// if connection failed we have lost network connectivity
// we must fire that all contacts has gone offline
+ Iterator<Contact> rootcontactsIter
+ = getServerStoredContactListRoot().contacts();
+
+ while(rootcontactsIter.hasNext())
+ {
+ ContactSipImpl contact
+ = (ContactSipImpl)rootcontactsIter.next();
+
+ PresenceStatus oldContactStatus
+ = contact.getPresenceStatus();
+
+ contact.setResolved(false);
+ if (subscriber != null)
+ try
+ {
+ subscriber
+ .removeSubscription(getAddress(contact));
+ }
+ catch (OperationFailedException ex)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug(
+ "Failed to remove subscription to contact "
+ + contact);
+ }
+
+ if(!oldContactStatus.isOnline())
+ continue;
+
+ contact.setPresenceStatus(
+ sipStatusEnum.getStatus(SipStatusEnum.OFFLINE));
+
+ fireContactPresenceStatusChangeEvent(
+ contact
+ , contact.getParentContactGroup()
+ , oldContactStatus);
+ }
+
Iterator<ContactGroup> groupsIter
= getServerStoredContactListRoot().subgroups();