Search in sources :

Example 91 with FormField

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

the class GetListActiveUsers method addStageInformation.

@Override
protected void addStageInformation(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.form);
    form.setTitle("Requesting List of Active Users");
    form.addInstruction("Fill out this form to request the active users of this service.");
    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("Maximum number of items to show");
    field.setVariable("max_items");
    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");
    // Add the form to the command
    command.add(form.getElement());
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 92 with FormField

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

the class MultiUserChatServiceImpl method getExtendedInfos.

@Override
public Set<DataForm> getExtendedInfos(String name, String node, JID senderJID) {
    if (name != null && node == null) {
        // Answer the extended info of a given room
        final MUCRoom room = getChatRoom(name);
        if (room != null) {
            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.setType(FormField.Type.text_single);
            fieldDescr.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.desc"));
            fieldDescr.addValue(room.getDescription());
            final FormField fieldSubj = dataForm.addField();
            fieldSubj.setVariable("muc#roominfo_subject");
            fieldSubj.setType(FormField.Type.text_single);
            fieldSubj.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.subject"));
            fieldSubj.addValue(room.getSubject());
            final FormField fieldOcc = dataForm.addField();
            fieldOcc.setVariable("muc#roominfo_occupants");
            fieldOcc.setType(FormField.Type.text_single);
            fieldOcc.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.occupants"));
            fieldOcc.addValue(Integer.toString(room.getOccupantsCount()));
            /*field = new XFormFieldImpl("muc#roominfo_lang");
                field.setType(FormField.Type.text_single);
                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.setType(FormField.Type.text_single);
            fieldDate.setLabel(LocaleUtils.getLocalizedString("muc.extended.info.creationdate"));
            fieldDate.addValue(XMPPDateTimeFormat.format(room.getCreationDate()));
            final Set<DataForm> dataForms = new HashSet<>();
            dataForms.add(dataForm);
            return dataForms;
        }
    }
    return new HashSet<>();
}
Also used : MUCRoom(org.jivesoftware.openfire.muc.MUCRoom) DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Aggregations

FormField (org.xmpp.forms.FormField)92 DataForm (org.xmpp.forms.DataForm)80 Element (org.dom4j.Element)21 JID (org.xmpp.packet.JID)13 IQ (org.xmpp.packet.IQ)7 HashSet (java.util.HashSet)6 ClientSession (org.jivesoftware.openfire.session.ClientSession)6 ArrayList (java.util.ArrayList)4 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)4 ParseException (java.text.ParseException)3 Date (java.util.Date)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3 Group (org.jivesoftware.openfire.group.Group)3 Test (org.junit.Test)3 List (java.util.List)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 PacketException (org.jivesoftware.openfire.PacketException)2 GroupJID (org.jivesoftware.openfire.group.GroupJID)2 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)2 MUCRoom (org.jivesoftware.openfire.muc.MUCRoom)2