mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Provide earlier feedback in the UI when connecting to a new contact.
Partially addresses issue #3611924.
This commit is contained in:
@@ -91,10 +91,12 @@ class AliceConnector extends Connector {
|
||||
secret = deriveMasterSecret(hash, key, true);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
group.keyAgreementFailed();
|
||||
tryToClose(conn, true);
|
||||
return;
|
||||
} catch(GeneralSecurityException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
group.keyAgreementFailed();
|
||||
tryToClose(conn, true);
|
||||
return;
|
||||
}
|
||||
@@ -102,7 +104,7 @@ class AliceConnector extends Connector {
|
||||
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " agreement succeeded");
|
||||
int[] codes = crypto.deriveConfirmationCodes(secret);
|
||||
int aliceCode = codes[0], bobCode = codes[1];
|
||||
group.connectionSucceeded(aliceCode, bobCode);
|
||||
group.keyAgreementSucceeded(aliceCode, bobCode);
|
||||
// Exchange confirmation results
|
||||
try {
|
||||
sendConfirmation(w);
|
||||
|
||||
@@ -91,10 +91,12 @@ class BobConnector extends Connector {
|
||||
secret = deriveMasterSecret(hash, key, false);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
group.keyAgreementFailed();
|
||||
tryToClose(conn, true);
|
||||
return;
|
||||
} catch(GeneralSecurityException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
group.keyAgreementFailed();
|
||||
tryToClose(conn, true);
|
||||
return;
|
||||
}
|
||||
@@ -102,7 +104,7 @@ class BobConnector extends Connector {
|
||||
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " agreement succeeded");
|
||||
int[] codes = crypto.deriveConfirmationCodes(secret);
|
||||
int aliceCode = codes[0], bobCode = codes[1];
|
||||
group.connectionSucceeded(bobCode, aliceCode);
|
||||
group.keyAgreementSucceeded(bobCode, aliceCode);
|
||||
// Exchange confirmation results
|
||||
try {
|
||||
if(receiveConfirmation(r)) group.remoteConfirmationSucceeded();
|
||||
|
||||
@@ -101,7 +101,7 @@ class ConnectorGroup extends Thread implements InvitationTask {
|
||||
public synchronized InvitationState addListener(InvitationListener l) {
|
||||
listeners.add(l);
|
||||
return new InvitationState(localInvitationCode, remoteInvitationCode,
|
||||
localConfirmationCode, remoteConfirmationCode,
|
||||
localConfirmationCode, remoteConfirmationCode, connected.get(),
|
||||
connectionFailed, localCompared, remoteCompared, localMatched,
|
||||
remoteMatched, remoteName);
|
||||
}
|
||||
@@ -202,16 +202,24 @@ class ConnectorGroup extends Thread implements InvitationTask {
|
||||
}
|
||||
|
||||
boolean getAndSetConnected() {
|
||||
return connected.getAndSet(true);
|
||||
boolean redundant = connected.getAndSet(true);
|
||||
if(!redundant) {
|
||||
for(InvitationListener l : listeners) l.connectionSucceeded();
|
||||
}
|
||||
return redundant;
|
||||
}
|
||||
|
||||
void connectionSucceeded(int localCode, int remoteCode) {
|
||||
void keyAgreementSucceeded(int localCode, int remoteCode) {
|
||||
synchronized(this) {
|
||||
localConfirmationCode = localCode;
|
||||
remoteConfirmationCode = remoteCode;
|
||||
}
|
||||
for(InvitationListener l : listeners)
|
||||
l.connectionSucceeded(localCode, remoteCode);
|
||||
l.keyAgreementSucceeded(localCode, remoteCode);
|
||||
}
|
||||
|
||||
void keyAgreementFailed() {
|
||||
for(InvitationListener l : listeners) l.keyAgreementFailed();
|
||||
}
|
||||
|
||||
void remoteConfirmationSucceeded() {
|
||||
|
||||
Reference in New Issue
Block a user