Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mport java.util.List;
- import java.util.Map;
- //import org.freedesktop.DBus.*;
- import org.freedesktop.dbus.*;
- import org.freedesktop.dbus.exceptions.DBusException;
- import org.freedesktop.DBus;
- import org.freedesktop.DBus.Introspectable;
- import org.freedesktop.DBus.Properties;
- import org.freedesktop.NetworkManager;
- import org.freedesktop.NetworkManager.Settings.*;
- import org.freedesktop.NetworkManager.*;
- public class TestDBUS {
- private static DBusConnection conn;
- //private static Properties props;
- public TestDBUS() {
- try {
- conn = DBusConnection.getConnection(DBusConnection.SYSTEM);
- DBus.Properties props = (DBus.Properties) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/AccessPoint/193" ,DBus.Properties.class );
- NetworkManager c = (NetworkManager) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager");
- AccessPoint ap = (AccessPoint) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/AccessPoint/193", AccessPoint.class);
- Map<String, Variant> ap_props_map = props.GetAll("org.fresdedesktop.NetworkManager.AccessPoint");
- Settings s = (Settings) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings");
- Connection co = (Connection) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings/0");
- Map<String,Map<String,Variant>> map = co.GetSettings();
- System.out.println(map.toString());
- List<DBusInterface> conn_list = s.ListConnections();
- DBusInterface connection = conn_list.get(0);
- System.out.println("Connection:");
- System.out.println(connection.toString());
- String[] d = conn.getNames();
- int i=0;
- System.out.println(d.length);
- while(i<d.length) {
- System.out.println(d.length);
- System.out.println(i);
- System.out.println(d[i]);
- i++;
- }
- List<DBusInterface> list = c.GetDevices();
- //DBus.Properties props = this.conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager", DBus.Properties.class);
- //NetworkManager c1 = (NetworkManager) conn.getRemoteObject(ServiceBusName+".AccessPoint", ObjectPath+"/AccessPoint" );
- System.out.println("About to print");
- System.out.println("Devices present in machine: " + list.size());
- System.out.println("Connection state: " + c.state());
- DBusInterface dev = list.get(0);
- System.out.println(dev.toString());
- //dev = list.get(1);
- System.out.println(dev.toString());
- } catch(DBusException ex) {
- ex.printStackTrace();
- }
- }
- public static void main(String [] args) {
- TestDBUS n = new TestDBUS();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement