mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
code clean up
This commit is contained in:
parent
b519411d34
commit
933538a39d
@ -409,19 +409,9 @@ public class AxolotlService {
|
|||||||
publishDeviceBundle(signedPreKeyRecord, preKeyRecords, announceAfter, wipe);
|
publishDeviceBundle(signedPreKeyRecord, preKeyRecords, announceAfter, wipe);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (KeyChainException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
Log.d(Config.LOGTAG,"no such algo "+e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (java.security.InvalidKeyException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SignatureException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void publishBundlesIfNeeded(final boolean announce, final boolean wipe) {
|
public void publishBundlesIfNeeded(final boolean announce, final boolean wipe) {
|
||||||
@ -530,7 +520,6 @@ public class AxolotlService {
|
|||||||
}
|
}
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Failed to publish bundle " + getOwnDeviceId() + ", reason: " + e.getMessage());
|
Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Failed to publish bundle " + getOwnDeviceId() + ", reason: " + e.getMessage());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -639,7 +628,6 @@ public class AxolotlService {
|
|||||||
fetchStatusMap.put(address, FetchStatus.ERROR);
|
fetchStatusMap.put(address, FetchStatus.ERROR);
|
||||||
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while building session:" + packet.findChild("error"));
|
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while building session:" + packet.findChild("error"));
|
||||||
finish();
|
finish();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@ public abstract class SaslMechanism {
|
|||||||
final protected Account account;
|
final protected Account account;
|
||||||
final protected SecureRandom rng;
|
final protected SecureRandom rng;
|
||||||
|
|
||||||
protected static enum State {
|
protected enum State {
|
||||||
INITIAL,
|
INITIAL,
|
||||||
AUTH_TEXT_SENT,
|
AUTH_TEXT_SENT,
|
||||||
RESPONSE_SENT,
|
RESPONSE_SENT,
|
||||||
|
@ -21,7 +21,6 @@ public class ScramSha1 extends SaslMechanism {
|
|||||||
// TODO: When channel binding (SCRAM-SHA1-PLUS) is supported in future, generalize this to indicate support and/or usage.
|
// TODO: When channel binding (SCRAM-SHA1-PLUS) is supported in future, generalize this to indicate support and/or usage.
|
||||||
final private static String GS2_HEADER = "n,,";
|
final private static String GS2_HEADER = "n,,";
|
||||||
private String clientFirstMessageBare;
|
private String clientFirstMessageBare;
|
||||||
private byte[] serverFirstMessage;
|
|
||||||
final private String clientNonce;
|
final private String clientNonce;
|
||||||
private byte[] serverSignature = null;
|
private byte[] serverSignature = null;
|
||||||
private static HMac HMAC;
|
private static HMac HMAC;
|
||||||
@ -104,7 +103,7 @@ public class ScramSha1 extends SaslMechanism {
|
|||||||
if (challenge == null) {
|
if (challenge == null) {
|
||||||
throw new AuthenticationException("challenge can not be null");
|
throw new AuthenticationException("challenge can not be null");
|
||||||
}
|
}
|
||||||
serverFirstMessage = Base64.decode(challenge, Base64.DEFAULT);
|
byte[] serverFirstMessage = Base64.decode(challenge, Base64.DEFAULT);
|
||||||
final Tokenizer tokenizer = new Tokenizer(serverFirstMessage);
|
final Tokenizer tokenizer = new Tokenizer(serverFirstMessage);
|
||||||
String nonce = "";
|
String nonce = "";
|
||||||
int iterationCount = -1;
|
int iterationCount = -1;
|
||||||
|
@ -3,9 +3,9 @@ package eu.siacs.conversations.ui;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
|
||||||
public interface UiCallback<T> {
|
public interface UiCallback<T> {
|
||||||
public void success(T object);
|
void success(T object);
|
||||||
|
|
||||||
public void error(int errorCode, T object);
|
void error(int errorCode, T object);
|
||||||
|
|
||||||
public void userInputRequried(PendingIntent pi, T object);
|
void userInputRequried(PendingIntent pi, T object);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
|
|||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
if (constraint != null) {
|
if (constraint != null) {
|
||||||
ArrayList<String> suggestions = new ArrayList<String>();
|
ArrayList<String> suggestions = new ArrayList<>();
|
||||||
final String[] split = constraint.toString().split("@");
|
final String[] split = constraint.toString().split("@");
|
||||||
if (split.length == 1) {
|
if (split.length == 1) {
|
||||||
for (String domain : domains) {
|
for (String domain : domains) {
|
||||||
@ -58,10 +58,9 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public KnownHostsAdapter(Context context, int viewResourceId,
|
public KnownHostsAdapter(Context context, int viewResourceId, List<String> mKnownHosts) {
|
||||||
List<String> mKnownHosts) {
|
|
||||||
super(context, viewResourceId, new ArrayList<String>());
|
super(context, viewResourceId, new ArrayList<String>());
|
||||||
domains = new ArrayList<String>(mKnownHosts);
|
domains = new ArrayList<>(mKnownHosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,7 +92,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface OnTagClickedListener {
|
public interface OnTagClickedListener {
|
||||||
public void onTagClicked(String tag);
|
void onTagClicked(String tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
class BitmapWorkerTask extends AsyncTask<ListItem, Void, Bitmap> {
|
class BitmapWorkerTask extends AsyncTask<ListItem, Void, Bitmap> {
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package eu.siacs.conversations.xmpp;
|
package eu.siacs.conversations.xmpp;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.wifi.WifiConfiguration;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.security.KeyChain;
|
import android.security.KeyChain;
|
||||||
import android.security.KeyChainException;
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
@ -35,8 +32,6 @@ import java.net.UnknownHostException;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStore;
|
|
||||||
import java.security.KeyStoreException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
@ -177,7 +172,7 @@ public class XmppConnection implements Runnable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private OnIqPacketReceived createPacketReceiveHandler() {
|
private OnIqPacketReceived createPacketReceiveHandler() {
|
||||||
OnIqPacketReceived receiver = new OnIqPacketReceived() {
|
return new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
@ -195,8 +190,6 @@ public class XmppConnection implements Runnable {
|
|||||||
disconnect(true);
|
disconnect(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return receiver;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmppConnection(final Account account, final XmppConnectionService service) {
|
public XmppConnection(final Account account, final XmppConnectionService service) {
|
||||||
@ -775,17 +768,14 @@ public class XmppConnection implements Runnable {
|
|||||||
InputStream stream = new ByteArrayInputStream(strBlob);
|
InputStream stream = new ByteArrayInputStream(strBlob);
|
||||||
captcha = BitmapFactory.decodeStream(stream);
|
captcha = BitmapFactory.decodeStream(stream);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
//ignored
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Field url = data.getFieldByName("url");
|
Field url = data.getFieldByName("url");
|
||||||
String urlString = url.findChildContent("value");
|
String urlString = url.findChildContent("value");
|
||||||
|
|
||||||
URL uri = new URL(urlString);
|
URL uri = new URL(urlString);
|
||||||
captcha = BitmapFactory.decodeStream(uri.openConnection().getInputStream());
|
captcha = BitmapFactory.decodeStream(uri.openConnection().getInputStream());
|
||||||
} catch(MalformedURLException e) {
|
|
||||||
Log.e(Config.LOGTAG, e.toString());
|
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
Log.e(Config.LOGTAG, e.toString());
|
Log.e(Config.LOGTAG, e.toString());
|
||||||
}
|
}
|
||||||
@ -885,11 +875,9 @@ public class XmppConnection implements Runnable {
|
|||||||
this.sendUnmodifiedIqPacket(startSession, new OnIqPacketReceived() {
|
this.sendUnmodifiedIqPacket(startSession, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (packet.getType() == IqPacket.TYPE.TIMEOUT) {
|
if (packet.getType() == IqPacket.TYPE.RESULT) {
|
||||||
return;
|
|
||||||
} else if (packet.getType() == IqPacket.TYPE.RESULT) {
|
|
||||||
sendPostBindInitialization();
|
sendPostBindInitialization();
|
||||||
} else {
|
} else if (packet.getType() != IqPacket.TYPE.TIMEOUT){
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not init sessions");
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not init sessions");
|
||||||
disconnect(true);
|
disconnect(true);
|
||||||
}
|
}
|
||||||
|
@ -737,8 +737,7 @@ public class JingleConnection implements Transferable {
|
|||||||
JinglePacket answer = bootstrapPacket("transport-accept");
|
JinglePacket answer = bootstrapPacket("transport-accept");
|
||||||
Content content = new Content("initiator", "a-file-offer");
|
Content content = new Content("initiator", "a-file-offer");
|
||||||
content.setTransportId(this.transportId);
|
content.setTransportId(this.transportId);
|
||||||
content.ibbTransport().setAttribute("block-size",
|
content.ibbTransport().setAttribute("block-size",this.ibbBlockSize);
|
||||||
Integer.toString(this.ibbBlockSize));
|
|
||||||
answer.setContent(content);
|
answer.setContent(content);
|
||||||
this.sendJinglePacket(answer);
|
this.sendJinglePacket(answer);
|
||||||
return true;
|
return true;
|
||||||
|
@ -3,7 +3,7 @@ package eu.siacs.conversations.xmpp.jingle;
|
|||||||
import eu.siacs.conversations.entities.DownloadableFile;
|
import eu.siacs.conversations.entities.DownloadableFile;
|
||||||
|
|
||||||
public interface OnFileTransmissionStatusChanged {
|
public interface OnFileTransmissionStatusChanged {
|
||||||
public void onFileTransmitted(DownloadableFile file);
|
void onFileTransmitted(DownloadableFile file);
|
||||||
|
|
||||||
public void onFileTransferAborted();
|
void onFileTransferAborted();
|
||||||
}
|
}
|
||||||
|
@ -5,5 +5,5 @@ import eu.siacs.conversations.xmpp.PacketReceived;
|
|||||||
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket;
|
||||||
|
|
||||||
public interface OnJinglePacketReceived extends PacketReceived {
|
public interface OnJinglePacketReceived extends PacketReceived {
|
||||||
public void onJinglePacketReceived(Account account, JinglePacket packet);
|
void onJinglePacketReceived(Account account, JinglePacket packet);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.siacs.conversations.xmpp.jingle;
|
package eu.siacs.conversations.xmpp.jingle;
|
||||||
|
|
||||||
public interface OnPrimaryCandidateFound {
|
public interface OnPrimaryCandidateFound {
|
||||||
public void onPrimaryCandidateFound(boolean success,
|
void onPrimaryCandidateFound(boolean success, JingleCandidate canditate);
|
||||||
JingleCandidate canditate);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user