+ case "addDevice":
+ if (dBusConn != null) {
+ System.err.println("link is not yet implemented via dbus");
+ System.exit(1);
+ }
+ if (!m.isRegistered()) {
+ System.err.println("User is not registered.");
+ System.exit(1);
+ }
+ try {
+ m.addDeviceLink(new URI(ns.getString("uri")));
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(3);
+ } catch (InvalidKeyException e) {
+ e.printStackTrace();
+ System.exit(2);
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ System.exit(2);
+ }
+ break;
+ case "listDevices":
+ if (dBusConn != null) {
+ System.err.println("listDevices is not yet implemented via dbus");
+ System.exit(1);
+ }
+ if (!m.isRegistered()) {
+ System.err.println("User is not registered.");
+ System.exit(1);
+ }
+ try {
+ List<DeviceInfo> devices = m.getLinkedDevices();
+ for (DeviceInfo d : devices) {
+ System.out.println("Device " + d.getId() + (d.getId() == m.getDeviceId() ? " (this device)" : "") + ":");
+ System.out.println(" Name: " + d.getName());
+ System.out.println(" Created: " + d.getCreated());
+ System.out.println(" Last seen: " + d.getLastSeen());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(3);
+ }
+ break;
+ case "removeDevice":
+ if (dBusConn != null) {
+ System.err.println("removeDevice is not yet implemented via dbus");
+ System.exit(1);
+ }
+ if (!m.isRegistered()) {
+ System.err.println("User is not registered.");
+ System.exit(1);
+ }
+ try {
+ int deviceId = ns.getInt("deviceId");
+ m.removeLinkedDevices(deviceId);
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(3);
+ }
+ break;