Adapt D-Bus NetworkManager signal listener to NM_STATE 0.9

cusax-fix
Ingo Bauersachs 14 years ago
parent 5bef452c85
commit 2d1896a464

@ -1,94 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/felix.jar"/>
<classpathentry kind="lib" path="lib/jdic-all.jar"/>
<classpathentry kind="lib" path="lib/bundle/junit.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/apache-ant-1.7.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/aclibico-2.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/concurrent.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/dict4j.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/dhcp4java-1.00.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jmdns.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/fmj.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-api.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-ri.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jcalendar-1.3.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jdic_misc.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jdom.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jfontchooser-1.0.5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jml-1.0b5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jna.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/joscar-client.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/joscar-common.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/joscar-protocol.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jsch-0.1.36.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jsocks-klea.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/json-20090723.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jspeex.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/junit.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/laf-widget.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/libphonenumber-2.4.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/log4j-1.2.8.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/lti-civil-no_s_w_t.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sdp.jar">
<attributes>
<attribute name="javadoc_location" value="https://hudson.jboss.org/jenkins/job/jain-sip/lastStableBuild/artifact/javadoc/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/installer-exclude/pircbot.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/profiler4j-1.0-beta3-SC.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/rome-0.9.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/smack.jar" sourcepath="lib/installer-exclude/smack-src.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/smackx.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/ice4j.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/swing-worker-1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/transparency.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/ymsg_network_v0_67.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/zrtp4j-light.jar"/>
<classpathentry kind="lib" path="lib/os-specific/linux/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/linux/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/os-specific/mac/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/mac/OrangeExtensions.jar"/>
<classpathentry kind="lib" path="lib/os-specific/mac/growl4j.jar"/>
<classpathentry kind="lib" path="lib/os-specific/mac/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/os-specific/solaris/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/solaris/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/jna-platform-win32.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/sound.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/lcrypto-jdk16-143.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/otr4j.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jmyspell-core.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jnsapi.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/mac_widgets-0.9.5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/forms-1.2.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/weupnp-0.1.2-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/google-collect-1.0-rc1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-1.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-meta-1.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-contacts-3.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-contacts-meta-3.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-core-1.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/hexdump-0.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/libdbus-java-2.7.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/unix-0.5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/sdes4j.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/dnsjava.jar">
<attributes>
<attribute name="javadoc_location" value="http://www.dnsjava.org/dnsjava-current/doc/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/installer-exclude/httpmime-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/httpcore-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/httpclient-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/cglib-nodep.osgi-2.1_3.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/easymock-3.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/objenesis-1.2.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/felix.jar"/>
<classpathentry kind="lib" path="lib/jdic-all.jar"/>
<classpathentry kind="lib" path="lib/bundle/junit.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/apache-ant-1.7.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/aclibico-2.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/concurrent.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/dict4j.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/dhcp4java-1.00.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jmdns.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/fmj.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-api.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-ri.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jcalendar-1.3.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jdic_misc.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jdom.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jfontchooser-1.0.5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jml-1.0b5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jna.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/joscar-client.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/joscar-common.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/joscar-protocol.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jsch-0.1.36.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jsocks-klea.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/json-20090723.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jspeex.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/junit.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/laf-widget.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/libphonenumber-2.4.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/log4j-1.2.8.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/lti-civil-no_s_w_t.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jain-sdp.jar">
<attributes>
<attribute name="javadoc_location" value="https://hudson.jboss.org/jenkins/job/jain-sip/lastStableBuild/artifact/javadoc/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/installer-exclude/pircbot.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/profiler4j-1.0-beta3-SC.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/rome-0.9.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/smack.jar" sourcepath="lib/installer-exclude/smack-src.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/smackx.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/ice4j.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/swing-worker-1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/transparency.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/ymsg_network_v0_67.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/zrtp4j-light.jar"/>
<classpathentry kind="lib" path="lib/os-specific/linux/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/linux/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/os-specific/mac/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/mac/OrangeExtensions.jar"/>
<classpathentry kind="lib" path="lib/os-specific/mac/growl4j.jar"/>
<classpathentry kind="lib" path="lib/os-specific/mac/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/os-specific/solaris/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/solaris/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/jna-platform-win32.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/sound.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/lcrypto-jdk16-143.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/otr4j.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jmyspell-core.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jnsapi.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/mac_widgets-0.9.5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/forms-1.2.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/weupnp-0.1.2-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/google-collect-1.0-rc1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-1.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-meta-1.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-contacts-3.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-contacts-meta-3.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/gdata-core-1.0.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/hexdump-0.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/libdbus-java-2.7.jar">
<attributes>
<attribute name="javadoc_location" value="http://dbus.freedesktop.org/doc/dbus-java/api/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/installer-exclude/unix-0.5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/sdes4j.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/dnsjava.jar">
<attributes>
<attribute name="javadoc_location" value="http://www.dnsjava.org/dnsjava-current/doc/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/installer-exclude/httpmime-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/httpcore-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/httpclient-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/cglib-nodep.osgi-2.1_3.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/easymock-3.1.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/objenesis-1.2.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>

@ -0,0 +1,136 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.sysactivity;
import org.freedesktop.dbus.*;
import org.freedesktop.dbus.exceptions.*;
/**
* NetworkManager D-Bus Interface
*
* @author Damian Minkov
* @author Ingo Bauersachs
*/
@DBusInterfaceName("org.freedesktop.NetworkManager")
public interface DBusNetworkManager
extends DBusInterface
{
/*
* Types of NetworkManager states for versions < 0.9
*/
public static final int NM_STATE_UNKNOWN = 0;
public static final int NM_STATE_ASLEEP = 1;
public static final int NM_STATE_CONNECTING = 2;
public static final int NM_STATE_CONNECTED = 3;
public static final int NM_STATE_DISCONNECTED = 4;
/*
* Types of NetworkManager states for versions >= 0.9
*/
public static final int NM9_STATE_UNKNOWN = 0;
public static final int NM9_STATE_ASLEEP = 10;
public static final int NM9_STATE_DISCONNECTED = 20;
public static final int NM9_STATE_DISCONNECTING = 30;
public static final int NM9_STATE_CONNECTING = 40;
public static final int NM9_STATE_CONNECTED_LOCAL = 50;
public static final int NM9_STATE_CONNECTED_SITE = 60;
public static final int NM9_STATE_CONNECTED_GLOBAL = 70;
/**
* State change signal.
*/
public class StateChange extends DBusSignal
{
/**
* The name of the signal.
*/
public final String name;
/**
* The current status it holds.
*/
public final UInt32 status;
/**
* Creates status change.
* @param path the path
* @param status the status
* @throws DBusException
*/
public StateChange(String path, UInt32 status)
throws DBusException
{
super(path, status);
name = path;
this.status = status;
}
/**
* The current status.
* @return
*/
public int getStatus()
{
return status.intValue();
}
/**
* Returns status description
* @return
*/
public String getStatusName()
{
switch(status.intValue())
{
case NM_STATE_ASLEEP : return "Asleep";
case NM_STATE_CONNECTING : return "Connecting";
case NM_STATE_CONNECTED : return "Connected";
case NM_STATE_DISCONNECTED : return "Disconnected";
default : return "Unknown";
}
}
}
/**
* State changed signal.
*/
public static class StateChanged extends StateChange
{
/**
* Creates status changed.
* @param path the path
* @param status the status
* @throws DBusException
*/
public StateChanged(String path, UInt32 status)
throws DBusException
{
super(path, status);
}
/**
* Returns status description
* @return
*/
@Override
public String getStatusName()
{
switch(status.intValue())
{
case NM9_STATE_UNKNOWN: return "Unknown";
case NM9_STATE_ASLEEP: return "Asleep";
case NM9_STATE_DISCONNECTED: return "Disconnected";
case NM9_STATE_DISCONNECTING: return "Disconnecting";
case NM9_STATE_CONNECTING: return "Connecting";
case NM9_STATE_CONNECTED_LOCAL: return "LocalConnectivity";
case NM9_STATE_CONNECTED_SITE: return "SiteConnectivity";
case NM9_STATE_CONNECTED_GLOBAL: return "GlobalConnectivity";
default : return "Unknown";
}
}
}
}

@ -18,6 +18,7 @@
*
* @author Damian Minkov
*/
@SuppressWarnings("rawtypes")
public class NetworkManagerListenerImpl
implements DBusSigHandler
{
@ -77,7 +78,8 @@ public void start()
try
{
dbusConn.addSigHandler(DBus.NameOwnerChanged.class, this);
dbusConn.addSigHandler(NetworkManager.StateChange.class, this);
dbusConn.addSigHandler(DBusNetworkManager.StateChange.class, this);
dbusConn.addSigHandler(DBusNetworkManager.StateChanged.class, this);
}
catch(DBusException e)
{
@ -98,7 +100,10 @@ public void stop()
try
{
dbusConn.removeSigHandler(DBus.NameOwnerChanged.class, this);
dbusConn.removeSigHandler(NetworkManager.StateChange.class, this);
dbusConn.removeSigHandler(
DBusNetworkManager.StateChange.class, this);
dbusConn.removeSigHandler(
DBusNetworkManager.StateChanged.class, this);
}
catch(DBusException e)
{
@ -117,7 +122,7 @@ public void handle(DBusSignal dBusSignal)
DBus.NameOwnerChanged nameOwnerChanged =
(DBus.NameOwnerChanged)dBusSignal;
if(nameOwnerChanged.name.equals(NetworkManager.class.getName()))
if(nameOwnerChanged.name.equals("org.freedesktop.NetworkManager"))
{
boolean b1 = nameOwnerChanged.old_owner != null
&& nameOwnerChanged.old_owner.length() > 0;
@ -134,21 +139,26 @@ public void handle(DBusSignal dBusSignal)
}
}
}
else if(dBusSignal instanceof NetworkManager.StateChange)
else if(dBusSignal instanceof DBusNetworkManager.StateChange)
{
NetworkManager.StateChange stateChange =
(NetworkManager.StateChange)dBusSignal;
DBusNetworkManager.StateChange stateChange =
(DBusNetworkManager.StateChange)dBusSignal;
SystemActivityEvent evt = null;
switch(stateChange.getStatus())
{
case NetworkManager.NM_STATE_CONNECTED:
case NetworkManager.NM_STATE_DISCONNECTED:
case DBusNetworkManager.NM_STATE_CONNECTED:
case DBusNetworkManager.NM_STATE_DISCONNECTED:
case DBusNetworkManager.NM9_STATE_DISCONNECTED:
case DBusNetworkManager.NM9_STATE_CONNECTED_LOCAL:
case DBusNetworkManager.NM9_STATE_CONNECTED_SITE:
case DBusNetworkManager.NM9_STATE_CONNECTED_GLOBAL:
evt = new SystemActivityEvent(
SysActivityActivator.getSystemActivityService(),
SystemActivityEvent.EVENT_NETWORK_CHANGE);
break;
case NetworkManager.NM_STATE_ASLEEP:
case DBusNetworkManager.NM_STATE_ASLEEP:
case DBusNetworkManager.NM9_STATE_ASLEEP:
evt = new SystemActivityEvent(
SysActivityActivator.getSystemActivityService(),
SystemActivityEvent.EVENT_SLEEP);

Loading…
Cancel
Save