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);
}
}
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());
}
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());
}
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());
}
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());
}
Aggregations