use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.
the class UserDeleting method addStageInformation.
@Override
protected void addStageInformation(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.form);
form.setTitle("Dispatching a user deleting event.");
form.addInstruction("Fill out this form to dispatch a user deleting event.");
FormField field = form.addField();
field.setType(FormField.Type.hidden);
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
field = form.addField();
field.setType(FormField.Type.text_single);
field.setLabel("The username of the user that is being deleted");
field.setVariable("username");
field.setRequired(true);
// Add the form to the command
command.add(form.getElement());
}
use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.
the class GetListActiveUsers method addStageInformation.
@Override
protected void addStageInformation(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.form);
form.setTitle("Requesting List of Active Users");
form.addInstruction("Fill out this form to request the active users of this service.");
FormField field = form.addField();
field.setType(FormField.Type.hidden);
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
field = form.addField();
field.setType(FormField.Type.list_single);
field.setLabel("Maximum number of items to show");
field.setVariable("max_items");
field.addOption("25", "25");
field.addOption("50", "50");
field.addOption("75", "75");
field.addOption("100", "100");
field.addOption("150", "150");
field.addOption("200", "200");
field.addOption("None", "none");
// Add the form to the command
command.add(form.getElement());
}
use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.
the class GetNumberUserSessions method execute.
@Override
public void execute(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.result);
FormField field = form.addField();
field.setType(FormField.Type.hidden);
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
field = form.addField();
field.setLabel(getLabel());
field.setVariable("onlineuserssessionsnum");
SessionManager sessionManager = SessionManager.getInstance();
field.addValue(sessionManager.getUserSessionsCount(false));
command.add(form.getElement());
}
use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.
the class GetServerStats method execute.
@Override
public void execute(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.result);
FormField field = form.addField();
field.setType(FormField.Type.hidden);
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
field = form.addField();
field.setLabel(LocaleUtils.getLocalizedString("index.server_name"));
field.setVariable("name");
field.addValue(AdminConsole.getAppName());
field = form.addField();
field.setLabel(LocaleUtils.getLocalizedString("index.version"));
field.setVariable("version");
field.addValue(AdminConsole.getVersionString());
field = form.addField();
field.setLabel(LocaleUtils.getLocalizedString("index.domain_name"));
field.setVariable("domain");
field.addValue(XMPPServer.getInstance().getServerInfo().getXMPPDomain());
field = form.addField();
field.setLabel(LocaleUtils.getLocalizedString("index.jvm"));
field.setVariable("os");
String vmName = System.getProperty("java.vm.name");
if (vmName == null) {
vmName = "";
} else {
vmName = " -- " + vmName;
}
field.addValue(System.getProperty("java.version") + " " + System.getProperty("java.vendor") + vmName);
field = form.addField();
field.setLabel(LocaleUtils.getLocalizedString("index.uptime"));
field.setVariable("uptime");
field.addValue(XMPPDateTimeFormat.format(XMPPServer.getInstance().getServerInfo().getLastStarted()));
DecimalFormat mbFormat = new DecimalFormat("#0.00");
DecimalFormat percentFormat = new DecimalFormat("#0.0");
Runtime runtime = Runtime.getRuntime();
double freeMemory = (double) runtime.freeMemory() / (1024 * 1024);
double maxMemory = (double) runtime.maxMemory() / (1024 * 1024);
double totalMemory = (double) runtime.totalMemory() / (1024 * 1024);
double usedMemory = totalMemory - freeMemory;
double percentFree = ((maxMemory - usedMemory) / maxMemory) * 100.0;
double percentUsed = 100 - percentFree;
field = form.addField();
field.setLabel(LocaleUtils.getLocalizedString("index.memory"));
field.setVariable("memory");
field.addValue(mbFormat.format(usedMemory) + " MB of " + mbFormat.format(maxMemory) + " MB (" + percentFormat.format(percentUsed) + "%) used");
// Make sure that we are only counting based on bareJIDs and not fullJIDs
Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
Set<String> users = new HashSet<>(sessions.size());
int availableSessions = 0;
for (ClientSession session : sessions) {
if (session.getPresence().isAvailable()) {
users.add(session.getAddress().toBareJID());
availableSessions++;
}
}
field = form.addField();
field.setLabel("Available Users");
field.setVariable("activeusersnum");
field.addValue(users.size());
field = form.addField();
field.setLabel("Available Users Sessions");
field.setVariable("sessionsnum");
field.addValue(availableSessions);
command.add(form.getElement());
}
use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.
the class GetUsersPresence method addStageInformation.
@Override
protected void addStageInformation(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.form);
form.setTitle("Requesting Presence of Active Users");
form.addInstruction("Fill out this form to request the active users presence of this service.");
FormField field = form.addField();
field.setType(FormField.Type.hidden);
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
field = form.addField();
field.setType(FormField.Type.list_single);
field.setLabel("Maximum number of items to return");
field.setVariable("max_items");
field.addOption("25", "25");
field.addOption("50", "50");
field.addOption("75", "75");
field.addOption("100", "100");
field.addOption("150", "150");
field.addOption("200", "200");
field.addOption("None", "none");
// Add the form to the command
command.add(form.getElement());
}
Aggregations