aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java492
-rwxr-xr-xsrc/net/java/sip/communicator/impl/protocol/jabber/JabberAccountID.java1
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java3
-rw-r--r--src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java9
-rw-r--r--src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java13
-rw-r--r--src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java55
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationForm.java2
-rw-r--r--src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java19
-rw-r--r--src/net/java/sip/communicator/service/netaddr/event/ChangeEvent.java89
-rw-r--r--src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java10
-rw-r--r--src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java2
-rw-r--r--src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java8
-rw-r--r--src/net/java/sip/communicator/util/NetworkUtils.java2
13 files changed, 592 insertions, 113 deletions
diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java b/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
index cf2ebca..b3c438c 100644
--- a/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
+++ b/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
@@ -24,7 +24,8 @@ import org.osgi.framework.*;
*/
public class NetworkConfigurationWatcher
implements SystemActivityChangeListener,
- ServiceListener
+ ServiceListener,
+ Runnable
{
/**
* Our class logger.
@@ -41,8 +42,18 @@ public class NetworkConfigurationWatcher
/**
* The current active interfaces.
*/
- private List<NetworkInterface> activeInterfaces
- = new ArrayList<NetworkInterface>();
+ private Map<String, List<InetAddress>> activeInterfaces
+ = new HashMap<String, List<InetAddress>>();
+
+ /**
+ * Interval between check of network configuration.
+ */
+ private static final int CHECK_INTERVAL = 3000; // 3 sec.
+
+ /**
+ * Whether thread checking for network notifications is running.
+ */
+ private boolean isRunning = false;
/**
* Service we use to listen for network changes.
@@ -55,7 +66,13 @@ public class NetworkConfigurationWatcher
*/
NetworkConfigurationWatcher()
{
- checkNetworkInterfaces(false);
+ try
+ {
+ checkNetworkInterfaces(false, 0);
+ } catch (SocketException e)
+ {
+ logger.error("Error checking network interfaces", e);
+ }
}
/**
@@ -68,17 +85,114 @@ public class NetworkConfigurationWatcher
{
synchronized(listeners)
{
- listeners.add(listener);
+ if(!listeners.contains(listener))
+ {
+ listeners.add(listener);
+
+ initialFireEvents(listener);
+ }
}
NetaddrActivator.getBundleContext().addServiceListener(this);
- this.systemActivityNotificationsService
- = ServiceUtils.getService(
- NetaddrActivator.getBundleContext(),
- SystemActivityNotificationsService.class);
- this.systemActivityNotificationsService
- .addSystemActivityChangeListener(this);
+ if(this.systemActivityNotificationsService == null)
+ {
+ SystemActivityNotificationsService systActService
+ = ServiceUtils.getService(
+ NetaddrActivator.getBundleContext(),
+ SystemActivityNotificationsService.class);
+
+ handleNewSystemActivityNotificationsService(systActService);
+ }
+ }
+
+ /**
+ * Used to fire initial events to newly added listers.
+ * @param listener the listener to fire.
+ */
+ private void initialFireEvents(
+ NetworkConfigurationChangeListener listener)
+ {
+ try
+ {
+ Enumeration<NetworkInterface> e =
+ NetworkInterface.getNetworkInterfaces();
+
+ while (e.hasMoreElements())
+ {
+ NetworkInterface networkInterface = e.nextElement();
+
+ if(isInterfaceLoopback(networkInterface))
+ continue;
+
+ // if interface is up and has some valid(non-local) address
+ // add it to currently active
+ if(isInterfaceUp(networkInterface))
+ {
+ Enumeration<InetAddress> as =
+ networkInterface.getInetAddresses();
+ boolean hasAddress = false;
+ while (as.hasMoreElements())
+ {
+ InetAddress inetAddress = as.nextElement();
+ if(inetAddress.isLinkLocalAddress())
+ continue;
+
+ hasAddress = true;
+ fireChangeEvent(
+ new ChangeEvent(
+ networkInterface.getName(),
+ ChangeEvent.ADDRESS_UP,
+ inetAddress,
+ false,
+ true),
+ listener);
+ }
+
+ if(hasAddress)
+ fireChangeEvent(
+ new ChangeEvent(networkInterface.getName(),
+ ChangeEvent.IFACE_UP, null, false, true),
+ listener);
+ }
+ }
+
+
+ } catch (SocketException e)
+ {
+ logger.error("Error checking network interfaces", e);
+ }
+ }
+
+ /**
+ * Saves the reference for the service and
+ * add a listener if the desired events are supported. Or start
+ * the checking thread otherwise.
+ * @param newService
+ */
+ private void handleNewSystemActivityNotificationsService(
+ SystemActivityNotificationsService newService)
+ {
+ this.systemActivityNotificationsService = newService;
+
+ if(this.systemActivityNotificationsService
+ .isSupported(SystemActivityEvent.EVENT_NETWORK_CHANGE))
+ {
+ this.systemActivityNotificationsService
+ .addSystemActivityChangeListener(this);
+ }
+ else
+ {
+ if(!isRunning)
+ {
+ isRunning = true;
+ Thread th = new Thread(this);
+ // set to max priority to prevent detecting sleep if the cpu is
+ // overloaded
+ th.setPriority(Thread.MAX_PRIORITY);
+ th.start();
+ }
+ }
}
/**
@@ -121,14 +235,12 @@ public class NetworkConfigurationWatcher
if(this.systemActivityNotificationsService != null)
break;
- this.systemActivityNotificationsService =
- (SystemActivityNotificationsService)sService;
- systemActivityNotificationsService
- .addSystemActivityChangeListener(this);
+ handleNewSystemActivityNotificationsService(
+ (SystemActivityNotificationsService)sService);
break;
case ServiceEvent.UNREGISTERING:
((SystemActivityNotificationsService)sService)
- .addSystemActivityChangeListener(this);
+ .removeSystemActivityChangeListener(this);
break;
}
@@ -148,43 +260,42 @@ public class NetworkConfigurationWatcher
{
NetworkConfigurationChangeListener nCChangeListener
= listeners.get(i);
- try
- {
- nCChangeListener.configurationChanged(evt);
- } catch (Throwable e)
- {
- logger.warn("Error delivering event:" + evt + ", to:"
- + nCChangeListener);
- }
+ fireChangeEvent(evt, nCChangeListener);
}
}
}
-
/**
- * Stop.
+ * Fire ChangeEvent.
+ * @param evt the event to fire.
*/
- void stop()
+ private void fireChangeEvent(ChangeEvent evt,
+ NetworkConfigurationChangeListener listener)
{
+ try
+ {
+ listener.configurationChanged(evt);
+ } catch (Throwable e)
+ {
+ logger.warn("Error delivering event:" + evt + ", to:"
+ + listener);
+ }
}
+
/**
- * Checks whether the supplied network interface name is in the list.
- * @param ifaces the list of interfaces.
- * @param name the name to check.
- * @return whether name is found in the list of interfaces.
+ * Stop.
*/
- private boolean containsInterfaceWithName(
- List<NetworkInterface> ifaces, String name)
+ void stop()
{
- for (int i = 0; i < ifaces.size(); i++)
+ if(isRunning)
{
- NetworkInterface networkInterface = ifaces.get(i);
- if(networkInterface.getName().equals(name))
- return true;
+ synchronized(this)
+ {
+ isRunning = false;
+ notifyAll();
+ }
}
-
- return false;
}
/**
@@ -268,99 +379,298 @@ public class NetworkConfigurationWatcher
return true;
}
+ /**
+ * This method gets called when a notification action for a particular event
+ * type has been changed. We are interested in sleep and network
+ * changed events.
+ *
+ * @param event the <tt>NotificationActionTypeEvent</tt>, which is
+ * dispatched when an action has been changed.
+ */
public void activityChanged(SystemActivityEvent event)
{
if(event.getEventID() == SystemActivityEvent.EVENT_SLEEP)
{
// 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, true));
- }
- activeInterfaces.clear();
+ downAllInterfaces();
}
else if(event.getEventID() == SystemActivityEvent.EVENT_NETWORK_CHANGE)
{
- checkNetworkInterfaces(true);
- }
- }
-
- private void checkNetworkInterfaces(boolean fireEvents)
- {
- try
- {
// when there is a net change
// give time for devices to come up/down fully
// before checking with them
synchronized(this)
{
try{
- wait(1000);
+ wait(3000);
}catch(InterruptedException ex){}
}
- Enumeration<NetworkInterface> e =
- NetworkInterface.getNetworkInterfaces();
+ try
+ {
+ checkNetworkInterfaces(true, 0);
+ } catch (SocketException e)
+ {
+ logger.error("Error checking network interfaces", e);
+ }
+ }
+ }
- List<NetworkInterface> currentActiveInterfaces =
- new ArrayList<NetworkInterface>();
+ /**
+ * Down all interfaces and fire events for it.
+ */
+ private void downAllInterfaces()
+ {
+ Iterator<String> iter = activeInterfaces.keySet().iterator();
+ while (iter.hasNext())
+ {
+ String niface = iter.next();
+ fireChangeEvent(new ChangeEvent(niface,
+ ChangeEvent.IFACE_DOWN, true));
+ }
+ activeInterfaces.clear();
+ }
- while (e.hasMoreElements())
- {
- NetworkInterface networkInterface = e.nextElement();
+ /**
+ * Checks current interfaces configuration against the last saved
+ * active interfaces.
+ * @param fireEvents whether we will fire events when we detect
+ * that interface is changed. When we start we query the interfaces
+ * just to check which are online, without firing events.
+ * @param waitBeforeFiringUpEvents milliseconds to wait before
+ * firing events for interfaces up, sometimes we must wait a little bit
+ * and give time for interfaces to configure fully (dns on linux).
+ */
+ private void checkNetworkInterfaces(
+ boolean fireEvents,
+ int waitBeforeFiringUpEvents)
+ throws SocketException
+ {
+ Enumeration<NetworkInterface> e =
+ NetworkInterface.getNetworkInterfaces();
- if(isInterfaceLoopback(networkInterface))
- continue;
+ Map<String, List<InetAddress>> currentActiveInterfaces =
+ new HashMap<String, List<InetAddress>>();
- // if interface is up and has some valid(non-local) address
- if(isInterfaceUp(networkInterface)
- && hasValidAddress(networkInterface))
+ while (e.hasMoreElements())
+ {
+ NetworkInterface networkInterface = e.nextElement();
+
+ if(isInterfaceLoopback(networkInterface))
+ continue;
+
+ // if interface is up and has some valid(non-local) address
+ // add it to currently active
+ if(isInterfaceUp(networkInterface))
+ {
+ List<InetAddress> addresses =
+ new ArrayList<InetAddress>();
+
+ Enumeration<InetAddress> as =
+ networkInterface.getInetAddresses();
+ while (as.hasMoreElements())
{
- currentActiveInterfaces.add(networkInterface);
+ InetAddress inetAddress = as.nextElement();
+ if(inetAddress.isLinkLocalAddress())
+ continue;
+
+ addresses.add(inetAddress);
}
+
+ if(addresses.size() > 0)
+ currentActiveInterfaces.put(
+ networkInterface.getName(), addresses);
}
+ }
- List<NetworkInterface> inactiveActiveInterfaces =
- new ArrayList<NetworkInterface>(activeInterfaces);
- inactiveActiveInterfaces.removeAll(currentActiveInterfaces);
+ // search for down interface
+ List<String> inactiveActiveInterfaces =
+ new ArrayList<String>(activeInterfaces.keySet());
+ List<String> currentActiveInterfacesSet
+ = new ArrayList<String>(currentActiveInterfaces.keySet());
+ inactiveActiveInterfaces.removeAll(currentActiveInterfacesSet);
- // fire that interface has gone down
- for (int i = 0; i < inactiveActiveInterfaces.size(); i++)
+ // fire that interface has gone down
+ for (int i = 0; i < inactiveActiveInterfaces.size(); i++)
+ {
+ String iface = inactiveActiveInterfaces.get(i);
+
+ if(!currentActiveInterfacesSet.contains(iface))
+ {
+ if(fireEvents)
+ fireChangeEvent(new ChangeEvent(iface,
+ ChangeEvent.IFACE_DOWN));
+
+ activeInterfaces.remove(iface);
+ }
+ }
+
+ // now look at the addresses of the connected interfaces
+ // if something has gown down
+ Iterator<Map.Entry<String, List<InetAddress>>>
+ activeEntriesIter = activeInterfaces.entrySet().iterator();
+ while(activeEntriesIter.hasNext())
+ {
+ Map.Entry<String, List<InetAddress>>
+ entry = activeEntriesIter.next();
+ Iterator<InetAddress> addrIter = entry.getValue().iterator();
+ while(addrIter.hasNext())
{
- NetworkInterface iface = inactiveActiveInterfaces.get(i);
+ InetAddress addr = addrIter.next();
+
+ // if address is missing in current active interfaces
+ // it means it has gone done
+ List<InetAddress> addresses =
+ currentActiveInterfaces.get(entry.getKey());
- if(!containsInterfaceWithName(
- currentActiveInterfaces, iface.getName()))
+ if(addresses != null && !addresses.contains(addr))
{
if(fireEvents)
- fireChangeEvent(new ChangeEvent(iface,
- ChangeEvent.IFACE_DOWN, false));
+ fireChangeEvent(
+ new ChangeEvent(entry.getKey(),
+ ChangeEvent.ADDRESS_DOWN, addr));
- activeInterfaces.remove(iface);
+ addrIter.remove();
}
}
+ }
- // now we leave with only with the new and up interfaces
- // in currentActiveInterfaces list
- currentActiveInterfaces.removeAll(activeInterfaces);
+ if(waitBeforeFiringUpEvents > 0
+ && currentActiveInterfaces.size() != 0)
+ {
+ // calm for a while, we sometimes receive those events and
+ // configuration has not yet finished (dns can be the old one)
+ synchronized(this)
+ {
+ try{
+ wait(1000);
+ }catch(InterruptedException ex){}
+ }
+ }
- // fire that interface has gone up
- for (int i = 0; i < currentActiveInterfaces.size(); i++)
+ // now look at the addresses of the connected interfaces
+ // if something has gown up
+ activeEntriesIter = currentActiveInterfaces.entrySet().iterator();
+ while(activeEntriesIter.hasNext())
+ {
+ Map.Entry<String, List<InetAddress>>
+ entry = activeEntriesIter.next();
+ for(InetAddress addr : entry.getValue())
{
- NetworkInterface iface = currentActiveInterfaces.get(i);
+ // if address is missing in active interfaces
+ // it means it has gone up
+ List<InetAddress> addresses =
+ activeInterfaces.get(entry.getKey());
+ if(addresses != null && !addresses.contains(addr))
+ {
+ if(fireEvents)
+ fireChangeEvent(new ChangeEvent(entry.getKey(),
+ ChangeEvent.ADDRESS_UP, addr));
+ addresses.add(addr);
+ }
+ }
+ }
+
+ // now we leave with only with the new and up interfaces
+ // in currentActiveInterfaces Map
+ Iterator<String> ifaceIter
+ = activeInterfaces.keySet().iterator();
+ while(ifaceIter.hasNext())
+ {
+ currentActiveInterfaces.remove(ifaceIter.next());
+ }
+
+ // fire that interface has gone up
+ activeEntriesIter = currentActiveInterfaces.entrySet().iterator();
+ while(activeEntriesIter.hasNext())
+ {
+ Map.Entry<String, List<InetAddress>>
+ entry = activeEntriesIter.next();
+ for(InetAddress addr : entry.getValue())
+ {
if(fireEvents)
- fireChangeEvent(new ChangeEvent(iface,
- ChangeEvent.IFACE_UP, false));
- activeInterfaces.add(iface);
+ fireChangeEvent(new ChangeEvent(entry.getKey(),
+ ChangeEvent.ADDRESS_UP, addr));
}
- } catch (SocketException e)
+
+ if(fireEvents)
+ fireChangeEvent(new ChangeEvent(entry.getKey(),
+ ChangeEvent.IFACE_UP));
+
+ activeInterfaces.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ /**
+ * Main loop of this thread.
+ */
+ public void run()
+ {
+ long last = 0;
+ boolean isAfterStandby = false;
+
+ while(isRunning)
{
- logger.error("Error checking network interfaces", e);
+ long curr = System.currentTimeMillis();
+
+ // if time spent between checks is more than 4 times
+ // longer than the check interval we consider it as a
+ // new check after standby
+ if(!isAfterStandby && last != 0)
+ isAfterStandby = (last + 4*CHECK_INTERVAL - curr) < 0;
+
+ if(isAfterStandby)
+ {
+ // oo standby lets fire down to all interfaces
+ // so they can reconnect
+ downAllInterfaces();
+
+ // 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
+ {
+ boolean networkIsUP = activeInterfaces.size() > 0;
+
+ checkNetworkInterfaces(true, 1000);
+
+ // fire that network has gone up
+ if(!networkIsUP && activeInterfaces.size() > 0)
+ {
+ isAfterStandby = false;
+ }
+
+ // save the last time that we checked
+ last = System.currentTimeMillis();
+ } catch (SocketException e)
+ {
+ logger.error("Error checking network interfaces", e);
+ }
+
+ synchronized(this)
+ {
+ try{
+ wait(CHECK_INTERVAL);
+ }
+ catch (Exception e){}
+ }
}
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/JabberAccountID.java b/src/net/java/sip/communicator/impl/protocol/jabber/JabberAccountID.java
index 3f728c3..f2c0ec9 100755
--- a/src/net/java/sip/communicator/impl/protocol/jabber/JabberAccountID.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/JabberAccountID.java
@@ -8,7 +8,6 @@ package net.java.sip.communicator.impl.protocol.jabber;
import java.util.*;
-import net.java.sip.communicator.plugin.jabberaccregwizz.*;
import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.protocol.*;
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
index 3246e04..0803dfb 100644
--- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
@@ -265,7 +265,8 @@ public class ProtocolProviderServiceMsnImpl
typingNotifications.setMessenger(null);
}
- if(fireEvent)
+ // if messenger is null we have already fired unregister
+ if(fireEvent && messenger != null)
fireRegistrationStateChanged(
currRegState,
RegistrationState.UNREGISTERED,
diff --git a/src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java b/src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java
index 7260701..96bed15 100644
--- a/src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java
+++ b/src/net/java/sip/communicator/impl/sysactivity/NetworkManagerListenerImpl.java
@@ -160,4 +160,13 @@ public class NetworkManagerListenerImpl
.fireSystemActivityEvent(evt);
}
}
+
+ /**
+ * Whether we are connected to the network manager through dbus.
+ * @return whether we are connected to the network manager.
+ */
+ public boolean isConnected()
+ {
+ return dbusConn != null;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java
index 6264b49..f503b19 100644
--- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java
+++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java
@@ -74,6 +74,8 @@ public class SystemActivityNotifications
*/
private static long notifierInstance = -1;
+ private static boolean loaded = false;
+
/**
* Init native library.
*/
@@ -84,6 +86,8 @@ public class SystemActivityNotifications
System.loadLibrary("sysactivitynotifications");
notifierInstance = allocAndInit();
+
+ loaded = true;
}
catch(Throwable t)
{
@@ -191,4 +195,13 @@ public class SystemActivityNotifications
long type,
boolean connected);
}
+
+ /**
+ * Whether native library is loaded.
+ * @return whether native library is loaded.
+ */
+ public static boolean isLoaded()
+ {
+ return loaded;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java
index 112fe93..903435e 100644
--- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotificationsServiceImpl.java
@@ -474,4 +474,59 @@ public class SystemActivityNotificationsServiceImpl
logger.error("Error delivering event", e);
}
}
+
+ /**
+ * Can check whether an event id is supported on
+ * current operation system.
+ * Simple return what is implemented in native, and checks
+ * are made when possible, for example linux cannot connect
+ * to NM through dbus.
+ * @param eventID the event to check.
+ * @return whether the supplied event id is supported.
+ */
+ public boolean isSupported(int eventID)
+ {
+ if(OSUtils.IS_WINDOWS)
+ {
+ if(!SystemActivityNotifications.isLoaded())
+ return false;
+
+ switch(eventID)
+ {
+ case SystemActivityEvent.EVENT_SLEEP:
+ case SystemActivityEvent.EVENT_WAKE:
+ case SystemActivityEvent.EVENT_NETWORK_CHANGE:
+ case SystemActivityEvent.EVENT_SYSTEM_IDLE:
+ case SystemActivityEvent.EVENT_SYSTEM_IDLE_END:
+ return true;
+ default:
+ return false;
+ }
+ }
+ else if(OSUtils.IS_MAC)
+ {
+ return SystemActivityNotifications.isLoaded();
+ }
+ else if(OSUtils.IS_LINUX)
+ {
+ switch(eventID)
+ {
+ case SystemActivityEvent.EVENT_SLEEP:
+ case SystemActivityEvent.EVENT_NETWORK_CHANGE:
+ {
+ return NetworkManagerListenerImpl.getInstance()
+ .isConnected();
+ }
+ case SystemActivityEvent.EVENT_SYSTEM_IDLE:
+ case SystemActivityEvent.EVENT_SYSTEM_IDLE_END:
+ {
+ return SystemActivityNotifications.isLoaded();
+ }
+ default:
+ return false;
+ }
+ }
+ else
+ return false;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationForm.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationForm.java
index af5b718..f2a2074 100644
--- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationForm.java
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationForm.java
@@ -406,7 +406,7 @@ public class JabberAccountRegistrationForm
accountProperties.get(ProtocolProviderFactory.IS_USE_GOOGLE_ICE);
boolean isUseGoogleIce = Boolean.parseBoolean(
(useGoogleIce != null && useGoogleIce.length() != 0) ?
- useGoogleIce : "false");
+ useGoogleIce : "true");
iceConfigPanel.setUseGoogleIce(isUseGoogleIce);
diff --git a/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java b/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java
index 0d05e02..bd8fabe 100644
--- a/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java
+++ b/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java
@@ -113,12 +113,12 @@ public class ReconnectPluginActivator
/**
* Start of the delay interval when starting a reconnect.
*/
- private static final int RECONNECT_DELAY_MIN = 2; // sec
+ private static final int RECONNECT_DELAY_MIN = 1; // sec
/**
* The end of the interval for the initial reconnect.
*/
- private static final int RECONNECT_DELAY_MAX = 5; // sec
+ private static final int RECONNECT_DELAY_MAX = 4; // sec
/**
* Max value for growing the reconnect delay, all subsequent reconnects
@@ -413,10 +413,7 @@ public class ReconnectPluginActivator
*/
public synchronized void configurationChanged(ChangeEvent event)
{
- if(!(event.getSource() instanceof NetworkInterface))
- return;
-
- NetworkInterface iface = (NetworkInterface)event.getSource();
+ String ifaceName = (String)event.getSource();
if(event.getType() == ChangeEvent.IFACE_UP)
{
@@ -441,11 +438,11 @@ public class ReconnectPluginActivator
needsReconnection.clear();
}
- connectedInterfaces.add(iface.getName());
+ connectedInterfaces.add(ifaceName);
}
else if(event.getType() == ChangeEvent.IFACE_DOWN)
{
- connectedInterfaces.remove(iface.getName());
+ connectedInterfaces.remove(ifaceName);
// one is down and at least one more is connected
if(connectedInterfaces.size() > 0)
@@ -459,7 +456,7 @@ public class ReconnectPluginActivator
Map.Entry<ProtocolProviderService, List<String>> entry
= iter.next();
- if(entry.getValue().contains(iface.getName()))
+ if(entry.getValue().contains(ifaceName))
{
ProtocolProviderService pp = entry.getKey();
// hum someone is reconnecting, lets cancel and
@@ -679,6 +676,8 @@ public class ReconnectPluginActivator
if(currentlyReconnecting.containsKey(pp))
currentlyReconnecting.remove(pp).cancel();
+ unregisteredProviders.remove(pp);
+
if(logger.isTraceEnabled())
{
logger.trace("Got Registered for " + pp);
@@ -740,7 +739,7 @@ public class ReconnectPluginActivator
ReconnectTask task = new ReconnectTask(pp);
task.delay = delay;
currentlyReconnecting.put(pp, task);
-
+
if (logger.isTraceEnabled())
logger.trace("Reconnect " + pp + " after " + delay + " ms.");
timer.schedule(task, delay);
diff --git a/src/net/java/sip/communicator/service/netaddr/event/ChangeEvent.java b/src/net/java/sip/communicator/service/netaddr/event/ChangeEvent.java
index 0b9675d..bf31614 100644
--- a/src/net/java/sip/communicator/service/netaddr/event/ChangeEvent.java
+++ b/src/net/java/sip/communicator/service/netaddr/event/ChangeEvent.java
@@ -6,6 +6,8 @@
*/
package net.java.sip.communicator.service.netaddr.event;
+import java.net.*;
+
/**
* A ChangeEvent is fired on change of the network configuration of the computer.
*
@@ -20,16 +22,26 @@ public class ChangeEvent
private static final long serialVersionUID = 0L;
/**
- * Event type for interface going up.
+ * Event type for interface going down.
*/
public static final int IFACE_DOWN = 0;
/**
- * Event type for interface going down.
+ * Event type for interface going up.
*/
public static final int IFACE_UP = 1;
/**
+ * Event type for address going down.
+ */
+ public static final int ADDRESS_DOWN = 2;
+
+ /**
+ * Event type for interface going down.
+ */
+ public static final int ADDRESS_UP = 3;
+
+ /**
* The type of the current event.
*/
private int type = -1;
@@ -40,15 +52,59 @@ public class ChangeEvent
private boolean standby = false;
/**
+ * The address that changed.
+ */
+ private InetAddress address;
+
+ /**
+ * Is this event initial one. When starting, no actual
+ * change has occurred in the system.
+ */
+ private boolean initial;
+
+ /**
* Creates event.
- * @param source the source of the event.
+ * @param source the source of the event, the interface.
* @param type the type of the event.
+ * @param address the address that changed.
+ * @param standby is the event after a suspend of the computer.
+ * @param initial is this event initial one.
*/
- public ChangeEvent(Object source, int type)
+ public ChangeEvent(Object source,
+ int type,
+ InetAddress address,
+ boolean standby,
+ boolean initial)
{
super(source);
this.type = type;
+ this.address = address;
+ this.standby = standby;
+ this.initial = initial;
+ }
+
+ /**
+ * Creates event.
+ * @param source the source of the event, the interface.
+ * @param type the type of the event.
+ * @param address the address that changed.
+ */
+ public ChangeEvent(Object source,
+ int type,
+ InetAddress address)
+ {
+ this(source, type, address, false, false);
+ }
+
+ /**
+ * Creates event.
+ * @param source the source of the event, the interface.
+ * @param type the type of the event.
+ */
+ public ChangeEvent(Object source, int type)
+ {
+ this(source, type, null, false, false);
}
/**
@@ -59,9 +115,7 @@ public class ChangeEvent
*/
public ChangeEvent(Object source, int type, boolean standby)
{
- this(source, type);
-
- this.standby = standby;
+ this(source, type, null, standby, false);
}
/**
@@ -74,6 +128,15 @@ public class ChangeEvent
}
/**
+ * The address that changed.
+ * @return the address
+ */
+ public InetAddress getAddress()
+ {
+ return address;
+ }
+
+ /**
* Whether this event is after suspend of the computer.
* @return the standby
*/
@@ -96,10 +159,22 @@ public class ChangeEvent
{
case IFACE_DOWN: buff.append("Interface down"); break;
case IFACE_UP: buff.append("Interface up"); break;
+ case ADDRESS_DOWN : buff.append("Address down"); break;
+ case ADDRESS_UP : buff.append("Address up"); break;
}
buff.append(", standby=" + standby);
return buff.toString();
}
+
+ /**
+ * Is this event initial one. When starting, no actual
+ * change has occurred in the system.
+ * @return is this event initial one.
+ */
+ public boolean isInitial()
+ {
+ return initial;
+ }
}
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java b/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java
index 3e6ee2e..1507234 100644
--- a/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java
+++ b/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java
@@ -249,4 +249,14 @@ public abstract class AbstractProtocolProviderService
registrationListeners.clear();
}
}
+
+ /**
+ * A clear display for ProtocolProvider when its printed in logs.
+ * @return the class name and the currently handled account.
+ */
+ public String toString()
+ {
+ return getClass().getSimpleName() + "("
+ + getAccountID().getDisplayName() + ")";
+ }
}
diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
index 60c1376..778dba1 100644
--- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
+++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
@@ -289,7 +289,7 @@ public abstract class ProtocolProviderFactory
/**
* Indicates if Google ICE should be used.
*/
- public static final String IS_USE_GOOGLE_ICE = "GOOGLE_ICE_ENABLED";
+ public static final String IS_USE_GOOGLE_ICE = "GTALK_ICE_ENABLED";
/**
* Indicates if STUN server should be automatically discovered.
diff --git a/src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java b/src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java
index 2faf4f4..621f1eb 100644
--- a/src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java
+++ b/src/net/java/sip/communicator/service/sysactivity/SystemActivityNotificationsService.java
@@ -55,4 +55,12 @@ public interface SystemActivityNotificationsService
*/
public void removeIdleSystemChangeListener(
SystemActivityChangeListener listener);
+
+ /**
+ * Can check whether an event id is supported on
+ * current operation system.
+ * @param eventID the event to check.
+ * @return whether the supplied event id is supported.
+ */
+ public boolean isSupported(int eventID);
}
diff --git a/src/net/java/sip/communicator/util/NetworkUtils.java b/src/net/java/sip/communicator/util/NetworkUtils.java
index e6ee8d0..a362f1e 100644
--- a/src/net/java/sip/communicator/util/NetworkUtils.java
+++ b/src/net/java/sip/communicator/util/NetworkUtils.java
@@ -1139,7 +1139,7 @@ public class NetworkUtils
*/
public void configurationChanged(ChangeEvent event)
{
- if(event.getType() == ChangeEvent.IFACE_UP)
+ if(event.getType() == ChangeEvent.IFACE_UP && !event.isInitial())
{
reloadDnsResolverConfig();
}