Exemplo n.º 1
0
  private void init() {
    Element element =
        DocumentHelper.createElement(QName.get("query", "http://jabber.org/protocol/muc#owner"));

    configurationForm = new DataForm(DataForm.Type.form);
    configurationForm.setTitle(LocaleUtils.getLocalizedString("muc.form.conf.title"));
    List<String> params = new ArrayList<String>();
    params.add(room.getName());
    configurationForm.addInstruction(
        LocaleUtils.getLocalizedString("muc.form.conf.instruction", params));

    configurationForm
        .addField("FORM_TYPE", null, Type.hidden)
        .addValue("http://jabber.org/protocol/muc#roomconfig");

    configurationForm.addField(
        "muc#roomconfig_roomname",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_roomname"),
        Type.text_single);

    configurationForm.addField(
        "muc#roomconfig_roomdesc",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_roomdesc"),
        Type.text_single);

    configurationForm.addField(
        "muc#roomconfig_changesubject",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_changesubject"),
        Type.boolean_type);

    final FormField maxUsers =
        configurationForm.addField(
            "muc#roomconfig_maxusers",
            LocaleUtils.getLocalizedString("muc.form.conf.owner_maxusers"),
            Type.list_single);
    maxUsers.addOption("10", "10");
    maxUsers.addOption("20", "20");
    maxUsers.addOption("30", "30");
    maxUsers.addOption("40", "40");
    maxUsers.addOption("50", "50");
    maxUsers.addOption(LocaleUtils.getLocalizedString("muc.form.conf.none"), "0");

    final FormField broadcast =
        configurationForm.addField(
            "muc#roomconfig_presencebroadcast",
            LocaleUtils.getLocalizedString("muc.form.conf.owner_presencebroadcast"),
            Type.list_multi);
    broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.moderator"), "moderator");
    broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.participant"), "participant");
    broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.visitor"), "visitor");

    configurationForm.addField(
        "muc#roomconfig_publicroom",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_publicroom"),
        Type.boolean_type);

    configurationForm.addField(
        "muc#roomconfig_persistentroom",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_persistentroom"),
        Type.boolean_type);

    configurationForm.addField(
        "muc#roomconfig_moderatedroom",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_moderatedroom"),
        Type.boolean_type);

    configurationForm.addField(
        "muc#roomconfig_membersonly",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_membersonly"),
        Type.boolean_type);

    configurationForm
        .addField(null, null, Type.fixed)
        .addValue(LocaleUtils.getLocalizedString("muc.form.conf.allowinvitesfixed"));

    configurationForm.addField(
        "muc#roomconfig_allowinvites",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_allowinvites"),
        Type.boolean_type);

    configurationForm.addField(
        "muc#roomconfig_passwordprotectedroom",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_passwordprotectedroom"),
        Type.boolean_type);

    configurationForm
        .addField(null, null, Type.fixed)
        .addValue(LocaleUtils.getLocalizedString("muc.form.conf.roomsecretfixed"));

    configurationForm.addField(
        "muc#roomconfig_roomsecret",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_roomsecret"),
        Type.text_private);

    final FormField whois =
        configurationForm.addField(
            "muc#roomconfig_whois",
            LocaleUtils.getLocalizedString("muc.form.conf.owner_whois"),
            Type.list_single);
    whois.addOption(LocaleUtils.getLocalizedString("muc.form.conf.moderator"), "moderators");
    whois.addOption(LocaleUtils.getLocalizedString("muc.form.conf.anyone"), "anyone");

    configurationForm.addField(
        "muc#roomconfig_enablelogging",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_enablelogging"),
        Type.boolean_type);

    configurationForm.addField(
        "x-muc#roomconfig_reservednick",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_reservednick"),
        Type.boolean_type);

    configurationForm.addField(
        "x-muc#roomconfig_canchangenick",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_canchangenick"),
        Type.boolean_type);

    configurationForm
        .addField(null, null, Type.fixed)
        .addValue(LocaleUtils.getLocalizedString("muc.form.conf.owner_registration"));

    configurationForm.addField(
        "x-muc#roomconfig_registration",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_registration"),
        Type.boolean_type);

    configurationForm
        .addField(null, null, Type.fixed)
        .addValue(LocaleUtils.getLocalizedString("muc.form.conf.roomadminsfixed"));

    configurationForm.addField(
        "muc#roomconfig_roomadmins",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_roomadmins"),
        Type.jid_multi);

    configurationForm
        .addField(null, null, Type.fixed)
        .addValue(LocaleUtils.getLocalizedString("muc.form.conf.roomownersfixed"));

    configurationForm.addField(
        "muc#roomconfig_roomowners",
        LocaleUtils.getLocalizedString("muc.form.conf.owner_roomowners"),
        Type.jid_multi);

    // Create the probeResult and add the basic info together with the configuration form
    probeResult = element;
    probeResult.add(configurationForm.getElement());
  }
Exemplo n.º 2
0
  /**
   * Returns a data form with the subscription configuration. The data form can be used to edit the
   * subscription configuration.
   *
   * @return data form used by the subscriber to edit the subscription configuration.
   */
  public DataForm getConfigurationForm() {
    DataForm form = new DataForm(DataForm.Type.form);
    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;
  }