use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class MamManager method addWithJid.
private static void addWithJid(Jid withJid, DataForm dataForm) {
if (withJid == null) {
return;
}
FormField formField = new FormField("with");
formField.addValue(withJid.toString());
dataForm.addField(formField);
}
use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class MamManager method addEnd.
private static void addEnd(Date end, DataForm dataForm) {
if (end == null) {
return;
}
FormField formField = new FormField("end");
formField.addValue(XmppDateTime.formatXEP0082Date(end));
dataForm.addField(formField);
}
use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class EntityCapsManagerTest method createMalformedDiscoverInfo.
private static DiscoverInfo createMalformedDiscoverInfo() throws XmppStringprepException {
DiscoverInfo di = new DiscoverInfo();
di.setFrom(JidCreate.from("benvolio@capulet.lit/230193"));
di.setStanzaId("disco1");
di.setTo(JidCreate.from(")juliet@capulet.lit/chamber"));
di.setType(IQ.Type.result);
Collection<DiscoverInfo.Identity> identities = new LinkedList<DiscoverInfo.Identity>();
DiscoverInfo.Identity i = new DiscoverInfo.Identity("client", "pc", "Psi 0.11", "en");
identities.add(i);
i = new DiscoverInfo.Identity("client", "pc", "Ψ 0.11", "el");
identities.add(i);
di.addIdentities(identities);
// Failure 1: Duplicate identities
i = new DiscoverInfo.Identity("client", "pc", "Ψ 0.11", "el");
identities.add(i);
di.addIdentities(identities);
di.addFeature("http://jabber.org/protocol/disco#items");
di.addFeature(EntityCapsManager.NAMESPACE);
di.addFeature("http://jabber.org/protocol/muc");
di.addFeature("http://jabber.org/protocol/disco#info");
// Failure 2: Duplicate features
di.addFeature("http://jabber.org/protocol/disco#info");
DataForm df = new DataForm(DataForm.Type.result);
FormField ff = new FormField("os");
ff.addValue("Mac");
df.addField(ff);
ff = new FormField("FORM_TYPE");
ff.setType(FormField.Type.hidden);
ff.addValue("urn:xmpp:dataforms:softwareinfo");
df.addField(ff);
ff = new FormField("ip_version");
ff.addValue("ipv4");
ff.addValue("ipv6");
df.addField(ff);
ff = new FormField("os_version");
ff.addValue("10.5.1");
df.addField(ff);
ff = new FormField("software");
ff.addValue("Psi");
df.addField(ff);
ff = new FormField("software_version");
ff.addValue("0.11");
df.addField(ff);
di.addExtension(df);
// Failure 3: Another service discovery information form with the same
// FORM_TYPE
df = new DataForm(DataForm.Type.result);
ff = new FormField("FORM_TYPE");
ff.setType(FormField.Type.hidden);
ff.addValue("urn:xmpp:dataforms:softwareinfo");
df.addField(ff);
ff = new FormField("software");
ff.addValue("smack");
df.addField(ff);
di.addExtension(df);
return di;
}
use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.
the class EntityCapsManagerTest method createComplexSamplePacket.
private static DiscoverInfo createComplexSamplePacket() throws XmppStringprepException {
DiscoverInfo di = new DiscoverInfo();
di.setFrom(JidCreate.from("benvolio@capulet.lit/230193"));
di.setStanzaId("disco1");
di.setTo(JidCreate.from("juliet@capulet.lit/chamber"));
di.setType(IQ.Type.result);
Collection<DiscoverInfo.Identity> identities = new LinkedList<DiscoverInfo.Identity>();
DiscoverInfo.Identity i = new DiscoverInfo.Identity("client", "pc", "Psi 0.11", "en");
identities.add(i);
i = new DiscoverInfo.Identity("client", "pc", "Ψ 0.11", "el");
identities.add(i);
di.addIdentities(identities);
di.addFeature("http://jabber.org/protocol/disco#items");
di.addFeature(EntityCapsManager.NAMESPACE);
di.addFeature("http://jabber.org/protocol/muc");
di.addFeature("http://jabber.org/protocol/disco#info");
DataForm df = new DataForm(DataForm.Type.result);
FormField ff = new FormField("os");
ff.addValue("Mac");
df.addField(ff);
ff = new FormField("FORM_TYPE");
ff.setType(FormField.Type.hidden);
ff.addValue("urn:xmpp:dataforms:softwareinfo");
df.addField(ff);
ff = new FormField("ip_version");
ff.addValue("ipv4");
ff.addValue("ipv6");
df.addField(ff);
ff = new FormField("os_version");
ff.addValue("10.5.1");
df.addField(ff);
ff = new FormField("software");
ff.addValue("Psi");
df.addField(ff);
ff = new FormField("software_version");
ff.addValue("0.11");
df.addField(ff);
di.addExtension(df);
return di;
}
use of org.jivesoftware.smackx.xdata.FormField in project xabber-android by redsolution.
the class Feature method getDisclosureOptions.
public Collection<DisclosureValue> getDisclosureOptions() {
FormField field = getField(DISCLOSURE_FIELD);
if (field == null) {
return null;
}
Collection<DisclosureValue> collection = new ArrayList<>();
List<FormField.Option> options = field.getOptions();
for (FormField.Option option : options) {
collection.add(DisclosureValue.fromString(option.getValue()));
}
return collection;
}
Aggregations