Search in sources :

Example 1 with RefMedia

use of com.xabber.android.data.extension.references.RefMedia 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

Attachment (com.xabber.android.data.database.messagerealm.Attachment)1 RefMedia (com.xabber.android.data.extension.references.RefMedia)1 RealmList (io.realm.RealmList)1 FormField (org.jivesoftware.smackx.xdata.FormField)1 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)1