Search in sources :

Example 16 with FormField

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);
}
Also used : FormField(org.jivesoftware.smackx.xdata.FormField)

Example 17 with 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);
}
Also used : FormField(org.jivesoftware.smackx.xdata.FormField)

Example 18 with 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;
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) FormField(org.jivesoftware.smackx.xdata.FormField) LinkedList(java.util.LinkedList)

Example 19 with FormField

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;
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) FormField(org.jivesoftware.smackx.xdata.FormField) LinkedList(java.util.LinkedList)

Example 20 with FormField

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;
}
Also used : ArrayList(java.util.ArrayList) 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