Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.DataForm$Item


     */
    public AdHocCommandData build(Map<String, String[]> parameters) {
        AdHocCommandData commandData = new AdHocCommandData();
        commandData.setSessionID(getSingleValue(parameters, AdminConsoleController.SESSION_FIELD));
       
        DataForm form = new DataForm("submit");
       
        for(Entry<String, String[]> entry : parameters.entrySet()) {
            if(!AdminConsoleController.SESSION_FIELD.equals(entry.getKey())) {
                FormField field = new FormField(entry.getKey());
                for(String value : entry.getValue()) {
                    String[] splitValues = value.split("[\\r\\n]+");
                    for(String splitValue : splitValues) {
                        field.addValue(splitValue);
                    }
                }
                form.addField(field);
            }
        }
       
        commandData.setForm(form);
       
View Full Code Here


    public static ReportedData getReportedDataFrom(Packet packet) {
        // Check if the packet includes the DataForm extension
        PacketExtension packetExtension = packet.getExtension("x","jabber:x:data");
        if (packetExtension != null) {
            // Check if the existing DataForm is a result of a search
            DataForm dataForm = (DataForm) packetExtension;
            if (dataForm.getReportedData() != null)
                return new ReportedData(dataForm);
        }
        // Otherwise return null
        return null;
    }
View Full Code Here

    public static Form getFormFrom(Packet packet) {
        // Check if the packet includes the DataForm extension
        PacketExtension packetExtension = packet.getExtension("x","jabber:x:data");
        if (packetExtension != null) {
            // Check if the existing DataForm is not a result of a search
            DataForm dataForm = (DataForm) packetExtension;
            if (dataForm.getReportedData() == null)
                return new Form(dataForm);
        }
        // Otherwise return null
        return null;
    }
View Full Code Here

     * </ul>
     *
     * @param type the form's type (e.g. form, submit,cancel,result).
     */
    public Form(String type) {
        this.dataForm = new DataForm(type);
    }
View Full Code Here

     * @return the wrapped DataForm.
     */
    public DataForm getDataFormToSend() {
        if (isSubmitType()) {
            // Create a new DataForm that contains only the answered fields
            DataForm dataFormToSend = new DataForm(getType());
            for(Iterator<FormField> it=getFields();it.hasNext();) {
                FormField field = it.next();
                if (field.getValues().hasNext()) {
                    dataFormToSend.addField(field);
                }
            }
            return dataFormToSend;
        }
        return dataForm;
View Full Code Here

            return simpleUserSearch;
        }
    }

    private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception {
        DataForm dataForm = new DataForm(Form.TYPE_FORM);
        boolean done = false;
        dataForm.setTitle("User Search");
        dataForm.addInstruction(instructions);
        while (!done) {
            int eventType = parser.next();

            if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
                String name = parser.getName();
                FormField field = new FormField(name);

                // Handle hard coded values.
                if(name.equals("first")){
                    field.setLabel("First Name");
                }
                else if(name.equals("last")){
                    field.setLabel("Last Name");
                }
                else if(name.equals("email")){
                    field.setLabel("Email Address");
                }
                else if(name.equals("nick")){
                    field.setLabel("Nickname");
                }

                field.setType(FormField.TYPE_TEXT_SINGLE);
                dataForm.addField(field);
            }
            else if (eventType == XmlPullParser.END_TAG) {
                if (parser.getName().equals("query")) {
                    done = true;
                }
View Full Code Here

public class RoomInfoTest
{
    @Test
    public void validateRoomWithEmptyForm()
    {
  DataForm dataForm = new DataForm("result");
 
  DiscoverInfo discoInfo = new DiscoverInfo();
  discoInfo.addExtension(dataForm);
  RoomInfo roomInfo = new RoomInfo(discoInfo);
  assertTrue(roomInfo.getDescription().isEmpty());
View Full Code Here

    }

    @Test
    public void validateRoomWithForm()
    {
  DataForm dataForm = new DataForm("result");
 
  FormField desc = new FormField("muc#roominfo_description");
  desc.addValue("The place for all good witches!");
  dataForm.addField(desc);

  FormField subject = new FormField("muc#roominfo_subject");
  subject.addValue("Spells");
  dataForm.addField(subject);

  FormField occupants = new FormField("muc#roominfo_occupants");
  occupants.addValue("3");
  dataForm.addField(occupants);

  DiscoverInfo discoInfo = new DiscoverInfo();
  discoInfo.addExtension(dataForm);
  RoomInfo roomInfo = new RoomInfo(discoInfo);
  assertEquals("The place for all good witches!", roomInfo.getDescription());
View Full Code Here

        response.setTo(streamInitiationOffer.getFrom());
        response.setFrom(streamInitiationOffer.getTo());
        response.setType(IQ.Type.RESULT);
        response.setPacketID(streamInitiationOffer.getPacketID());

        DataForm form = new DataForm(Form.TYPE_SUBMIT);
        FormField field = new FormField(
                FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
        for (String namespace : namespaces) {
            field.addValue(namespace);
        }
        form.addField(field);

        response.setFeatureNegotiationForm(form);
        return response;
    }
View Full Code Here

            return inbandTransferManager;
        }
    }

    private DataForm createDefaultInitiationForm() {
        DataForm form = new DataForm(Form.TYPE_FORM);
        FormField field = new FormField(STREAM_DATA_FIELD_NAME);
        field.setType(FormField.TYPE_LIST_SINGLE);
        if (!IBB_ONLY) {
            field.addOption(new FormField.Option(Socks5BytestreamManager.NAMESPACE));
        }
        field.addOption(new FormField.Option(InBandBytestreamManager.NAMESPACE));
        form.addField(field);
        return form;
    }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.DataForm$Item

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.