blob: cefcde365c3bd9f7b9132115303abc4c5019676e (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package eu.siacs.conversations.xmpp.jingle.stanzas;
import java.util.ArrayList;
import java.util.List;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.jingle.JingleFile;
public class Content extends Element {
private Content(String name) {
super(name);
}
public Content() {
super("content");
}
public void offerFile(JingleFile actualFile, String hash) {
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.getSize());
file.addChild("name").setContent(actualFile.getName());
}
public void setCandidates(String transportId, 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.setAttribute("sid", transportId);
transport.clearChildren();
for(Element canditate : canditates) {
transport.addChild(canditate);
}
}
public List<Element> getCanditates() {
Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
if (transport==null) {
return new ArrayList<Element>();
} else {
return transport.getChildren();
}
}
public String getUsedCandidate() {
Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
if (transport==null) {
return null;
}
Element usedCandidate = transport.findChild("candidate-used");
if (usedCandidate==null) {
return null;
} else {
return usedCandidate.getAttribute("cid");
}
}
}
|