Search in sources :

Example 11 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project xabber-android by redsolution.

the class SSNManager method onTerminateReceived.

private void onTerminateReceived(String account, String from, String session) {
    if (sessionStates.get(account, session) == null)
        return;
    sessionStates.remove(account, session);
    DataForm dataForm = Feature.createDataForm(DataFormType.result);
    Feature.addTerminateField(dataForm);
    sendFeature(account, from, session, new Feature(dataForm));
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) Feature(com.xabber.xmpp.ssn.Feature)

Example 12 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project xabber-android by redsolution.

the class SSNManager method onSubmitReceived.

private void onSubmitReceived(String account, String from, String bareAddress, String session, Feature feature) {
    if (feature.getTerminateValue() != null) {
        onTerminateReceived(account, from, session);
        return;
    }
    if (!isAccepted(account, from, bareAddress, session, feature))
        return;
    OtrMode otrMode = getOtrMode(account, bareAddress, session);
    LoggingValue loggingValue = feature.getLoggingValue();
    if (loggingValue == null || otrMode.acceptLoggingValue(loggingValue)) {
        DataForm dataForm = Feature.createDataForm(DataFormType.result);
        if (feature.getAcceptValue() != null)
            Feature.addAcceptField(dataForm, true);
        else
            Feature.addRenegotiateField(dataForm, true);
        sendFeature(account, from, session, new Feature(dataForm));
        sessionStates.put(account, session, SessionState.active);
    } else {
        DataForm dataForm = Feature.createDataForm(DataFormType.result);
        if (feature.getAcceptValue() != null) {
            Feature.addAcceptField(dataForm, false);
            sessionStates.remove(account, session);
        } else
            Feature.addRenegotiateField(dataForm, false);
        sendFeature(account, from, session, new Feature(dataForm));
    }
}
Also used : LoggingValue(com.xabber.xmpp.ssn.LoggingValue) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) OtrMode(com.xabber.xmpp.archive.OtrMode) Feature(com.xabber.xmpp.ssn.Feature)

Example 13 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project Spark by igniterealtime.

the class ConferenceUtils method getCreationDate.

/**
 * Retrieve the date (in yyyyMMdd) format of the time the room was created.
 *
 * @param roomJID the jid of the room.
 * @return the formatted date.
 * @throws Exception throws an exception if we are unable to retrieve the date.
 */
public static String getCreationDate(String roomJID) throws Exception {
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
    final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
    DiscoverInfo infoResult = discoManager.discoverInfo(roomJID);
    DataForm dataForm = infoResult.getExtension("x", "jabber:x:data");
    if (dataForm == null) {
        return "Not available";
    }
    String creationDate = "";
    for (final FormField field : dataForm.getFields()) {
        String label = field.getLabel();
        if (label != null && "Creation date".equalsIgnoreCase(label)) {
            for (String value : field.getValues()) {
                creationDate = value;
                Date date = dateFormatter.parse(creationDate);
                creationDate = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM).format(date);
            }
        }
    }
    return creationDate;
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) SimpleDateFormat(java.text.SimpleDateFormat) FormField(org.jivesoftware.smackx.xdata.FormField) ServiceDiscoveryManager(org.jivesoftware.smackx.disco.ServiceDiscoveryManager)

Example 14 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project xabber-android by redsolution.

the class NextMamManager method getNewMamForm.

/**
 * UTILS
 */
private static DataForm getNewMamForm() {
    FormField field = new FormField(FormField.FORM_TYPE);
    field.setType(FormField.Type.hidden);
    field.addValue(MamElements.NAMESPACE);
    DataForm form = new DataForm(DataForm.Type.submit);
    form.addField(field);
    return form;
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) FormField(org.jivesoftware.smackx.xdata.FormField)

Example 15 with DataForm

use of org.jivesoftware.smackx.xdata.packet.DataForm in project xabber-android by redsolution.

the class HttpFileUploadManager method parseFileMessage.

public static RealmList<Attachment> parseFileMessage(Stanza packet) {
    RealmList<Attachment> attachments = new RealmList<>();
    // parsing data references
    List<RefMedia> refMediaList = ReferencesManager.getMediaFromReferences(packet);
    if (!refMediaList.isEmpty()) {
        for (RefMedia media : refMediaList) {
            attachments.add(refMediaToAttachment(media));
        }
    }
    // parsing data forms
    DataForm dataForm = DataForm.from(packet);
    if (dataForm != null) {
        List<FormField> fields = dataForm.getFields();
        for (FormField field : fields) {
            if (field instanceof ExtendedFormField) {
                ExtendedFormField.Media media = ((ExtendedFormField) field).getMedia();
                attachments.add(mediaToAttachment(media, field.getLabel()));
            }
        }
    }
    return attachments;
}
Also used : RefMedia(com.xabber.android.data.extension.references.RefMedia) RealmList(io.realm.RealmList) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) Attachment(com.xabber.android.data.database.messagerealm.Attachment) FormField(org.jivesoftware.smackx.xdata.FormField)

Aggregations

DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)65 FormField (org.jivesoftware.smackx.xdata.FormField)23 Test (org.junit.jupiter.api.Test)13 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)12 Feature (com.xabber.xmpp.ssn.Feature)7 MamQueryIQ (org.jivesoftware.smackx.mam.element.MamQueryIQ)7 Date (java.util.Date)5 MamQueryArgs (org.jivesoftware.smackx.mam.MamManager.MamQueryArgs)5 OtrMode (com.xabber.xmpp.archive.OtrMode)4 LoggingValue (com.xabber.xmpp.ssn.LoggingValue)4 ArrayList (java.util.ArrayList)4 TreeSet (java.util.TreeSet)4 FillableForm (org.jivesoftware.smackx.xdata.form.FillableForm)4 LinkedList (java.util.LinkedList)3 IQ (org.jivesoftware.smack.packet.IQ)3 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)3 Identity (org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity)3 DiscoverInfoBuilder (org.jivesoftware.smackx.disco.packet.DiscoverInfoBuilder)3 Form (org.jivesoftware.smackx.xdata.form.Form)3 DisclosureValue (com.xabber.xmpp.ssn.DisclosureValue)2