Search in sources :

Example 61 with DataForm

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

the class VCardModified method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Dispatching a vCard updated event.");
    form.addInstruction("Fill out this form to dispatch a vCard updated 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 who's vCard was updated");
    field.setVariable("username");
    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 62 with DataForm

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

the class GetListGroups method execute.

@Override
public void execute(SessionData data, Element command) {
    String start = data.getData().get("start").get(0);
    String max_items = data.getData().get("max_items").get(0);
    int nStart = 0;
    if (start != null) {
        try {
            nStart = Integer.parseInt(start);
        } catch (NumberFormatException e) {
        // Do nothing. Assume default value
        }
    }
    int maxItems = 100000;
    if (max_items != null && !"none".equals(max_items)) {
        try {
            maxItems = Integer.parseInt(max_items);
        } catch (NumberFormatException e) {
        // Do nothing. Assume that all users are being requested
        }
    }
    DataForm form = new DataForm(DataForm.Type.result);
    form.addReportedField("name", "Name", FormField.Type.text_single);
    form.addReportedField("desc", "Description", FormField.Type.text_multi);
    form.addReportedField("count", "User Count", FormField.Type.text_single);
    form.addReportedField("shared", "Shared group?", FormField.Type.boolean_type);
    form.addReportedField("display", "Display Name", FormField.Type.text_single);
    form.addReportedField("visibility", "Visibility", FormField.Type.text_single);
    form.addReportedField("groups", "Show group to members' rosters of these groups", FormField.Type.text_multi);
    // Add groups to the result
    for (Group group : GroupManager.getInstance().getGroups(nStart, maxItems)) {
        boolean isSharedGroup = RosterManager.isSharedGroup(group);
        Map<String, String> properties = group.getProperties();
        Map<String, Object> fields = new HashMap<>();
        fields.put("name", group.getName());
        fields.put("desc", group.getDescription());
        fields.put("count", group.getMembers().size() + group.getAdmins().size());
        fields.put("shared", isSharedGroup);
        fields.put("display", (isSharedGroup ? properties.get("sharedRoster.displayName") : ""));
        String showInRoster = (isSharedGroup ? properties.get("sharedRoster.showInRoster") : "");
        if ("onlyGroup".equals(showInRoster) && properties.get("sharedRoster.groupList").trim().length() > 0) {
            // Show shared group to other groups
            showInRoster = "spefgroups";
        }
        fields.put("visibility", showInRoster);
        fields.put("groups", (isSharedGroup ? properties.get("sharedRoster.groupList") : ""));
        form.addItemFields(fields);
    }
    command.add(form.getElement());
}
Also used : Group(org.jivesoftware.openfire.group.Group) HashMap(java.util.HashMap) DataForm(org.xmpp.forms.DataForm)

Example 63 with DataForm

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

the class AddUser method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Adding a user");
    form.addInstruction("Fill out this form to add 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.jid_single);
    field.setLabel("The Jabber ID for the account to be added");
    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 = form.addField();
    field.setType(FormField.Type.text_private);
    field.setLabel("Retype password");
    field.setVariable("password-verify");
    field = form.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel("Email address");
    field.setVariable("email");
    field = form.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel("Given name");
    field.setVariable("given_name");
    field = form.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel("Family name");
    field.setVariable("surname");
    // Add the form to the command
    command.add(form.getElement());
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 64 with DataForm

use of org.xmpp.forms.DataForm 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’s 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 65 with DataForm

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

the class DeleteUser method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Deleting a user");
    form.addInstruction("Fill out this form to delete 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.jid_single);
    field.setLabel("The Jabber ID for the account to be deleted");
    field.setVariable("accountjid");
    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