Search in sources :

Example 66 with DataForm

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

the class AdHocCommandManager method saveCompletedForm.

/**
     * Stores in the SessionData the fields and their values as specified in the completed
     * data form by the user.
     *
     * @param iqCommand the command element containing the data form element.
     * @param session the SessionData for this command execution.
     */
private void saveCompletedForm(Element iqCommand, SessionData session) {
    Element formElement = iqCommand.element(QName.get("x", "jabber:x:data"));
    if (formElement != null) {
        // Generate a Map with the variable names and variables values
        Map<String, List<String>> data = new HashMap<>();
        DataForm dataForm = new DataForm(formElement);
        for (FormField field : dataForm.getFields()) {
            data.put(field.getVariable(), field.getValues());
        }
        // Store the variables and their values in the session data
        session.addStageForm(data);
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Element(org.dom4j.Element) DataForm(org.xmpp.forms.DataForm) List(java.util.List) FormField(org.xmpp.forms.FormField)

Example 67 with DataForm

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

the class AddGroup method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Create new group");
    form.addInstruction("Fill out this form to create a new 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);
    field = form.addField();
    field.setType(FormField.Type.text_multi);
    field.setLabel("Description");
    field.setVariable("desc");
    field = form.addField();
    field.setType(FormField.Type.jid_multi);
    field.setLabel("Initial members");
    field.setVariable("members");
    field = form.addField();
    field.setType(FormField.Type.list_single);
    field.setLabel("Shared group visibility");
    field.setVariable("showInRoster");
    field.addValue("nobody");
    field.addOption("Disable sharing group in rosters", "nobody");
    field.addOption("Show group in all users' rosters", "everybody");
    field.addOption("Show group in group members' rosters", "onlyGroup");
    field.addOption("Show group to members' rosters of these groups", "spefgroups");
    field.setRequired(true);
    field = form.addField();
    field.setType(FormField.Type.list_multi);
    field.setVariable("groupList");
    for (Group group : GroupManager.getInstance().getGroups()) {
        field.addOption(group.getName(), group.getName());
    }
    field = form.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel("Group Display Name");
    field.setVariable("displayName");
    // Add the form to the command
    command.add(form.getElement());
}
Also used : Group(org.jivesoftware.openfire.group.Group) DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 68 with DataForm

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

the class AddGroupUsers method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Add members or admins to a group");
    form.addInstruction("Fill out this form to add new members or admins to 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);
    field = form.addField();
    field.setType(FormField.Type.boolean_type);
    field.setLabel("Admin");
    field.setVariable("admin");
    field.addValue(false);
    field.setRequired(true);
    field = form.addField();
    field.setType(FormField.Type.jid_multi);
    field.setLabel("Users");
    field.setVariable("users");
    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 69 with DataForm

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

the class DeleteGroupUsers method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Delete members or admins from a group");
    form.addInstruction("Fill out this form to delete members or admins from 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);
    field = form.addField();
    field.setType(FormField.Type.jid_multi);
    field.setLabel("Users");
    field.setVariable("users");
    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 70 with DataForm

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

the class GetListGroupUsers method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Requesting List of Group Members");
    form.addInstruction("Fill out this form to request list of group members and admins.");
    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)

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