Examples of DataForm


Examples of org.xmpp.forms.DataForm

        note.setText("Operation finished successfully");
    }

    @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());
    }
View Full Code Here

Examples of org.xmpp.forms.DataForm

* TODO Use i18n
*/
public class UpdateGroup extends AdHocCommand {
    @Override
  protected void addStageInformation(SessionData data, Element command) {
        DataForm form = new DataForm(DataForm.Type.form);
        if (data.getStage() == 0) {
            form.setTitle("Update group configuration");
            form.addInstruction("Fill out this form to specify the group to update.");

            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);
        }
        else {

            // Check if groups cannot be modified (backend is read-only)
            if (GroupManager.getInstance().isReadOnly()) {
                Element note = command.addElement("note");
                note.addAttribute("type", "error");
                note.setText("Groups are read only");
                return;
            }
            // Get requested group
            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 not found");
                return;
            }

            form.setTitle("Update group configuration");
            form.addInstruction("Fill out this form with the new group configuration.");

            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_multi);
            field.setLabel("Description");
            field.setVariable("desc");
            if (group.getDescription() != null) {
                field.addValue(group.getDescription());
            }

            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);
            String showInRoster = group.getProperties().get("sharedRoster.showInRoster");
            if (showInRoster != null) {
                if ("onlyGroup".equals(showInRoster) &&
                        group.getProperties().get("sharedRoster.groupList").trim().length() > 0) {
                    // Show shared group to other groups
                    showInRoster = "spefgroups";
                }
                field.addValue(showInRoster);
            }


            field = form.addField();
            field.setType(FormField.Type.list_multi);
            field.setVariable("groupList");
            for (Group otherGroup : GroupManager.getInstance().getGroups()) {
                field.addOption(otherGroup.getName(), otherGroup.getName());
            }
            String groupList = group.getProperties().get("sharedRoster.groupList");
            if (groupList != null) {
                Collection<String> groups = new ArrayList<String>();
                StringTokenizer tokenizer = new StringTokenizer(groupList,",\t\n\r\f");
                while (tokenizer.hasMoreTokens()) {
                    String tok = tokenizer.nextToken().trim();
                    groups.add(tok.trim());
                }
                for (String othergroup : groups) {
                    field.addValue(othergroup);
                }
            }

            field = form.addField();
            field.setType(FormField.Type.text_single);
            field.setLabel("Group Display Name");
            field.setVariable("displayName");
            String displayName = group.getProperties().get("sharedRoster.displayName");
            if (displayName != null) {
                field.addValue(displayName);
            }
        }

        // Add the form to the command
        command.add(form.getElement());
    }
View Full Code Here

Examples of org.xmpp.forms.DataForm

 
  private static final Logger Log = LoggerFactory.getLogger(AddGroupUsers.class);

    @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());
    }
View Full Code Here

Examples of org.xmpp.forms.DataForm

 
  private static final Logger Log = LoggerFactory.getLogger(AddGroup.class);

    @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());
    }
View Full Code Here

Examples of org.xmpp.forms.DataForm

          // discovery broadcasts the disco#info feature.
          queryElement.addElement("feature").addAttribute("var", NAMESPACE_DISCO_INFO);
        }
               
                // Add to the reply the extended info (XDataForm) provided by the DiscoInfoProvider
                DataForm dataForm = infoProvider.getExtendedInfo(name, node, packet.getFrom());
                if (dataForm != null) {
                    queryElement.add(dataForm.getElement());
                }
            }
            else {
                // If the DiscoInfoProvider has no information for the requested name and node
                // then answer a not found error
View Full Code Here

Examples of org.xmpp.forms.DataForm

        note.setText("Operation finished successfully");
    }

    @Override
  protected void addStageInformation(SessionData data, Element command) {
        DataForm form = new DataForm(DataForm.Type.form);
        form.setTitle("Dispatching a group admin removed event.");
        form.addInstruction("Fill out this form to dispatch a group admin removed 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");
        field.setVariable("groupName");
        field.setRequired(true);

        field = form.addField();
        field.setType(FormField.Type.text_single);
        field.setLabel("The username of the admin");
        field.setVariable("admin");
        field.setRequired(true);

        // Add the form to the command
        command.add(form.getElement());
    }
View Full Code Here

Examples of org.xmpp.forms.DataForm

* TODO Use i18n
*/
public class GetListGroupUsers extends AdHocCommand {
    @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());
    }
View Full Code Here

Examples of org.xmpp.forms.DataForm

            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<String,Object>();
            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<String,Object>();
            fields.put("jid", memberJID.toString());
            fields.put("admin", true);
            form.addItemFields(fields);
        }
        command.add(form.getElement());
    }
View Full Code Here

Examples of org.xmpp.forms.DataForm

*/
public class GetListGroups extends AdHocCommand {

    @Override
  protected void addStageInformation(SessionData data, Element command) {
        DataForm form = new DataForm(DataForm.Type.form);
        form.setTitle("Requesting List of Existing Groups");
        form.addInstruction("Fill out this form to request list of groups.");

        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_single);
        field.setLabel("Start from page number");
        field.setVariable("start");
        field.addValue("0");
        field.addOption("0", "0");
        field.addOption("25", "25");
        field.addOption("50", "50");
        field.addOption("75", "75");
        field.addOption("100", "100");
        field.addOption("150", "150");
        field.addOption("200", "200");
        field.setRequired(true);

        field = form.addField();
        field.setType(FormField.Type.list_single);
        field.setLabel("Maximum number of items to show");
        field.setVariable("max_items");
        field.addValue("25");
        field.addOption("25", "25");
        field.addOption("50", "50");
        field.addOption("75", "75");
        field.addOption("100", "100");
        field.addOption("150", "150");
        field.addOption("200", "200");
        field.addOption("None", "none");
        field.setRequired(true);

        // Add the form to the command
        command.add(form.getElement());
    }
View Full Code Here

Examples of org.xmpp.forms.DataForm

            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<String,Object>();
            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());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.