diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java index 3ff1cebd5..4f8f65f54 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java @@ -406,6 +406,30 @@ public class ConfigureForm extends Form { setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify); } + /** + * Determines the type of notifications which are sent. + * + * @return NotificationType for the node configuration + * @since 4.3 + */ + public NotificationType getNotificationType() { + String value = getFieldValue(ConfigureNodeFields.notification_type); + if (value == null) + return null; + return NotificationType.valueOf(value); + } + + /** + * Sets the NotificationType for the node. + * + * @param notificationType The enum representing the possible options + * @since 4.3 + */ + public void setNotificationType(NotificationType notificationType) { + addField(ConfigureNodeFields.notification_type, FormField.Type.list_single); + setAnswer(ConfigureNodeFields.notification_type.getFieldName(), getListSingle(notificationType.toString())); + } + /** * Determines whether items should be persisted in the node. * diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java index 6a3ce0be9..8e0573fc1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java @@ -147,6 +147,13 @@ public enum ConfigureNodeFields { */ notify_retract, + /** + * The type of notification that the nodes sends. + * + *
Value: {@link NotificationType}
+ */ + notification_type, + /** * Whether to persist items to storage. This is required to have. multiple * items in the node. @@ -205,7 +212,7 @@ public enum ConfigureNodeFields { title, /** - * The type of node data, ussually specified by the namespace + * The type of node data, usually specified by the namespace * of the payload(if any);MAY be a list-single rather than a * text single. * diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NotificationType.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NotificationType.java new file mode 100644 index 000000000..ab311dd2b --- /dev/null +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NotificationType.java @@ -0,0 +1,28 @@ +/** + * + * Copyright the original author or authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smackx.pubsub; + +/** + * Specify the delivery style for event notifications. Denotes possible values + * for {@link ConfigureForm#setNotificationType(NotificationType)}. + * + * @author Timothy Pitt + */ +public enum NotificationType { + normal, + headline +} diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java index 852d164f5..a5875c9d8 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java @@ -97,4 +97,14 @@ public class ConfigureFormTest extends InitExtensions { node.getNodeConfiguration(); } + + @Test + public void checkNotificationType() { + ConfigureForm form = new ConfigureForm(DataForm.Type.submit); + form.setNotificationType(NotificationType.normal); + assertEquals(NotificationType.normal, form.getNotificationType()); + form.setNotificationType(NotificationType.headline); + assertEquals(NotificationType.headline, form.getNotificationType()); + } + }