connection.respond(createHeader());
connection.respond(String.format(lineFormat, Formatter.getBar(), "User", "Group", "Action", Formatter.getBar()));
connection.respond(Formatter.createLine(200));
}
for (Connection c : Sort.connections(conns)) {
User u = c.getUser();
// not listing users that are not logged in might cause problems if people connect and then are orphaned. the site might look empty
// but people still can't get in
// we will list these connections in xwho (or whatever we'll call it)
// so, the NullPointerException we got here was when the connection was being reconnected automatically, and
// we did a "site who" before there was a User object available, and thus we got a NullpointerException
if (u != null) { // don't list connections where the user hasn't logged in yet
if ((u.isHidden() && !user.hasPermission(UserPermission.SEE_HIDDEN)) || !ServiceManager.getServices().getPermissions().canSee(user, u, c.getCurrentDir())) {
// hide user if user has the property hidden, or the directory in which the user operates is hidden
continue;
}
if (c.isUploading()) {
if (raw) {
connection.respond(u.getUsername() + ";" + u.getPrimaryGroup() + ";uploading;" + c.getCurrentSpeed() + ";" + c.getIdleTime() + ";" + escape(c.getLastCommand()));
} else {
connection.respond(String.format(lineFormat, Formatter.getBar(), u.getUsername(), u.getPrimaryGroup(), c.getLastCommand() + " @ " + Formatter.speedFromKBps(c.getCurrentSpeed()), Formatter.getBar()));
}
} else if (c.isDownloading()) {
if (raw) {
connection.respond(u.getUsername() + ";" + u.getPrimaryGroup() + ";downloading;" + c.getCurrentSpeed() + ";" + c.getIdleTime() + ";" + escape(c.getLastCommand()));
} else {
connection.respond(String.format(lineFormat, Formatter.getBar(), u.getUsername(), u.getPrimaryGroup(), c.getLastCommand() + " @ " + Formatter.speedFromKBps(c.getCurrentSpeed()), Formatter.getBar()));
}
} else {
if (raw) {
connection.respond(u.getUsername() + ";" + u.getPrimaryGroup() + ";idle;" + c.getCurrentSpeed() + ";" + c.getIdleTime() + ";" + escape(c.getLastCommand()));
} else {
connection.respond(String.format(lineFormat, Formatter.getBar(), u.getUsername(), u.getPrimaryGroup(), "idle for " + Formatter.shortDuration(c.getIdleTime()), Formatter.getBar()));
}
}
}
}
if (raw) {