diff options
Diffstat (limited to 'src/eu/siacs/conversations/xmpp')
4 files changed, 12 insertions, 31 deletions
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index b2829c6e..72018394 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -18,7 +18,6 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map.Entry; @@ -793,20 +792,10 @@ public class XmppConnection implements Runnable { this.sendPacket(packet, null); } - public void sendMessagePacket(MessagePacket packet, - OnMessagePacketReceived callback) { - this.sendPacket(packet, callback); - } - public void sendPresencePacket(PresencePacket packet) { this.sendPacket(packet, null); } - - public void sendPresencePacket(PresencePacket packet, - OnPresencePacketReceived callback) { - this.sendPacket(packet, callback); - } - + private synchronized void sendPacket(final AbstractStanza packet, PacketReceived callback) { // TODO dont increment stanza count if packet = request packet or ack; @@ -926,14 +915,10 @@ public class XmppConnection implements Runnable { public List<String> findDiscoItemsByFeature(String feature) { List<String> items = new ArrayList<String>(); - Iterator<Entry<String, List<String>>> it = this.disco.entrySet() - .iterator(); - while (it.hasNext()) { - Entry<String, List<String>> pairs = it.next(); - if (pairs.getValue().contains(feature)) { - items.add(pairs.getKey()); + for (Entry<String, List<String>> cursor : disco.entrySet()) { + if (cursor.getValue().contains(feature)) { + items.add(cursor.getKey()); } - it.remove(); } return items; } diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index 1f287194..f1a0373c 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -83,7 +83,7 @@ public class JingleConnection { sendSuccess(); if (acceptedAutomatically) { message.markUnread(); - JingleConnection.this.mXmppConnectionService.updateUi(message.getConversation(), true); + JingleConnection.this.mXmppConnectionService.notifyUi(message.getConversation(), true); } BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; @@ -277,7 +277,7 @@ public class JingleConnection { } else { message.markUnread(); Log.d("xmppService","not auto accepting new file offer with size: "+size+" allowed size:"+this.mJingleConnectionManager.getAutoAcceptFileSize()); - this.mXmppConnectionService.updateUi(conversation, true); + this.mXmppConnectionService.notifyUi(conversation, true); } this.file = this.mXmppConnectionService.getFileBackend().getJingleFile(message,false); if (message.getEncryption() == Message.ENCRYPTION_OTR) { @@ -507,10 +507,8 @@ public class JingleConnection { private JingleSocks5Transport chooseConnection() { JingleSocks5Transport connection = null; - Iterator<Entry<String, JingleSocks5Transport>> it = this.connections.entrySet().iterator(); - while (it.hasNext()) { - Entry<String, JingleSocks5Transport> pairs = it.next(); - JingleSocks5Transport currentConnection = pairs.getValue(); + for (Entry<String, JingleSocks5Transport> cursor : connections.entrySet()) { + JingleSocks5Transport currentConnection = cursor.getValue(); //Log.d("xmppService","comparing candidate: "+currentConnection.getCandidate().toString()); if (currentConnection.isEstablished()&&(currentConnection.getCandidate().isUsedByCounterpart()||(!currentConnection.getCandidate().isOurs()))) { //Log.d("xmppService","is usable"); @@ -533,7 +531,6 @@ public class JingleConnection { } } } - it.remove(); } return connection; } diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index d4af624a..f01d7fa9 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -2,12 +2,11 @@ package eu.siacs.conversations.xmpp.jingle; import java.math.BigInteger; import java.security.SecureRandom; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; - +import java.util.concurrent.CopyOnWriteArrayList; +import android.annotation.SuppressLint; import android.util.Log; - import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.services.XmppConnectionService; @@ -20,10 +19,11 @@ public class JingleConnectionManager { private XmppConnectionService xmppConnectionService; - private List<JingleConnection> connections = new ArrayList<JingleConnection>(); + private List<JingleConnection> connections = new CopyOnWriteArrayList<JingleConnection>(); private HashMap<String, JingleCandidate> primaryCandidates = new HashMap<String, JingleCandidate>(); + @SuppressLint("TrulyRandom") private SecureRandom random = new SecureRandom(); public JingleConnectionManager(XmppConnectionService service) { diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java b/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java index f9de6a6a..d2c84325 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java @@ -5,7 +5,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; -import java.net.SocketTimeoutException; import java.net.UnknownHostException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; |