mirror of
https://codeberg.org/monocles/monocles_chat.git
synced 2025-01-29 00:14:12 +01:00
Helper to get thumbnails from SIMS element (Cheogram)
This commit is contained in:
parent
7e5c3c902f
commit
1bd22920c6
1 changed files with 20 additions and 0 deletions
|
@ -1402,6 +1402,26 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
|||
return sims;
|
||||
}
|
||||
|
||||
public List<Element> getThumbnails() {
|
||||
List<Element> thumbs = new ArrayList<>();
|
||||
if (sims == null) return thumbs;
|
||||
|
||||
Element mediaSharing = sims.findChild("media-sharing", "urn:xmpp:sims:1");
|
||||
if (mediaSharing == null) return thumbs;
|
||||
Element file = mediaSharing.findChild("file", "urn:xmpp:jingle:apps:file-transfer:5");
|
||||
if (file == null) file = mediaSharing.findChild("file", "urn:xmpp:jingle:apps:file-transfer:4");
|
||||
if (file == null) file = mediaSharing.findChild("file", "urn:xmpp:jingle:apps:file-transfer:3");
|
||||
if (file == null) return thumbs;
|
||||
|
||||
for (Element child : file.getChildren()) {
|
||||
if (child.getName().equals("thumbnail") && child.getNamespace().equals("urn:xmpp:thumbs:1")) {
|
||||
thumbs.add(child);
|
||||
}
|
||||
}
|
||||
|
||||
return thumbs;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
if (url != null) builder.append(url);
|
||||
|
|
Loading…
Add table
Reference in a new issue