summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-06-17 07:33:03 (GMT)
committerTarun Gupta <tarun1995gupta@gmail.com>2015-06-18 20:18:56 (GMT)
commitf9c7be7adde21ab29b5e268a726506bb06510ead (patch)
treeb1e2f276c7015eb74e955b856bdf944c8f4f4041 /src/com/isode/stroke/elements/JingleS5BTransportPayload.java
parent4addb6419080db814094ab501d69111adffeb5be (diff)
downloadstroke-f9c7be7adde21ab29b5e268a726506bb06510ead.zip
stroke-f9c7be7adde21ab29b5e268a726506bb06510ead.tar.bz2
Adds Jingle Elements.
Adds: JinglePayload, its Parser and Serializer and JingleReasonParser. JingleContentPayload Element, its Parser and Serializer. JingleDesciption Element. JingleFileTransferDescription Element, its Parser and Serializer. JingleFileTransferFileInfo Element, its Parser and Serializer. JingleFileTransferHash Element, its Parser and Serializer. JingleIBBTransportPayload Element, its Parser and Serializer. JingleS5BTransportPayload Element, its Parser and Serializer. JingleTransportPayload Element and HashElement. Updates HostAddress access specifier for getInetAddress(). License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Tests added for: JingleParser JingleContentPayload Parser and Serializer. JingleFileTransferHash Parser and Serializer. JingleFileTranferFileInfo Parser and Serializer. JingleFileTransferDescription Parser and Serializer. JingleIBBTransportPayload Parser and Serializer. JingleS5BTransportPayload Parser and Serializer. All tests passes. Change-Id: Ife1b7fef00efc57d8d0d4290f3280327439abbb6
Diffstat (limited to 'src/com/isode/stroke/elements/JingleS5BTransportPayload.java')
-rw-r--r--src/com/isode/stroke/elements/JingleS5BTransportPayload.java172
1 files changed, 172 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/JingleS5BTransportPayload.java b/src/com/isode/stroke/elements/JingleS5BTransportPayload.java
new file mode 100644
index 0000000..e9ee67f
--- /dev/null
+++ b/src/com/isode/stroke/elements/JingleS5BTransportPayload.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2011-2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.elements.JingleTransportPayload;
+import com.isode.stroke.elements.Bytestreams;
+import com.isode.stroke.network.HostAddressPort;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.base.NotNull;
+import java.util.Vector;
+
+public class JingleS5BTransportPayload extends JingleTransportPayload {
+
+ public enum Mode {
+ TCPMode, // default case
+ UDPMode
+ };
+
+ public static class Candidate {
+
+ public enum Type {
+ DirectType, // default case
+ AssistedType,
+ TunnelType,
+ ProxyType
+ };
+
+ public String cid = "";
+ public JID jid = new JID();
+ public HostAddressPort hostPort;
+ public int priority;
+ public Type type;
+
+ public Candidate() {
+ this.priority = 0;
+ this.type = Type.DirectType;
+ }
+ }
+
+ public class CompareCandidate {
+ public boolean compareTo(JingleS5BTransportPayload.Candidate c1, JingleS5BTransportPayload.Candidate c2) {
+ return (c1.priority < c2.priority);
+ }
+ }
+
+ private Mode mode;
+ private Vector<Candidate> candidates = new Vector<Candidate>();
+
+ private String candidateUsedCID = "";
+ private String activatedCID = "";
+ private String dstAddr = "";
+ private boolean candidateError;
+ private boolean proxyError;
+
+ public JingleS5BTransportPayload() {
+ this.mode = Mode.TCPMode;
+ this.candidateError = false;
+ this.proxyError = false;
+ }
+
+ /**
+ * @return mode, Not Null.
+ */
+ public Mode getMode() {
+ return mode;
+ }
+
+ /**
+ * @param mode, Not Null.
+ */
+ public void setMode(Mode mode) {
+ NotNull.exceptIfNull(mode, "mode");
+ this.mode = mode;
+ }
+
+ /**
+ * @return candidates, Not Null.
+ */
+ public Vector<Candidate> getCandidates() {
+ return candidates;
+ }
+
+ /**
+ * @param candidate, NotNull.
+ */
+ public void addCandidate(Candidate candidate) {
+ NotNull.exceptIfNull(candidate, "candidate");
+ candidates.add(candidate);
+ }
+
+ /**
+ * @param cid, NotNull.
+ */
+ public void setCandidateUsed(String cid) {
+ NotNull.exceptIfNull(cid, "cid");
+ candidateUsedCID = cid;
+ }
+
+ /**
+ * @return candidateUsedCID, Not Null.
+ */
+ public String getCandidateUsed() {
+ return candidateUsedCID;
+ }
+
+ /**
+ * @param cid, NotNull.
+ */
+ public void setActivated(String cid) {
+ NotNull.exceptIfNull(cid, "cid");
+ activatedCID = cid;
+ }
+
+ /**
+ * @return activatedCID, Not Null.
+ */
+ public String getActivated() {
+ return activatedCID;
+ }
+
+ /**
+ * @param addr, NotNull.
+ */
+ public void setDstAddr(String addr) {
+ NotNull.exceptIfNull(addr, "addr");
+ dstAddr = addr;
+ }
+
+ /**
+ * @return dstAddr, Not Null.
+ */
+ public String getDstAddr() {
+ return dstAddr;
+ }
+
+ /**
+ * @param candidateError.
+ */
+ public void setCandidateError(boolean hasError) {
+ candidateError = hasError;
+ }
+
+ /**
+ * @return candidateError.
+ */
+ public boolean hasCandidateError() {
+ return candidateError;
+ }
+
+ /**
+ * @param proxyError.
+ */
+ public void setProxyError(boolean hasError) {
+ proxyError = hasError;
+ }
+
+ /**
+ * @return proxyError.
+ */
+ public boolean hasProxyError() {
+ return proxyError;
+ }
+} \ No newline at end of file