Advertisement
Guest User

Untitled

a guest
Jul 25th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.75 KB | None | 0 0
  1. mport java.util.List;
  2. import java.util.Map;
  3.  
  4. //import org.freedesktop.DBus.*;
  5. import org.freedesktop.dbus.*;
  6. import org.freedesktop.dbus.exceptions.DBusException;
  7.  
  8. import org.freedesktop.DBus;
  9. import org.freedesktop.DBus.Introspectable;
  10. import org.freedesktop.DBus.Properties;
  11. import org.freedesktop.NetworkManager;
  12. import org.freedesktop.NetworkManager.Settings.*;
  13. import org.freedesktop.NetworkManager.*;
  14.  
  15. public class TestDBUS {
  16.  
  17. private static DBusConnection conn;
  18. //private static Properties props;
  19.  
  20. public TestDBUS() {
  21.    
  22.    
  23.     try {
  24.        
  25.         conn = DBusConnection.getConnection(DBusConnection.SYSTEM);
  26.        
  27.         DBus.Properties props = (DBus.Properties) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/AccessPoint/193" ,DBus.Properties.class );
  28.        
  29.         NetworkManager c = (NetworkManager) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager");
  30.        
  31.         AccessPoint ap = (AccessPoint) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/AccessPoint/193", AccessPoint.class);
  32.    
  33.  
  34.        
  35.  
  36.  
  37.  
  38.  
  39.  
  40.        
  41.  
  42.  
  43.         Map<String, Variant> ap_props_map = props.GetAll("org.fresdedesktop.NetworkManager.AccessPoint");
  44.         Settings s = (Settings) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings");
  45.    
  46.        
  47.  
  48.  
  49.        
  50.         Connection co = (Connection) conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings/0");
  51.        
  52.        
  53.         Map<String,Map<String,Variant>> map = co.GetSettings();
  54.        
  55.         System.out.println(map.toString());
  56.        
  57.         List<DBusInterface> conn_list = s.ListConnections();
  58.         DBusInterface connection = conn_list.get(0);
  59.        
  60.         System.out.println("Connection:");
  61.         System.out.println(connection.toString());
  62.  
  63.  
  64.         String[] d = conn.getNames();
  65.      
  66.         int i=0;
  67.         System.out.println(d.length);
  68.         while(i<d.length) {
  69.             System.out.println(d.length);
  70.             System.out.println(i);
  71.  
  72.             System.out.println(d[i]);
  73.             i++;
  74.         }
  75.        
  76.         List<DBusInterface> list = c.GetDevices();
  77.         //DBus.Properties props = this.conn.getRemoteObject("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager", DBus.Properties.class);
  78.         //NetworkManager c1 = (NetworkManager) conn.getRemoteObject(ServiceBusName+".AccessPoint", ObjectPath+"/AccessPoint" );
  79.         System.out.println("About to print");
  80.         System.out.println("Devices present in machine: " + list.size());
  81.         System.out.println("Connection state: " + c.state());
  82.         DBusInterface dev = list.get(0);
  83.         System.out.println(dev.toString());
  84.         //dev = list.get(1);
  85.         System.out.println(dev.toString());
  86.     } catch(DBusException ex) {
  87.         ex.printStackTrace();
  88.     }
  89. }
  90.  
  91. public static void main(String [] args) {
  92.     TestDBUS n = new TestDBUS();
  93.     }
  94.  
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement