Search in sources :

Example 6 with DataForm

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

the class AuthenticateUser method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Authenticating a user");
    form.addInstruction("Fill out this form to authenticate a user.");
    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 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 7 with DataForm

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

the class HttpBindStatus 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");
    HttpBindManager manager = HttpBindManager.getInstance();
    boolean isEnabled = manager.isHttpBindEnabled();
    field = form.addField();
    field.setLabel("Http Bind Enabled");
    field.setVariable("httpbindenabled");
    field.addValue(String.valueOf(isEnabled));
    if (isEnabled) {
        field = form.addField();
        field.setLabel("Http Bind Address");
        field.setVariable("httpbindaddress");
        field.addValue(manager.getHttpBindUnsecureAddress());
        field = form.addField();
        field.setLabel("Http Bind Secure Address");
        field.setVariable("httpbindsecureaddress");
        field.addValue(manager.getHttpBindSecureAddress());
        String jsUrl = manager.getJavaScriptUrl();
        if (jsUrl != null) {
            field = form.addField();
            field.setLabel("Http Bind JavaScript Address");
            field.setVariable("javascriptaddress");
            field.addValue(jsUrl);
        }
    }
    command.add(form.getElement());
}
Also used : DataForm(org.xmpp.forms.DataForm) HttpBindManager(org.jivesoftware.openfire.http.HttpBindManager) FormField(org.xmpp.forms.FormField)

Example 8 with DataForm

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

the class PacketsNotification method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Receiving notification of packets activity");
    form.addInstruction("Fill out this form to configure packets to receive.");
    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_multi);
    field.setLabel("Type of packet");
    field.setVariable("packet_type");
    field.addOption("Presence", "presence");
    field.addOption("IQ", "iq");
    field.addOption("Message", "message");
    field.setRequired(true);
    field = form.addField();
    field.setType(FormField.Type.list_single);
    field.setLabel("Direction");
    field.setVariable("direction");
    field.addOption("Incoming", "incoming");
    field.addOption("Outgoing", "outgoing");
    field.setRequired(true);
    field = form.addField();
    field.setType(FormField.Type.list_single);
    field.setLabel("Processing time");
    field.setVariable("processed");
    field.addOption("Before processing", "false");
    field.addOption("After processing", "true");
    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 9 with DataForm

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

the class DeleteGroup method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Delete group");
    form.addInstruction("Fill out this form to delete a group.");
    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("Group Name");
    field.setVariable("group");
    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 10 with DataForm

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

the class GetListGroupUsers method execute.

@Override
public void execute(SessionData data, Element command) {
    Group group;
    try {
        group = GroupManager.getInstance().getGroup(data.getData().get("group").get(0));
    } catch (GroupNotFoundException e) {
        // Group not found
        Element note = command.addElement("note");
        note.addAttribute("type", "error");
        note.setText("Group name does not exist");
        return;
    }
    DataForm form = new DataForm(DataForm.Type.result);
    form.addReportedField("jid", "User", FormField.Type.jid_single);
    form.addReportedField("admin", "Description", FormField.Type.boolean_type);
    // Add group members the result
    for (JID memberJID : group.getMembers()) {
        Map<String, Object> fields = new HashMap<>();
        fields.put("jid", memberJID.toString());
        fields.put("admin", false);
        form.addItemFields(fields);
    }
    // Add group admins the result
    for (JID memberJID : group.getAdmins()) {
        Map<String, Object> fields = new HashMap<>();
        fields.put("jid", memberJID.toString());
        fields.put("admin", true);
        form.addItemFields(fields);
    }
    command.add(form.getElement());
}
Also used : Group(org.jivesoftware.openfire.group.Group) JID(org.xmpp.packet.JID) HashMap(java.util.HashMap) Element(org.dom4j.Element) DataForm(org.xmpp.forms.DataForm) GroupNotFoundException(org.jivesoftware.openfire.group.GroupNotFoundException)

Aggregations

DataForm (org.xmpp.forms.DataForm)81 FormField (org.xmpp.forms.FormField)67 Element (org.dom4j.Element)23 IQ (org.xmpp.packet.IQ)12 JID (org.xmpp.packet.JID)9 ArrayList (java.util.ArrayList)7 ClientSession (org.jivesoftware.openfire.session.ClientSession)6 HashMap (java.util.HashMap)4 List (java.util.List)4 Group (org.jivesoftware.openfire.group.Group)4 Date (java.util.Date)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3 MUCRoom (org.jivesoftware.openfire.muc.MUCRoom)3 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)3 XStream (com.thoughtworks.xstream.XStream)2 ParseException (java.text.ParseException)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 PacketException (org.jivesoftware.openfire.PacketException)2 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)2