Search in sources :

Example 71 with FormField

use of org.xmpp.forms.FormField in project Openfire by igniterealtime.

the class ChangeUserPassword method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Changing a User Password");
    form.addInstruction("Fill out this form to change a user\u2019s password.");
    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.jid_single);
    field.setLabel("The Jabber ID for this account");
    field.setVariable("accountjid");
    field.setRequired(true);
    field = form.addField();
    field.setType(FormField.Type.text_private);
    field.setLabel("The password for this account");
    field.setVariable("password");
    field.setRequired(true);
    // Add the form to the command
    command.add(form.getElement());
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 72 with FormField

use of org.xmpp.forms.FormField in project Openfire by igniterealtime.

the class UserProperties 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");
    List<String> accounts = data.getData().get("accountjids");
    if (accounts != null && accounts.size() > 0) {
        populateResponseFields(form, accounts);
    }
    command.add(form.getElement());
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 73 with FormField

use of org.xmpp.forms.FormField in project Openfire by igniterealtime.

the class GroupDeleting method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Dispatching a deleting group event.");
    form.addInstruction("Fill out this form to dispatch a deleting group 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 group name of the group that is being deleted");
    field.setVariable("groupName");
    field.setRequired(true);
    // Add the form to the command
    command.add(form.getElement());
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 74 with FormField

use of org.xmpp.forms.FormField 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.setType(FormField.Type.text_single);
    field.setLabel(LocaleUtils.getLocalizedString("index.server_name"));
    field.setVariable("name");
    field.addValue(AdminConsole.getAppName());
    field = form.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel(LocaleUtils.getLocalizedString("index.version"));
    field.setVariable("version");
    field.addValue(AdminConsole.getVersionString());
    field = form.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel(LocaleUtils.getLocalizedString("index.domain_name"));
    field.setVariable("domain");
    field.addValue(XMPPServer.getInstance().getServerInfo().getXMPPDomain());
    field = form.addField();
    field.setType(FormField.Type.text_single);
    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.setType(FormField.Type.text_single);
    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.setType(FormField.Type.text_single);
    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.setType(FormField.Type.text_single);
    field.setLabel("Available Users");
    field.setVariable("activeusersnum");
    field.addValue(users.size());
    field = form.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel("Available Users Sessions");
    field.setVariable("sessionsnum");
    field.addValue(availableSessions);
    command.add(form.getElement());
}
Also used : DecimalFormat(java.text.DecimalFormat) ClientSession(org.jivesoftware.openfire.session.ClientSession) DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 75 with FormField

use of org.xmpp.forms.FormField 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.setType(FormField.Type.text_single);
    field.setLabel(getLabel());
    field.setVariable("onlineuserssessionsnum");
    SessionManager sessionManager = SessionManager.getInstance();
    field.addValue(sessionManager.getUserSessionsCount(false));
    command.add(form.getElement());
}
Also used : SessionManager(org.jivesoftware.openfire.SessionManager) DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Aggregations

FormField (org.xmpp.forms.FormField)92 DataForm (org.xmpp.forms.DataForm)80 Element (org.dom4j.Element)21 JID (org.xmpp.packet.JID)13 IQ (org.xmpp.packet.IQ)7 HashSet (java.util.HashSet)6 ClientSession (org.jivesoftware.openfire.session.ClientSession)6 ArrayList (java.util.ArrayList)4 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)4 ParseException (java.text.ParseException)3 Date (java.util.Date)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3 Group (org.jivesoftware.openfire.group.Group)3 Test (org.junit.Test)3 List (java.util.List)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 PacketException (org.jivesoftware.openfire.PacketException)2 GroupJID (org.jivesoftware.openfire.group.GroupJID)2 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)2 MUCRoom (org.jivesoftware.openfire.muc.MUCRoom)2