mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-24 19:47:58 +01:00
Add cleanup for transports, improve content states
This commit is contained in:
parent
cc4de48966
commit
cdcf0d590a
5 changed files with 46 additions and 9 deletions
|
@ -361,7 +361,7 @@ public final class Socks5Proxy {
|
|||
*
|
||||
* @param digest to be removed from the list of allowed transfers
|
||||
*/
|
||||
protected void removeTransfer(String digest) {
|
||||
public void removeTransfer(String digest) {
|
||||
this.allowedConnections.remove(digest);
|
||||
this.connectionMap.remove(digest);
|
||||
}
|
||||
|
|
|
@ -67,14 +67,39 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
private final List<Callback> callbacks = Collections.synchronizedList(new ArrayList<Callback>());
|
||||
private final Set<String> transportBlacklist = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
private short state;
|
||||
|
||||
public enum STATE {
|
||||
pending_accept,
|
||||
pending_transmission_start,
|
||||
pending_transport_replace,
|
||||
transmission_in_progress,
|
||||
transmission_successful,
|
||||
transmission_failed,
|
||||
transmission_cancelled
|
||||
pending_accept((short) 1),
|
||||
pending_transmission_start((short) 2),
|
||||
pending_transport_replace((short) 4),
|
||||
transmission_in_progress((short) 8),
|
||||
transmission_successful((short) 16),
|
||||
transmission_failed((short) 32),
|
||||
transmission_cancelled((short) 64),
|
||||
;
|
||||
|
||||
final short value;
|
||||
|
||||
STATE(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
short getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public void addState(STATE state) {
|
||||
this.state |= state.getValue();
|
||||
}
|
||||
|
||||
public void removeState(STATE state) {
|
||||
this.state ^= state.getValue();
|
||||
}
|
||||
|
||||
public boolean hasState(STATE state) {
|
||||
return (this.state & state.getValue()) == state.getValue();
|
||||
}
|
||||
|
||||
public JingleContent(JingleContentElement.Creator creator, JingleContentElement.Senders senders) {
|
||||
|
|
|
@ -135,4 +135,6 @@ public abstract class JingleTransport<D extends JingleContentTransportElement> e
|
|||
}
|
||||
|
||||
public abstract void handleSessionAccept(JingleContentTransportElement transportElement, XMPPConnection connection);
|
||||
|
||||
public abstract void cleanup();
|
||||
}
|
||||
|
|
|
@ -126,6 +126,11 @@ public class JingleIBBTransport extends JingleTransport<JingleIBBTransportElemen
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOurCandidate(JingleTransportCandidate<?> candidate) {
|
||||
// Sorry, we don't want any candidates.
|
||||
|
@ -133,7 +138,7 @@ public class JingleIBBTransport extends JingleTransport<JingleIBBTransportElemen
|
|||
|
||||
@Override
|
||||
public void prepare(XMPPConnection connection) {
|
||||
// Nuffin taddooh.
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -276,6 +276,11 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
|||
return CANDIDATE_FAILURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
Socks5Proxy.getSocks5Proxy().removeTransfer(ourDstAddr);
|
||||
}
|
||||
|
||||
void connectIfReady() {
|
||||
final JingleS5BTransportManager jingleS5BTransportManager = JingleS5BTransportManager.getInstanceFor(getParent().getParent().getJingleManager().getConnection());
|
||||
final JingleSession session = getParent().getParent();
|
||||
|
|
Loading…
Reference in a new issue