aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
blob: 941e6559e77963b9b7732a778456c8f955466f20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package eu.siacs.conversations.xmpp.jingle.stanzas;

import java.io.File;
import java.util.List;

import eu.siacs.conversations.xml.Element;

public class Content extends Element {
	private Content(String name) {
		super(name);
	}
	
	public Content() {
		super("content");
	}

	public void offerFile(File actualFile) {
		Element description = this.addChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
		Element offer = description.addChild("offer");
		Element file = offer.addChild("file");
		file.addChild("size").setContent(""+actualFile.length());
		file.addChild("name").setContent(actualFile.getName());
	}

	public void setCanditates(List<Element> canditates) {
		Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
		if (transport==null) {
			transport = this.addChild("transport", "urn:xmpp:jingle:transports:s5b:1");
		}
		transport.clearChildren();
		for(Element canditate : canditates) {
			transport.addChild(canditate);
		}
	}
}