Package org.xmpp.forms

Examples of org.xmpp.forms.FormField


      {
        names.add(field.getFirstValue());
      }
    }

    final FormField matchFF = df.getField("name_is_exact_match");
    if (matchFF != null)
    {
      final String b = matchFF.getFirstValue();
      if (b != null)
      {
        name_is_exact_match = b.equals("1")
            || b.equalsIgnoreCase("true")
            || b.equalsIgnoreCase("yes");
      }
    }

    final FormField subjectFF = df.getField("subject");
    if (subjectFF != null)
    {
      subject = subjectFF.getFirstValue();
    }

    try
    {
      final FormField userAmountFF = df.getField("num_users");
      if (userAmountFF != null)
      {
                String value = userAmountFF.getFirstValue();
                if (value != null && !"".equals(value)) {
                    numusers = Integer.parseInt(value);
                }
      }

      final FormField maxUsersFF = df.getField("num_max_users");
      if (maxUsersFF != null)
      {
                String value = maxUsersFF.getFirstValue();
                if (value != null && !"".equals(value)) {
                    numaxusers = Integer.parseInt(value);
                }
            }
    }
    catch (NumberFormatException e)
    {
      reply.setError(PacketError.Condition.bad_request);
      return reply;
    }

    final FormField includePasswordProtectedRoomsFF = df.getField("include_password_protected");
    if (includePasswordProtectedRoomsFF != null)
    {
      final String b = includePasswordProtectedRoomsFF.getFirstValue();
      if (b != null)
      {
        if (b.equals("0") || b.equalsIgnoreCase("false")
            || b.equalsIgnoreCase("no"))
        {
View Full Code Here


        // Configure the search form that will be sent to the agents
        this.searchForm = new DataForm(DataForm.Type.form);
        this.searchForm.setTitle("Chat search");
        this.searchForm.addInstruction("Fill out this form to search for chats");
        // Add starting date
        FormField field = this.searchForm.addField();
        field.setType(FormField.Type.text_single);
        field.setLabel("Starting Date");
        field.setVariable("date/start");
        // Add ending date
        field = this.searchForm.addField();
        field.setType(FormField.Type.text_single);
        field.setLabel("Ending Date");
        field.setVariable("date/end");
        // Add workgroup JID
        field = this.searchForm.addField();
        field.setType(FormField.Type.jid_multi);
        field.setLabel("Workgroup");
        field.setVariable("workgroups");
        // Add agent JID
        field = this.searchForm.addField();
        field.setType(FormField.Type.jid_single);
        field.setLabel("Agent");
        field.setVariable("agent");
        // Add query string
        field = this.searchForm.addField();
        field.setType(FormField.Type.text_single);
        field.setLabel("Search Terms");
        field.setVariable("queryString");
        field.setRequired(true);

        // Configure the form that will hold the search results
        this.resultForm = new DataForm(DataForm.Type.result);
        this.resultForm.addReportedField("workgroup", null, FormField.Type.jid_single);
        this.resultForm.addReportedField("sessionID", null, FormField.Type.text_single);
View Full Code Here

        if (!persistPublishedItems) {
            // Always save the last published item when not configured to use persistent items
            maxPublishedItems = 1;
        }
        else {
            FormField field = completedForm.getField("pubsub#max_items");
            if (field != null) {
                values = field.getValues();
                maxPublishedItems = values.size() > 0 ? Integer.parseInt(values.get(0)) : 50;
            }
        }
        synchronized (publishedItems) {
            // Remove stored published items based on the new max items
View Full Code Here

    @Override
  protected void addFormFields(DataForm form, boolean isEditing) {
        super.addFormFields(form, isEditing);

        FormField formField = form.addField();
        formField.setVariable("pubsub#send_item_subscribe");
        if (isEditing) {
            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");
        if (isEditing) {
            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");
        if (isEditing) {
            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");
        if (isEditing) {
            formField.setType(FormField.Type.text_single);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.max_payload_size"));
        }
        formField.addValue(maxPayloadSize);

    }
View Full Code Here

            FormField.Type.text_single)
            .setRequired(true);
       

        for (String searchField : getFilteredSearchFields()) {
          final FormField field = searchForm.addField();
            field.setVariable(searchField);
            field.setType(FormField.Type.boolean_type);
            field.addValue("1");
            field.setLabel(LocaleUtils.getLocalizedString(
                "advance.user.search." + searchField.toLowerCase(), "search"));
            field.setRequired(false);
        }

        queryResult.add(searchForm.getElement());
        replyPacket.setChildElement(queryResult);
View Full Code Here

        boolean wasUsingPresence = !presenceStates.isEmpty();

        // Remove this field from the form
        options.removeField("FORM_TYPE");
        // Process and remove specific collection node fields
        FormField collectionField = options.getField("pubsub#subscription_type");
        if (collectionField != null) {
            values = collectionField.getValues();
            if (values.size() > 0)  {
                type = Type.valueOf(values.get(0));
            }
            options.removeField("pubsub#subscription_type");
        }
        collectionField = options.getField("pubsub#subscription_depth");
        if (collectionField != null) {
            values = collectionField.getValues();
            depth = "all".equals(values.get(0)) ? 0 : 1;
            options.removeField("pubsub#subscription_depth");
        }
        // If there are more fields in the form then process them and set that
        // the subscription has been configured
View Full Code Here

        form.setTitle(LocaleUtils.getLocalizedString("pubsub.form.subscription.title"));
        List<String> params = new ArrayList<String>();
        params.add(node.getNodeID());
        form.addInstruction(LocaleUtils.getLocalizedString("pubsub.form.subscription.instruction", params));
        // 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#subscribe_options");

        formField = form.addField();
        formField.setVariable("pubsub#deliver");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.deliver"));
        formField.addValue(deliverNotifications);

        formField = form.addField();
        formField.setVariable("pubsub#digest");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.digest"));
        formField.addValue(usingDigest);

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

        formField = form.addField();
        formField.setVariable("pubsub#expire");
        formField.setType(FormField.Type.text_single);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.expire"));
        if (expire != null) {
            formField.addValue(fastDateFormat.format(expire));
        }

        formField = form.addField();
        formField.setVariable("pubsub#include_body");
        formField.setType(FormField.Type.boolean_type);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.include_body"));
        formField.addValue(includingBody);

        formField = form.addField();
        formField.setVariable("pubsub#show-values");
        formField.setType(FormField.Type.list_multi);
        formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.show-values"));
        formField.addOption(null, Presence.Show.away.name());
        formField.addOption(null, Presence.Show.chat.name());
        formField.addOption(null, Presence.Show.dnd.name());
        formField.addOption(null, "online");
        formField.addOption(null, Presence.Show.xa.name());
        for (String value : presenceStates) {
            formField.addValue(value);
        }

        if (node.isCollectionNode()) {
            formField = form.addField();
            formField.setVariable("pubsub#subscription_type");
            formField.setType(FormField.Type.list_single);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.subscription_type"));
            formField.addOption(null, Type.items.name());
            formField.addOption(null, Type.nodes.name());
            formField.addValue(type);

            formField = form.addField();
            formField.setVariable("pubsub#subscription_depth");
            formField.setType(FormField.Type.list_single);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.subscription_depth"));
            formField.addOption(null, "1");
            formField.addOption(null, "all");
            formField.addValue(depth == 1 ? "1" : "all");
        }

        if (!node.isCollectionNode() || type == Type.items) {
            formField = form.addField();
            formField.setVariable("x-pubsub#keywords");
            formField.setType(FormField.Type.text_single);
            formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.subscription.keywords"));
            if (keyword != null) {
                formField.addValue(keyword);
            }
        }

        return form;
    }
View Full Code Here

            final DataForm registrationForm = new DataForm(DataForm.Type.form);
            registrationForm.setTitle(LocaleUtils.getLocalizedString("muc.form.reg.title"));
            registrationForm.addInstruction(LocaleUtils
                    .getLocalizedString("muc.form.reg.instruction"));

            final FormField fieldForm = registrationForm.addField();
            fieldForm.setVariable("FORM_TYPE");
            fieldForm.setType(FormField.Type.hidden);
            fieldForm.addValue("http://jabber.org/protocol/muc#register");

            final FormField fieldReg = registrationForm.addField();
            fieldReg.setVariable("muc#register_first");
            fieldReg.setType(FormField.Type.text_single);
            fieldReg.setLabel(LocaleUtils.getLocalizedString("muc.form.reg.first-name"));
            fieldReg.setRequired(true);

            final FormField fieldLast = registrationForm.addField();
            fieldLast.setVariable("muc#register_last");
            fieldLast.setType(FormField.Type.text_single);
            fieldLast.setLabel(LocaleUtils.getLocalizedString("muc.form.reg.last-name"));
            fieldLast.setRequired(true);

            final FormField fieldNick = registrationForm.addField();
            fieldNick.setVariable("muc#register_roomnick");
            fieldNick.setType(FormField.Type.text_single);
            fieldNick.setLabel(LocaleUtils.getLocalizedString("muc.form.reg.nickname"));
            fieldNick.setRequired(true);

            final FormField fieldUrl = registrationForm.addField();
            fieldUrl.setVariable("muc#register_url");
            fieldUrl.setType(FormField.Type.text_single);
            fieldUrl.setLabel(LocaleUtils.getLocalizedString("muc.form.reg.url"));

            final FormField fieldMail = registrationForm.addField();
            fieldMail.setVariable("muc#register_email");
            fieldMail.setType(FormField.Type.text_single);
            fieldMail.setLabel(LocaleUtils.getLocalizedString("muc.form.reg.email"));

            final FormField fieldFaq = registrationForm.addField();
            fieldFaq.setVariable("muc#register_faqentry");
            fieldFaq.setType(FormField.Type.text_single);
            fieldFaq.setLabel(LocaleUtils.getLocalizedString("muc.form.reg.faqentry"));

            // Create the probeResult and add the registration form
            probeResult = DocumentHelper.createElement(QName.get("query", "jabber:iq:register"));
            probeResult.add(registrationForm.getElement());
        }
View Full Code Here

        DataForm form = new DataForm(DataForm.Type.form);
        form.setTitle(LocaleUtils.getLocalizedString("pubsub.command.pending-subscriptions.title"));
        form.addInstruction(
                LocaleUtils.getLocalizedString("pubsub.command.pending-subscriptions.instruction"));

        FormField formField = form.addField();
        formField.setVariable("pubsub#node");
        formField.setType(FormField.Type.list_single);
        formField.setLabel(
                LocaleUtils.getLocalizedString("pubsub.command.pending-subscriptions.node"));
        for (Node node : service.getNodes()) {
            if (!node.isCollectionNode() && node.isAdmin(data.getOwner())) {
                formField.addOption(null, node.getNodeID());
            }
        }
        // Add the form to the command
        command.add(form.getElement());
    }
View Full Code Here

     */
    private void processConfigurationForm(DataForm completedForm, MUCRole senderRole)
            throws ForbiddenException, ConflictException {
        List<String> values;
        String booleanValue;
        FormField field;

        // Get the new list of admins
        field = completedForm.getField("muc#roomconfig_roomadmins");
        boolean adminsSent = field != null;
        List<String> admins = new ArrayList<String>();
        if (field != null) {
          admins.addAll(field.getValues());
        }

        // Get the new list of owners
        field = completedForm.getField("muc#roomconfig_roomowners");
        boolean ownersSent = field != null;
        List<String> owners = new ArrayList<String>();
        if (field != null) {
          owners.addAll(field.getValues());
        }

        // Answer a conflic error if all the current owners will be removed
        if (ownersSent && owners.isEmpty()) {
            throw new ConflictException();
        }

        // Keep a registry of the updated presences
        List<Presence> presences = new ArrayList<Presence>(admins.size() + owners.size());

        field = completedForm.getField("muc#roomconfig_roomname");
        if (field != null) {
            final String value = field.getFirstValue();
            room.setNaturalLanguageName((value != null ? value : " "));
        }

        field = completedForm.getField("muc#roomconfig_roomdesc");
        if (field != null) {
            final String value = field.getFirstValue();
            room.setDescription((value != null ? value : " "));
        }

        field = completedForm.getField("muc#roomconfig_changesubject");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setCanOccupantsChangeSubject(("1".equals(booleanValue)));
        }

        field = completedForm.getField("muc#roomconfig_maxusers");
        if (field != null) {
            final String value = field.getFirstValue();
            room.setMaxUsers((value != null ? Integer.parseInt(value) : 30));
        }

        field = completedForm.getField("muc#roomconfig_presencebroadcast");
        if (field != null) {
            values = new ArrayList<String>(field.getValues());
            room.setRolesToBroadcastPresence(values);
        }

        field = completedForm.getField("muc#roomconfig_publicroom");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setPublicRoom(("1".equals(booleanValue)));
        }

        field = completedForm.getField("muc#roomconfig_persistentroom");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            boolean isPersistent = ("1".equals(booleanValue));
            // Delete the room from the DB if it's no longer persistent
            if (room.isPersistent() && !isPersistent) {
                MUCPersistenceManager.deleteFromDB(room);
            }
            room.setPersistent(isPersistent);
        }

        field = completedForm.getField("muc#roomconfig_moderatedroom");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setModerated(("1".equals(booleanValue)));
        }

        field = completedForm.getField("muc#roomconfig_membersonly");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            presences.addAll(room.setMembersOnly(("1".equals(booleanValue))));
        }

        field = completedForm.getField("muc#roomconfig_allowinvites");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setCanOccupantsInvite(("1".equals(booleanValue)));
        }

        field = completedForm.getField("muc#roomconfig_passwordprotectedroom");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            boolean isPasswordProtected = "1".equals(booleanValue);
            if (isPasswordProtected) {
                // The room is password protected so set the new password
                field = completedForm.getField("muc#roomconfig_roomsecret");
                if (field != null) {
                    final String secret = completedForm.getField("muc#roomconfig_roomsecret").getFirstValue();
                    room.setPassword(secret);
                }
            }
            else {
                // The room is not password protected so remove any previous password
                room.setPassword(null);
            }
        }

        field = completedForm.getField("muc#roomconfig_whois");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setCanAnyoneDiscoverJID(("anyone".equals(booleanValue)));
        }

        field = completedForm.getField("muc#roomconfig_enablelogging");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setLogEnabled(("1".equals(booleanValue)));
        }

        field = completedForm.getField("x-muc#roomconfig_reservednick");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setLoginRestrictedToNickname(("1".equals(booleanValue)));
        }

        field = completedForm.getField("x-muc#roomconfig_canchangenick");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setChangeNickname(("1".equals(booleanValue)));
        }

        field = completedForm.getField("x-muc#roomconfig_registration");
        if (field != null) {
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
            room.setRegistrationEnabled(("1".equals(booleanValue)));
        }

        // Update the modification date to reflect the last time when the room's configuration
View Full Code Here

TOP

Related Classes of org.xmpp.forms.FormField

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.