Give positive ratings to own pseudonyms and contacts' known pseudonyms.

This commit is contained in:
akwizgran
2013-04-14 15:17:11 +01:00
parent 8e9517ced0
commit 3c677a8599
3 changed files with 8 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_MATCH;
import static net.sf.briar.api.messaging.Rating.GOOD;
import java.util.ArrayList;
import java.util.List;
@@ -123,6 +124,7 @@ public class HomeScreenActivity extends BriarActivity {
serviceConnection.waitForStartup();
long now = System.currentTimeMillis();
db.addLocalAuthor(a);
db.setRating(a.getId(), GOOD);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
LOG.info("Storing author took " + duration + " ms");

View File

@@ -12,6 +12,7 @@ import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_MATCH;
import static net.sf.briar.android.widgets.CommonLayoutParams.WRAP_WRAP;
import static net.sf.briar.api.messaging.Rating.GOOD;
import java.io.IOException;
import java.security.KeyPair;
@@ -157,6 +158,7 @@ implements OnEditorActionListener, OnClickListener {
serviceConnection.waitForStartup();
long now = System.currentTimeMillis();
db.addLocalAuthor(a);
db.setRating(a.getId(), GOOD);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
LOG.info("Storing author took " + duration + " ms");

View File

@@ -9,6 +9,7 @@ import static net.sf.briar.api.TransportPropertyConstants.MAX_PROPERTIES_PER_TRA
import static net.sf.briar.api.TransportPropertyConstants.MAX_PROPERTY_LENGTH;
import static net.sf.briar.api.invitation.InvitationConstants.CONNECTION_TIMEOUT;
import static net.sf.briar.api.invitation.InvitationConstants.HASH_LENGTH;
import static net.sf.briar.api.messaging.Rating.GOOD;
import java.io.IOException;
import java.security.GeneralSecurityException;
@@ -275,13 +276,15 @@ abstract class Connector extends Thread {
long epoch, boolean alice) throws DbException {
// Add the contact to the database
ContactId c = db.addContact(remoteAuthor, localAuthor.getId());
// Add a positive rating for the contact's pseudonym
db.setRating(remoteAuthor.getId(), GOOD);
// Store the remote transport properties
db.setRemoteProperties(c, remoteProps);
// Create an endpoint for each transport shared with the contact
List<TransportId> ids = new ArrayList<TransportId>();
for(TransportId id : localProps.keySet())
if(remoteProps.containsKey(id)) ids.add(id);
// Assign indices to the transports in a deterministic way
// Assign indices to the transports deterministically and derive keys
Collections.sort(ids, TransportIdComparator.INSTANCE);
int size = ids.size();
for(int i = 0; i < size; i++) {