1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-21 10:07:58 +01:00

Merge branch '4.4'

This commit is contained in:
Florian Schmaus 2021-12-27 21:25:24 +01:00
commit 5f75d141ff
5 changed files with 43 additions and 3 deletions

View file

@ -68,6 +68,12 @@ public class FormFieldRegistry {
}
}
public static void register(String formType, FormField.Type fieldType, String... fieldNames) {
for (String fieldName : fieldNames) {
register(formType, fieldName, fieldType);
}
}
public static void register(String formType, String fieldName, FormField.Type fieldType) {
StringUtils.requireNotNullNorEmpty(fieldName, "fieldName must be provided");
Objects.requireNonNull(fieldType);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2020 Aditya Borikar
* Copyright 2020 Aditya Borikar, 2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import java.util.List;
import org.jivesoftware.smack.util.EqualsUtil;
import org.jivesoftware.smack.util.HashCode;
import org.jivesoftware.smackx.formtypes.FormFieldRegistry;
import org.jivesoftware.smackx.mediaelement.element.MediaElement;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormFieldChildElement;
@ -47,6 +47,11 @@ public final class SoftwareInfoForm extends FilledForm {
public static final String SOFTWARE_VERSION = "software_version";
public static final String ICON = "icon";
static {
FormFieldRegistry.register(FORM_TYPE, FormField.Type.text_single,
OS, OS_VERSION, SOFTWARE, SOFTWARE_VERSION);
}
private SoftwareInfoForm(DataForm dataForm) {
super(dataForm);
}

View file

@ -35,7 +35,31 @@ public class BooleanFormField extends SingleValueFormField {
return value.toString();
}
public Boolean getValueAsBoolean() {
/**
* Get the value of the booelan field. Note that, if no explicit boolean value is provided, in the form of "true",
* "false", "0", or "1", then the default value of a boolean field is <code>false</code>, according to
* XEP-0004 § 3.3.
*
* @return the boolean value of this form field.
*/
public boolean getValueAsBoolean() {
if (value == null) {
return false;
}
return value;
}
/**
* Get the value of the boolean field or maybe <code>null</code>. Note that you usually want to use
* {@link #getValueAsBoolean()} instead of this method, as {@link #getValueAsBoolean()} considers the default value
* of boolean fields. That is, boolean form fields have the value <code>false</code> if not explicitly set to
* something else.
*
* @return the boolean value of this form field or <code>null</code> if no value was explicitly provided.
* @see #getValueAsBoolean()
* @since 4.4.5
*/
public Boolean getValueAsBooleanOrNull() {
return value;
}

View file

@ -20,5 +20,6 @@
<className>org.jivesoftware.smackx.receipts.DeliveryReceiptManager</className>
<className>org.jivesoftware.smackx.iqversion.VersionManager</className>
<className>org.jivesoftware.smackx.caps.EntityCapsManager</className>
<className>org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm</className>
</startupClasses>
</smack>

View file

@ -66,4 +66,8 @@ public class SASLGSSAPIMechanism extends SASLJavaXMechanism {
return new SASLGSSAPIMechanism();
}
@Override
public boolean requiresPassword() {
return false;
}
}