Search in sources :

Example 41 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project xabber-android by redsolution.

the class Feature method getSecurityOptions.

public Collection<SecurityValue> getSecurityOptions() {
    FormField field = getField(SECURITY_FIELD);
    if (field == null) {
        return null;
    }
    Collection<SecurityValue> collection = new ArrayList<>();
    List<FormField.Option> options = field.getOptions();
    for (FormField.Option option : options) {
        collection.add(SecurityValue.fromString(option.getValue()));
    }
    return collection;
}
Also used : ArrayList(java.util.ArrayList) FormField(org.jivesoftware.smackx.xdata.FormField)

Example 42 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project xabber-android by redsolution.

the class Feature method getLoggingOptions.

public Collection<LoggingValue> getLoggingOptions() {
    FormField field = getField(LOGGING_FIELD);
    if (field == null) {
        return null;
    }
    Collection<LoggingValue> collection = new ArrayList<>();
    List<FormField.Option> options = field.getOptions();
    for (FormField.Option option : options) {
        collection.add(LoggingValue.fromString(option.getValue()));
    }
    return collection;
}
Also used : ArrayList(java.util.ArrayList) FormField(org.jivesoftware.smackx.xdata.FormField)

Example 43 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project xabber-android by redsolution.

the class Feature method createDataForm.

public static DataForm createDataForm(DataFormType type) {
    DataForm dataForm = new DataForm(DataForm.Type.fromString(type.toString()));
    FormField typeField = new FormField(FORM_TYPE_FIELD);
    typeField.addValue(FORM_TYPE_VALUE);
    typeField.setType(FormField.Type.hidden);
    dataForm.addField(typeField);
    return dataForm;
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) FormField(org.jivesoftware.smackx.xdata.FormField)

Example 44 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project xabber-android by redsolution.

the class Feature method addRequiredBooleanField.

private static void addRequiredBooleanField(DataForm dataForm, String name, String label, boolean value) {
    FormField field = new FormField(name);
    field.setRequired(true);
    field.setLabel(label);
    field.addValue(Boolean.valueOf(value).toString());
    field.setType(FormField.Type.bool);
    dataForm.addField(field);
}
Also used : FormField(org.jivesoftware.smackx.xdata.FormField)

Example 45 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project xabber-android by redsolution.

the class Feature method addSecurityField.

public static void addSecurityField(DataForm dataForm, SecurityValue[] options, SecurityValue value) {
    FormField field = new FormField(SECURITY_FIELD);
    field.setRequired(false);
    field.setLabel("Minimum security level");
    field.setType(FormField.Type.list_single);
    if (options != null)
        for (SecurityValue loggingValue : options) field.addOption(loggingValue.createOption());
    field.addValue(value.name());
    dataForm.addField(field);
}
Also used : FormField(org.jivesoftware.smackx.xdata.FormField)

Aggregations

FormField (org.jivesoftware.smackx.xdata.FormField)45 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)17 Test (org.junit.Test)10 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)6 ArrayList (java.util.ArrayList)4 TreeSet (java.util.TreeSet)3 Element (org.jivesoftware.smack.packet.Element)3 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)3 Form (org.jivesoftware.smackx.xdata.Form)3 RangeValidateElement (org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.RangeValidateElement)3 XmlPullParser (org.xmlpull.v1.XmlPullParser)3 LinkedList (java.util.LinkedList)2 IQ (org.jivesoftware.smack.packet.IQ)2 RemoteCommand (org.jivesoftware.smackx.commands.RemoteCommand)2 StreamInitiation (org.jivesoftware.smackx.si.packet.StreamInitiation)2 ValidateElement (org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Method (java.lang.reflect.Method)1 MessageDigest (java.security.MessageDigest)1 HashMap (java.util.HashMap)1