Package org.xmpp.forms

Examples of org.xmpp.forms.DataForm


        // Save DataForm for usage
        saveDataForm(workgroup);
    }

    private void saveDataForm(Workgroup workgroup) {
        DataForm dataForm = new DataForm(DataForm.Type.form);
        WorkgroupForm form = getWebForm(workgroup);

        if (form.getTitle() != null) {
            dataForm.setTitle(form.getTitle());
        }

        if (form.getDescription() != null) {
            dataForm.addInstruction(form.getDescription());
        }

        List<FormElement> elems = new ArrayList<FormElement>();
        // Add normal elems
        int size = form.getFormElements().size();
        for (int j = 0; j < size; j++) {
            elems.add(form.getFormElementAt(j));
        }

        size = form.getHiddenVars().size();
        for (int k = 0; k < size; k++) {
            elems.add(form.getHiddenVars().get(k));
        }

        size = elems.size();

        for (int i = 0; i < size; i++) {
            FormElement elem = elems.get(i);

            FormField field = dataForm.addField();
            field.setLabel(elem.getLabel());
            field.setVariable(elem.getVariable());
            field.setRequired(elem.isRequired());

            if (elem.getDescription() != null) {
View Full Code Here


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

    @Override
  protected void addStageInformation(SessionData data, Element command) {
        DataForm form = new DataForm(DataForm.Type.form);
        form.setTitle("Adding a new workgroup");
        form.addInstruction("Fill out this form to add a workgroup.");

        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 name of the workgroup to be added");
        field.setVariable("name");
        field.setRequired(true);

        field = form.addField();
        field.setType(FormField.Type.text_multi);
        field.setLabel("Username of the members");
        field.setVariable("members");

        field = form.addField();
        field.setType(FormField.Type.text_single);
        field.setLabel("Description");
        field.setVariable("description");

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

        return 0;
    }

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

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

        //Do nothing since there are no stages
    }

    @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");

        field = form.addField();
        field.setLabel(getLabel());
        field.setVariable("onlineusersnum");
        // Make sure that we are only counting based on bareJIDs and not fullJIDs
        Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
        Set<String> users = new HashSet<String>(sessions.size());
        for (ClientSession session : sessions) {
            users.add(session.getAddress().toBareJID());
        }
        field.addValue(users.size());

        command.add(form.getElement());
    }
View Full Code Here

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

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

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

*/
public class PacketsNotification extends AdHocCommand {

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

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

    @Override
  protected void addStageInformation(SessionData data, Element command) {
        DataForm form = new DataForm(DataForm.Type.form);
        form.setTitle("Changing the share secret");
        form.addInstruction("Fill out this form to change the shared secret.");

        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_private);
        field.setLabel("The old shared secret");
        field.setVariable("oldSharedSecret");
        field.setRequired(true);

        field = form.addField();
        field.setType(FormField.Type.text_private);
        field.setLabel("The new shared secret");
        field.setVariable("newSharedSecret");
        field.setRequired(true);

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

        this.maxLeafNodes = maxLeafNodes;
    }


    public DataForm getConfigurationForm() {
        DataForm form = new DataForm(DataForm.Type.form);
        form.setTitle(LocaleUtils.getLocalizedString("pubsub.form.default.title"));
        form.addInstruction(LocaleUtils.getLocalizedString("pubsub.form.default.instruction"));
        // Add the form fields and configure them for edition

        FormField formField = form.addField();
        formField.setVariable("FORM_TYPE");
        formField.setType(FormField.Type.hidden);
        formField.addValue("http://jabber.org/protocol/pubsub#node_config");

        formField = form.addField();
        formField.setVariable("pubsub#subscribe");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.subscribe"));
        formField.addValue(subscriptionEnabled);

        formField = form.addField();
        formField.setVariable("pubsub#deliver_payloads");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.deliver_payloads"));
        formField.addValue(deliverPayloads);

        formField = form.addField();
        formField.setVariable("pubsub#notify_config");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.notify_config"));
        formField.addValue(notifyConfigChanges);

        formField = form.addField();
        formField.setVariable("pubsub#notify_delete");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.notify_delete"));
        formField.addValue(notifyDelete);

        formField = form.addField();
        formField.setVariable("pubsub#notify_retract");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.notify_retract"));
        formField.addValue(notifyRetract);

        formField = form.addField();
        formField.setVariable("pubsub#presence_based_delivery");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.presence_based"));
        formField.addValue(presenceBasedDelivery);

        if (leaf) {
            formField = form.addField();
            formField.setVariable("pubsub#send_item_subscribe");
            formField.setType(FormField.Type.boolean_type);
            formField.setLabel(
                    LocaleUtils.getLocalizedString("pubsub.form.conf.send_item_subscribe"));
            formField.addValue(sendItemSubscribe);

            formField = form.addField();
            formField.setVariable("pubsub#persist_items");
            formField.setType(FormField.Type.boolean_type);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.persist_items"));
            formField.addValue(persistPublishedItems);

            formField = form.addField();
            formField.setVariable("pubsub#max_items");
            formField.setType(FormField.Type.text_single);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.max_items"));
            formField.addValue(maxPublishedItems);

            formField = form.addField();
            formField.setVariable("pubsub#max_payload_size");
            formField.setType(FormField.Type.text_single);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.max_payload_size"));
            formField.addValue(maxPayloadSize);
        }

        formField = form.addField();
        formField.setVariable("pubsub#access_model");
        formField.setType(FormField.Type.list_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.access_model"));
        formField.addOption(null, AccessModel.authorize.getName());
        formField.addOption(null, AccessModel.open.getName());
        formField.addOption(null, AccessModel.presence.getName());
        formField.addOption(null, AccessModel.roster.getName());
        formField.addOption(null, AccessModel.whitelist.getName());
        formField.addValue(accessModel.getName());

        formField = form.addField();
        formField.setVariable("pubsub#publish_model");
        formField.setType(FormField.Type.list_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.publish_model"));
        formField.addOption(null, PublisherModel.publishers.getName());
        formField.addOption(null, PublisherModel.subscribers.getName());
        formField.addOption(null, PublisherModel.open.getName());
        formField.addValue(publisherModel.getName());

        formField = form.addField();
        formField.setVariable("pubsub#language");
        formField.setType(FormField.Type.text_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.language"));
        formField.addValue(language);

        formField = form.addField();
        formField.setVariable("pubsub#itemreply");
        formField.setType(FormField.Type.list_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.itemreply"));
        if (replyPolicy != null) {
            formField.addValue(replyPolicy.name());
        }

        if (!leaf) {
            formField = form.addField();
            formField.setVariable("pubsub#leaf_node_association_policy");
            formField.setType(FormField.Type.list_single);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.leaf_node_association"));
            formField.addOption(null, CollectionNode.LeafNodeAssociationPolicy.all.name());
            formField.addOption(null, CollectionNode.LeafNodeAssociationPolicy.owners.name());
            formField.addOption(null, CollectionNode.LeafNodeAssociationPolicy.whitelist.name());
            formField.addValue(associationPolicy.name());

            formField = form.addField();
            formField.setVariable("pubsub#leaf_nodes_max");
            formField.setType(FormField.Type.text_single);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.leaf_nodes_max"));
            formField.addValue(maxLeafNodes);
        }
View Full Code Here

    public DataForm getExtendedInfo(String name, String node, JID senderJID) {
        if (name != null && node == null) {
            // Answer the extended info of a given room
            MUCRoom room = getChatRoom(name);
            if (room != null && canDiscoverRoom(room)) {
                final DataForm dataForm = new DataForm(Type.result);

                final FormField fieldType = dataForm.addField();
                fieldType.setVariable("FORM_TYPE");
                fieldType.setType(FormField.Type.hidden);
                fieldType.addValue("http://jabber.org/protocol/muc#roominfo");

                final FormField fieldDescr = dataForm.addField();
                fieldDescr.setVariable("muc#roominfo_description");
                fieldDescr.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.desc"));
                fieldDescr.addValue(room.getDescription());

                final FormField fieldSubj = dataForm.addField();
                fieldSubj.setVariable("muc#roominfo_subject");
                fieldSubj.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.subject"));
                fieldSubj.addValue(room.getSubject());

                /*final FormField fieldOcc = dataForm.addField(); */
                fieldSubj.setVariable("muc#roominfo_occupants");
                fieldSubj.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.occupants"));
                fieldSubj.addValue(Integer.toString(room.getOccupantsCount()));

                /*field = new XFormFieldImpl("muc#roominfo_lang");
                field.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.language"));
                field.addValue(room.getLanguage());
                dataForm.addField(field);*/

                final FormField fieldDate = dataForm.addField();
                fieldDate.setVariable("x-muc#roominfo_creationdate");
                fieldDate.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.creationdate"));
                fieldDate.addValue(dateFormatter.format(room.getCreationDate()));

                return dataForm;
View Full Code Here

TOP

Related Classes of org.xmpp.forms.DataForm

Copyright © 2018 www.massapicom. 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.