Search in sources :

Example 1 with Version

use of org.jivesoftware.smackx.httpfileupload.UploadService.Version in project Smack by igniterealtime.

the class HttpFileUploadManager method uploadServiceFrom.

private static UploadService uploadServiceFrom(DiscoverInfo discoverInfo) {
    assert (containsHttpFileUploadNamespace(discoverInfo));
    UploadService.Version version;
    if (discoverInfo.containsFeature(NAMESPACE)) {
        version = Version.v0_3;
    } else if (discoverInfo.containsFeature(NAMESPACE_0_2)) {
        version = Version.v0_2;
    } else {
        throw new AssertionError();
    }
    DomainBareJid address = discoverInfo.getFrom().asDomainBareJid();
    DataForm dataForm = DataForm.from(discoverInfo);
    if (dataForm == null) {
        return new UploadService(address, version);
    }
    FormField field = dataForm.getField("max-file-size");
    if (field == null) {
        return new UploadService(address, version);
    }
    List<String> values = field.getValues();
    if (values.isEmpty()) {
        return new UploadService(address, version);
    }
    Long maxFileSize = Long.valueOf(values.get(0));
    return new UploadService(address, version, maxFileSize);
}
Also used : Version(org.jivesoftware.smackx.httpfileupload.UploadService.Version) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) DomainBareJid(org.jxmpp.jid.DomainBareJid) FormField(org.jivesoftware.smackx.xdata.FormField)

Aggregations

Version (org.jivesoftware.smackx.httpfileupload.UploadService.Version)1 FormField (org.jivesoftware.smackx.xdata.FormField)1 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)1 DomainBareJid (org.jxmpp.jid.DomainBareJid)1