Browse Source

Merge branch '4.4'

master
Florian Schmaus 6 months ago
parent
commit
5f75d141ff
  1. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/formtypes/FormFieldRegistry.java
  2. 9
      smack-extensions/src/main/java/org/jivesoftware/smackx/softwareinfo/form/SoftwareInfoForm.java
  3. 26
      smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java
  4. 1
      smack-extensions/src/main/resources/org.jivesoftware.smack.extensions/extensions.xml
  5. 4
      smack-sasl-javax/src/main/java/org/jivesoftware/smack/sasl/javax/SASLGSSAPIMechanism.java

6
smack-extensions/src/main/java/org/jivesoftware/smackx/formtypes/FormFieldRegistry.java

@ -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);

9
smack-extensions/src/main/java/org/jivesoftware/smackx/softwareinfo/form/SoftwareInfoForm.java

@ -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);
}

26
smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java

@ -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;
}

1
smack-extensions/src/main/resources/org.jivesoftware.smack.extensions/extensions.xml

@ -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>

4
smack-sasl-javax/src/main/java/org/jivesoftware/smack/sasl/javax/SASLGSSAPIMechanism.java

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

Loading…
Cancel
Save