mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
Added active flag to contacts.
This commit is contained in:
@@ -125,7 +125,7 @@ public class ContactListFragment extends BaseEventFragment {
|
|||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
List<ContactListItem> contacts =
|
List<ContactListItem> contacts =
|
||||||
new ArrayList<ContactListItem>();
|
new ArrayList<ContactListItem>();
|
||||||
for (Contact c : contactManager.getContacts()) {
|
for (Contact c : contactManager.getActiveContacts()) {
|
||||||
try {
|
try {
|
||||||
ContactId id = c.getId();
|
ContactId id = c.getId();
|
||||||
GroupId groupId =
|
GroupId groupId =
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ SelectContactsDialog.Listener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
contacts = contactManager.getContacts();
|
contacts = contactManager.getActiveContacts();
|
||||||
selected = forumSharingManager.getSharedWith(groupId);
|
selected = forumSharingManager.getSharedWith(groupId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
|
|||||||
@@ -8,11 +8,14 @@ public class Contact {
|
|||||||
private final ContactId id;
|
private final ContactId id;
|
||||||
private final Author author;
|
private final Author author;
|
||||||
private final AuthorId localAuthorId;
|
private final AuthorId localAuthorId;
|
||||||
|
private final boolean active;
|
||||||
|
|
||||||
public Contact(ContactId id, Author author, AuthorId localAuthorId) {
|
public Contact(ContactId id, Author author, AuthorId localAuthorId,
|
||||||
|
boolean active) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.author = author;
|
this.author = author;
|
||||||
this.localAuthorId = localAuthorId;
|
this.localAuthorId = localAuthorId;
|
||||||
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactId getId() {
|
public ContactId getId() {
|
||||||
@@ -27,6 +30,10 @@ public class Contact {
|
|||||||
return localAuthorId;
|
return localAuthorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return id.hashCode();
|
return id.hashCode();
|
||||||
|
|||||||
@@ -19,17 +19,21 @@ public interface ContactManager {
|
|||||||
* Stores a contact associated with the given local and remote pseudonyms,
|
* Stores a contact associated with the given local and remote pseudonyms,
|
||||||
* and returns an ID for the contact.
|
* and returns an ID for the contact.
|
||||||
*/
|
*/
|
||||||
ContactId addContact(Author remote, AuthorId local) throws DbException;
|
ContactId addContact(Author remote, AuthorId local, boolean active)
|
||||||
|
throws DbException;
|
||||||
|
|
||||||
/** Returns the contact with the given ID. */
|
/** Returns the contact with the given ID. */
|
||||||
Contact getContact(ContactId c) throws DbException;
|
Contact getContact(ContactId c) throws DbException;
|
||||||
|
|
||||||
/** Returns all contacts. */
|
/** Returns all active contacts. */
|
||||||
Collection<Contact> getContacts() throws DbException;
|
Collection<Contact> getActiveContacts() throws DbException;
|
||||||
|
|
||||||
/** Removes a contact and all associated state. */
|
/** Removes a contact and all associated state. */
|
||||||
void removeContact(ContactId c) throws DbException;
|
void removeContact(ContactId c) throws DbException;
|
||||||
|
|
||||||
|
/** Marks a contact as active or inactive. */
|
||||||
|
void setContactActive(ContactId c, boolean active) throws DbException;
|
||||||
|
|
||||||
interface AddContactHook {
|
interface AddContactHook {
|
||||||
void addingContact(Transaction txn, Contact c) throws DbException;
|
void addingContact(Transaction txn, Contact c) throws DbException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ public interface DatabaseComponent {
|
|||||||
* Stores a contact associated with the given local and remote pseudonyms,
|
* Stores a contact associated with the given local and remote pseudonyms,
|
||||||
* and returns an ID for the contact.
|
* and returns an ID for the contact.
|
||||||
*/
|
*/
|
||||||
ContactId addContact(Transaction txn, Author remote, AuthorId local)
|
ContactId addContact(Transaction txn, Author remote, AuthorId local,
|
||||||
throws DbException;
|
boolean active) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a group.
|
* Stores a group.
|
||||||
@@ -317,6 +317,12 @@ public interface DatabaseComponent {
|
|||||||
*/
|
*/
|
||||||
void removeTransport(Transaction txn, TransportId t) throws DbException;
|
void removeTransport(Transaction txn, TransportId t) throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks the given contact as active or inactive.
|
||||||
|
*/
|
||||||
|
void setContactActive(Transaction txn, ContactId c, boolean active)
|
||||||
|
throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the given message as shared or unshared.
|
* Marks the given message as shared or unshared.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.briarproject.api.event;
|
||||||
|
|
||||||
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
|
||||||
|
/** An event that is broadcast when a contact is marked active or inactive. */
|
||||||
|
public class ContactStatusChangedEvent extends Event {
|
||||||
|
|
||||||
|
private final ContactId contactId;
|
||||||
|
private final boolean active;
|
||||||
|
|
||||||
|
public ContactStatusChangedEvent(ContactId contactId, boolean active) {
|
||||||
|
this.contactId = contactId;
|
||||||
|
this.active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactId getContactId() {
|
||||||
|
return contactId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,9 @@ import org.briarproject.api.identity.AuthorId;
|
|||||||
import org.briarproject.api.identity.IdentityManager.RemoveIdentityHook;
|
import org.briarproject.api.identity.IdentityManager.RemoveIdentityHook;
|
||||||
import org.briarproject.api.identity.LocalAuthor;
|
import org.briarproject.api.identity.LocalAuthor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
@@ -41,12 +43,12 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContactId addContact(Author remote, AuthorId local)
|
public ContactId addContact(Author remote, AuthorId local, boolean active)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
ContactId c;
|
ContactId c;
|
||||||
Transaction txn = db.startTransaction();
|
Transaction txn = db.startTransaction();
|
||||||
try {
|
try {
|
||||||
c = db.addContact(txn, remote, local);
|
c = db.addContact(txn, remote, local, active);
|
||||||
Contact contact = db.getContact(txn, c);
|
Contact contact = db.getContact(txn, c);
|
||||||
for (AddContactHook hook : addHooks)
|
for (AddContactHook hook : addHooks)
|
||||||
hook.addingContact(txn, contact);
|
hook.addingContact(txn, contact);
|
||||||
@@ -71,7 +73,7 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Contact> getContacts() throws DbException {
|
public Collection<Contact> getActiveContacts() throws DbException {
|
||||||
Collection<Contact> contacts;
|
Collection<Contact> contacts;
|
||||||
Transaction txn = db.startTransaction();
|
Transaction txn = db.startTransaction();
|
||||||
try {
|
try {
|
||||||
@@ -80,7 +82,9 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
|||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(txn);
|
db.endTransaction(txn);
|
||||||
}
|
}
|
||||||
return contacts;
|
List<Contact> active = new ArrayList<Contact>(contacts.size());
|
||||||
|
for (Contact c : contacts) if (c.isActive()) active.add(c);
|
||||||
|
return Collections.unmodifiableList(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,6 +98,18 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setContactActive(ContactId c, boolean active)
|
||||||
|
throws DbException {
|
||||||
|
Transaction txn = db.startTransaction();
|
||||||
|
try {
|
||||||
|
db.setContactActive(txn, c, active);
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction(txn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void removeContact(Transaction txn, ContactId c)
|
private void removeContact(Transaction txn, ContactId c)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
Contact contact = db.getContact(txn, c);
|
Contact contact = db.getContact(txn, c);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ interface Database<T> {
|
|||||||
* Stores a contact associated with the given local and remote pseudonyms,
|
* Stores a contact associated with the given local and remote pseudonyms,
|
||||||
* and returns an ID for the contact.
|
* and returns an ID for the contact.
|
||||||
*/
|
*/
|
||||||
ContactId addContact(T txn, Author remote, AuthorId local)
|
ContactId addContact(T txn, Author remote, AuthorId local, boolean active)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -446,6 +446,12 @@ interface Database<T> {
|
|||||||
*/
|
*/
|
||||||
void resetExpiryTime(T txn, ContactId c, MessageId m) throws DbException;
|
void resetExpiryTime(T txn, ContactId c, MessageId m) throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks the given contact as active or inactive.
|
||||||
|
*/
|
||||||
|
void setContactActive(T txn, ContactId c, boolean active)
|
||||||
|
throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the given message as shared or unshared.
|
* Marks the given message as shared or unshared.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.briarproject.api.db.NoSuchTransportException;
|
|||||||
import org.briarproject.api.db.Transaction;
|
import org.briarproject.api.db.Transaction;
|
||||||
import org.briarproject.api.event.ContactAddedEvent;
|
import org.briarproject.api.event.ContactAddedEvent;
|
||||||
import org.briarproject.api.event.ContactRemovedEvent;
|
import org.briarproject.api.event.ContactRemovedEvent;
|
||||||
|
import org.briarproject.api.event.ContactStatusChangedEvent;
|
||||||
import org.briarproject.api.event.Event;
|
import org.briarproject.api.event.Event;
|
||||||
import org.briarproject.api.event.EventBus;
|
import org.briarproject.api.event.EventBus;
|
||||||
import org.briarproject.api.event.GroupAddedEvent;
|
import org.briarproject.api.event.GroupAddedEvent;
|
||||||
@@ -136,13 +137,13 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ContactId addContact(Transaction transaction, Author remote,
|
public ContactId addContact(Transaction transaction, Author remote,
|
||||||
AuthorId local) throws DbException {
|
AuthorId local, boolean active) throws DbException {
|
||||||
T txn = unbox(transaction);
|
T txn = unbox(transaction);
|
||||||
if (!db.containsLocalAuthor(txn, local))
|
if (!db.containsLocalAuthor(txn, local))
|
||||||
throw new NoSuchLocalAuthorException();
|
throw new NoSuchLocalAuthorException();
|
||||||
if (db.containsContact(txn, remote.getId(), local))
|
if (db.containsContact(txn, remote.getId(), local))
|
||||||
throw new ContactExistsException();
|
throw new ContactExistsException();
|
||||||
ContactId c = db.addContact(txn, remote, local);
|
ContactId c = db.addContact(txn, remote, local, active);
|
||||||
transaction.attach(new ContactAddedEvent(c));
|
transaction.attach(new ContactAddedEvent(c));
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -580,6 +581,15 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
|||||||
transaction.attach(new TransportRemovedEvent(t));
|
transaction.attach(new TransportRemovedEvent(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setContactActive(Transaction transaction, ContactId c,
|
||||||
|
boolean active) throws DbException {
|
||||||
|
T txn = unbox(transaction);
|
||||||
|
if (!db.containsContact(txn, c))
|
||||||
|
throw new NoSuchContactException();
|
||||||
|
db.setContactActive(txn, c, active);
|
||||||
|
transaction.attach(new ContactStatusChangedEvent(c, active));
|
||||||
|
}
|
||||||
|
|
||||||
public void setMessageShared(Transaction transaction, Message m,
|
public void setMessageShared(Transaction transaction, Message m,
|
||||||
boolean shared) throws DbException {
|
boolean shared) throws DbException {
|
||||||
T txn = unbox(transaction);
|
T txn = unbox(transaction);
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
+ " name VARCHAR NOT NULL,"
|
+ " name VARCHAR NOT NULL,"
|
||||||
+ " publicKey BINARY NOT NULL,"
|
+ " publicKey BINARY NOT NULL,"
|
||||||
+ " localAuthorId HASH NOT NULL,"
|
+ " localAuthorId HASH NOT NULL,"
|
||||||
|
+ " active BOOLEAN NOT NULL,"
|
||||||
+ " PRIMARY KEY (contactId),"
|
+ " PRIMARY KEY (contactId),"
|
||||||
+ " FOREIGN KEY (localAuthorId)"
|
+ " FOREIGN KEY (localAuthorId)"
|
||||||
+ " REFERENCES localAuthors (authorId)"
|
+ " REFERENCES localAuthors (authorId)"
|
||||||
@@ -441,20 +442,21 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
return new DeviceId(StringUtils.fromHexString(s.get(DEVICE_ID_KEY)));
|
return new DeviceId(StringUtils.fromHexString(s.get(DEVICE_ID_KEY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactId addContact(Connection txn, Author remote, AuthorId local)
|
public ContactId addContact(Connection txn, Author remote, AuthorId local,
|
||||||
throws DbException {
|
boolean active) throws DbException {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
// Create a contact row
|
// Create a contact row
|
||||||
String sql = "INSERT INTO contacts"
|
String sql = "INSERT INTO contacts"
|
||||||
+ " (authorId, name, publicKey, localAuthorId)"
|
+ " (authorId, name, publicKey, localAuthorId, active)"
|
||||||
+ " VALUES (?, ?, ?, ?)";
|
+ " VALUES (?, ?, ?, ?, ?)";
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
ps.setBytes(1, remote.getId().getBytes());
|
ps.setBytes(1, remote.getId().getBytes());
|
||||||
ps.setString(2, remote.getName());
|
ps.setString(2, remote.getName());
|
||||||
ps.setBytes(3, remote.getPublicKey());
|
ps.setBytes(3, remote.getPublicKey());
|
||||||
ps.setBytes(4, local.getBytes());
|
ps.setBytes(4, local.getBytes());
|
||||||
|
ps.setBoolean(5, active);
|
||||||
int affected = ps.executeUpdate();
|
int affected = ps.executeUpdate();
|
||||||
if (affected != 1) throw new DbStateException();
|
if (affected != 1) throw new DbStateException();
|
||||||
ps.close();
|
ps.close();
|
||||||
@@ -926,7 +928,8 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
String sql = "SELECT authorId, name, publicKey, localAuthorId"
|
String sql = "SELECT authorId, name, publicKey,"
|
||||||
|
+ " localAuthorId, active"
|
||||||
+ " FROM contacts"
|
+ " FROM contacts"
|
||||||
+ " WHERE contactId = ?";
|
+ " WHERE contactId = ?";
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
@@ -937,10 +940,11 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
String name = rs.getString(2);
|
String name = rs.getString(2);
|
||||||
byte[] publicKey = rs.getBytes(3);
|
byte[] publicKey = rs.getBytes(3);
|
||||||
AuthorId localAuthorId = new AuthorId(rs.getBytes(4));
|
AuthorId localAuthorId = new AuthorId(rs.getBytes(4));
|
||||||
|
boolean active = rs.getBoolean(5);
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
Author author = new Author(authorId, name, publicKey);
|
Author author = new Author(authorId, name, publicKey);
|
||||||
return new Contact(c, author, localAuthorId);
|
return new Contact(c, author, localAuthorId, active);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
tryToClose(rs);
|
tryToClose(rs);
|
||||||
tryToClose(ps);
|
tryToClose(ps);
|
||||||
@@ -954,7 +958,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
String sql = "SELECT contactId, authorId, name, publicKey,"
|
String sql = "SELECT contactId, authorId, name, publicKey,"
|
||||||
+ " localAuthorId"
|
+ " localAuthorId, active"
|
||||||
+ " FROM contacts";
|
+ " FROM contacts";
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
@@ -966,7 +970,9 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
byte[] publicKey = rs.getBytes(4);
|
byte[] publicKey = rs.getBytes(4);
|
||||||
Author author = new Author(authorId, name, publicKey);
|
Author author = new Author(authorId, name, publicKey);
|
||||||
AuthorId localAuthorId = new AuthorId(rs.getBytes(5));
|
AuthorId localAuthorId = new AuthorId(rs.getBytes(5));
|
||||||
contacts.add(new Contact(contactId, author, localAuthorId));
|
boolean active = rs.getBoolean(6);
|
||||||
|
contacts.add(new Contact(contactId, author, localAuthorId,
|
||||||
|
active));
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
@@ -2013,6 +2019,23 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setContactActive(Connection txn, ContactId c, boolean active)
|
||||||
|
throws DbException {
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
try {
|
||||||
|
String sql = "UPDATE contacts SET active = ? WHERE contactId = ?";
|
||||||
|
ps = txn.prepareStatement(sql);
|
||||||
|
ps.setBoolean(1, active);
|
||||||
|
ps.setInt(2, c.getInt());
|
||||||
|
int affected = ps.executeUpdate();
|
||||||
|
if (affected < 0 || affected > 1) throw new DbStateException();
|
||||||
|
ps.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
tryToClose(ps);
|
||||||
|
throw new DbException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setMessageShared(Connection txn, MessageId m, boolean shared)
|
public void setMessageShared(Connection txn, MessageId m, boolean shared)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
@@ -2022,7 +2045,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
ps.setBoolean(1, shared);
|
ps.setBoolean(1, shared);
|
||||||
ps.setBytes(2, m.getBytes());
|
ps.setBytes(2, m.getBytes());
|
||||||
int affected = ps.executeUpdate();
|
int affected = ps.executeUpdate();
|
||||||
if (affected < 0) throw new DbStateException();
|
if (affected < 0 || affected > 1) throw new DbStateException();
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
tryToClose(ps);
|
tryToClose(ps);
|
||||||
@@ -2039,7 +2062,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
ps.setInt(1, valid ? VALID.getValue() : INVALID.getValue());
|
ps.setInt(1, valid ? VALID.getValue() : INVALID.getValue());
|
||||||
ps.setBytes(2, m.getBytes());
|
ps.setBytes(2, m.getBytes());
|
||||||
int affected = ps.executeUpdate();
|
int affected = ps.executeUpdate();
|
||||||
if (affected < 0) throw new DbStateException();
|
if (affected < 0 || affected > 1) throw new DbStateException();
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
tryToClose(ps);
|
tryToClose(ps);
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ abstract class Connector extends Thread {
|
|||||||
long timestamp, boolean alice) throws DbException {
|
long timestamp, boolean alice) throws DbException {
|
||||||
// Add the contact to the database
|
// Add the contact to the database
|
||||||
contactId = contactManager.addContact(remoteAuthor,
|
contactId = contactManager.addContact(remoteAuthor,
|
||||||
localAuthor.getId());
|
localAuthor.getId(), true);
|
||||||
// Derive transport keys
|
// Derive transport keys
|
||||||
keyManager.addContact(contactId, master, timestamp, alice);
|
keyManager.addContact(contactId, master, timestamp, alice);
|
||||||
return contactId;
|
return contactId;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
transportId = new TransportId("id");
|
transportId = new TransportId("id");
|
||||||
maxLatency = Integer.MAX_VALUE;
|
maxLatency = Integer.MAX_VALUE;
|
||||||
contactId = new ContactId(234);
|
contactId = new ContactId(234);
|
||||||
contact = new Contact(contactId, author, localAuthorId);
|
contact = new Contact(contactId, author, localAuthorId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DatabaseComponent createDatabaseComponent(Database<Object> database,
|
private DatabaseComponent createDatabaseComponent(Database<Object> database,
|
||||||
@@ -143,7 +143,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
will(returnValue(true));
|
will(returnValue(true));
|
||||||
oneOf(database).containsContact(txn, authorId, localAuthorId);
|
oneOf(database).containsContact(txn, authorId, localAuthorId);
|
||||||
will(returnValue(false));
|
will(returnValue(false));
|
||||||
oneOf(database).addContact(txn, author, localAuthorId);
|
oneOf(database).addContact(txn, author, localAuthorId, true);
|
||||||
will(returnValue(contactId));
|
will(returnValue(contactId));
|
||||||
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
|
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
|
||||||
// getContacts()
|
// getContacts()
|
||||||
@@ -193,7 +193,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
db.addLocalAuthor(transaction, localAuthor);
|
db.addLocalAuthor(transaction, localAuthor);
|
||||||
assertEquals(contactId,
|
assertEquals(contactId,
|
||||||
db.addContact(transaction, author, localAuthorId));
|
db.addContact(transaction, author, localAuthorId, true));
|
||||||
assertEquals(Collections.singletonList(contact),
|
assertEquals(Collections.singletonList(contact),
|
||||||
db.getContacts(transaction));
|
db.getContacts(transaction));
|
||||||
db.addGroup(transaction, group); // First time - listeners called
|
db.addGroup(transaction, group); // First time - listeners called
|
||||||
@@ -294,11 +294,11 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
final EventBus eventBus = context.mock(EventBus.class);
|
final EventBus eventBus = context.mock(EventBus.class);
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
// Check whether the contact is in the DB (which it's not)
|
// Check whether the contact is in the DB (which it's not)
|
||||||
exactly(17).of(database).startTransaction();
|
exactly(18).of(database).startTransaction();
|
||||||
will(returnValue(txn));
|
will(returnValue(txn));
|
||||||
exactly(17).of(database).containsContact(txn, contactId);
|
exactly(18).of(database).containsContact(txn, contactId);
|
||||||
will(returnValue(false));
|
will(returnValue(false));
|
||||||
exactly(17).of(database).abortTransaction(txn);
|
exactly(18).of(database).abortTransaction(txn);
|
||||||
}});
|
}});
|
||||||
DatabaseComponent db = createDatabaseComponent(database, eventBus,
|
DatabaseComponent db = createDatabaseComponent(database, eventBus,
|
||||||
shutdown);
|
shutdown);
|
||||||
@@ -456,6 +456,16 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transaction = db.startTransaction();
|
||||||
|
try {
|
||||||
|
db.setContactActive(transaction, contactId, true);
|
||||||
|
fail();
|
||||||
|
} catch (NoSuchContactException expected) {
|
||||||
|
// Expected
|
||||||
|
} finally {
|
||||||
|
db.endTransaction(transaction);
|
||||||
|
}
|
||||||
|
|
||||||
transaction = db.startTransaction();
|
transaction = db.startTransaction();
|
||||||
try {
|
try {
|
||||||
db.setReorderingWindow(transaction, contactId, transportId, 0, 0,
|
db.setReorderingWindow(transaction, contactId, transportId, 0, 0,
|
||||||
@@ -501,7 +511,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
|
|
||||||
Transaction transaction = db.startTransaction();
|
Transaction transaction = db.startTransaction();
|
||||||
try {
|
try {
|
||||||
db.addContact(transaction, author, localAuthorId);
|
db.addContact(transaction, author, localAuthorId, true);
|
||||||
fail();
|
fail();
|
||||||
} catch (NoSuchLocalAuthorException expected) {
|
} catch (NoSuchLocalAuthorException expected) {
|
||||||
// Expected
|
// Expected
|
||||||
@@ -755,7 +765,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
will(returnValue(true));
|
will(returnValue(true));
|
||||||
oneOf(database).containsContact(txn, authorId, localAuthorId);
|
oneOf(database).containsContact(txn, authorId, localAuthorId);
|
||||||
will(returnValue(false));
|
will(returnValue(false));
|
||||||
oneOf(database).addContact(txn, author, localAuthorId);
|
oneOf(database).addContact(txn, author, localAuthorId, true);
|
||||||
will(returnValue(contactId));
|
will(returnValue(contactId));
|
||||||
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
|
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
|
||||||
// endTransaction()
|
// endTransaction()
|
||||||
@@ -776,7 +786,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
|
|||||||
try {
|
try {
|
||||||
db.addLocalAuthor(transaction, localAuthor);
|
db.addLocalAuthor(transaction, localAuthor);
|
||||||
assertEquals(contactId,
|
assertEquals(contactId,
|
||||||
db.addContact(transaction, author, localAuthorId));
|
db.addContact(transaction, author, localAuthorId, true));
|
||||||
transaction.setComplete();
|
transaction.setComplete();
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction(transaction);
|
db.endTransaction(transaction);
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
Connection txn = db.startTransaction();
|
Connection txn = db.startTransaction();
|
||||||
assertFalse(db.containsContact(txn, contactId));
|
assertFalse(db.containsContact(txn, contactId));
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
assertTrue(db.containsContact(txn, contactId));
|
assertTrue(db.containsContact(txn, contactId));
|
||||||
assertFalse(db.containsGroup(txn, groupId));
|
assertFalse(db.containsGroup(txn, groupId));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
@@ -170,7 +171,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact, a group and a message
|
// Add a contact, a group and a message
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addVisibility(txn, contactId, groupId);
|
db.addVisibility(txn, contactId, groupId);
|
||||||
db.addMessage(txn, message, VALID, true);
|
db.addMessage(txn, message, VALID, true);
|
||||||
@@ -207,7 +209,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact, a group and an unvalidated message
|
// Add a contact, a group and an unvalidated message
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addVisibility(txn, contactId, groupId);
|
db.addVisibility(txn, contactId, groupId);
|
||||||
db.addMessage(txn, message, UNKNOWN, true);
|
db.addMessage(txn, message, UNKNOWN, true);
|
||||||
@@ -245,7 +248,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact, a group and an unshared message
|
// Add a contact, a group and an unshared message
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addVisibility(txn, contactId, groupId);
|
db.addVisibility(txn, contactId, groupId);
|
||||||
db.addMessage(txn, message, VALID, false);
|
db.addMessage(txn, message, VALID, false);
|
||||||
@@ -283,7 +287,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact, a group and a message
|
// Add a contact, a group and a message
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addVisibility(txn, contactId, groupId);
|
db.addVisibility(txn, contactId, groupId);
|
||||||
db.addMessage(txn, message, VALID, true);
|
db.addMessage(txn, message, VALID, true);
|
||||||
@@ -309,7 +314,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact and a group
|
// Add a contact and a group
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addVisibility(txn, contactId, groupId);
|
db.addVisibility(txn, contactId, groupId);
|
||||||
|
|
||||||
@@ -345,7 +351,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact, a group and a message
|
// Add a contact, a group and a message
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addVisibility(txn, contactId, groupId);
|
db.addVisibility(txn, contactId, groupId);
|
||||||
db.addMessage(txn, message, VALID, true);
|
db.addMessage(txn, message, VALID, true);
|
||||||
@@ -508,7 +515,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact and a group
|
// Add a contact and a group
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addVisibility(txn, contactId, groupId);
|
db.addVisibility(txn, contactId, groupId);
|
||||||
|
|
||||||
@@ -527,7 +535,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact
|
// Add a contact
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
|
|
||||||
// The group is not in the database
|
// The group is not in the database
|
||||||
assertFalse(db.containsVisibleMessage(txn, contactId, messageId));
|
assertFalse(db.containsVisibleMessage(txn, contactId, messageId));
|
||||||
@@ -544,7 +553,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact, a group and a message
|
// Add a contact, a group and a message
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addMessage(txn, message, VALID, true);
|
db.addMessage(txn, message, VALID, true);
|
||||||
db.addStatus(txn, contactId, messageId, false, false);
|
db.addStatus(txn, contactId, messageId, false, false);
|
||||||
@@ -563,7 +573,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact and a group
|
// Add a contact and a group
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
|
|
||||||
// The group should not be visible to the contact
|
// The group should not be visible to the contact
|
||||||
@@ -598,7 +609,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact and the groups
|
// Add a contact and the groups
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
for (Group g : groups) db.addGroup(txn, g);
|
for (Group g : groups) db.addGroup(txn, g);
|
||||||
|
|
||||||
// Make the groups visible to the contact
|
// Make the groups visible to the contact
|
||||||
@@ -630,7 +642,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add the contact, the transport and the transport keys
|
// Add the contact, the transport and the transport keys
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addTransport(txn, transportId, 123);
|
db.addTransport(txn, transportId, 123);
|
||||||
db.addTransportKeys(txn, contactId, keys);
|
db.addTransportKeys(txn, contactId, keys);
|
||||||
|
|
||||||
@@ -691,7 +704,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add the contact, transport and transport keys
|
// Add the contact, transport and transport keys
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addTransport(txn, transportId, 123);
|
db.addTransport(txn, transportId, 123);
|
||||||
db.updateTransportKeys(txn, Collections.singletonMap(contactId, keys));
|
db.updateTransportKeys(txn, Collections.singletonMap(contactId, keys));
|
||||||
|
|
||||||
@@ -726,7 +740,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add the contact, transport and transport keys
|
// Add the contact, transport and transport keys
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addTransport(txn, transportId, 123);
|
db.addTransport(txn, transportId, 123);
|
||||||
db.updateTransportKeys(txn, Collections.singletonMap(contactId, keys));
|
db.updateTransportKeys(txn, Collections.singletonMap(contactId, keys));
|
||||||
|
|
||||||
@@ -762,7 +777,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
assertEquals(Collections.emptyList(), contacts);
|
assertEquals(Collections.emptyList(), contacts);
|
||||||
|
|
||||||
// Add a contact associated with the local author
|
// Add a contact associated with the local author
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
contacts = db.getContacts(txn, localAuthorId);
|
contacts = db.getContacts(txn, localAuthorId);
|
||||||
assertEquals(Collections.singletonList(contactId), contacts);
|
assertEquals(Collections.singletonList(contactId), contacts);
|
||||||
|
|
||||||
@@ -783,7 +799,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact - initially there should be no offered messages
|
// Add a contact - initially there should be no offered messages
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
assertEquals(0, db.countOfferedMessages(txn, contactId));
|
assertEquals(0, db.countOfferedMessages(txn, contactId));
|
||||||
|
|
||||||
// Add some offered messages and count them
|
// Add some offered messages and count them
|
||||||
@@ -921,7 +938,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact
|
// Add a contact
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
|
|
||||||
// Add a group and make it visible to the contact
|
// Add a group and make it visible to the contact
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
@@ -997,7 +1015,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact and a group
|
// Add a contact and a group
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
|
|
||||||
// The group should not be visible to the contact
|
// The group should not be visible to the contact
|
||||||
@@ -1030,8 +1049,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
db.addLocalAuthor(txn, localAuthor1);
|
db.addLocalAuthor(txn, localAuthor1);
|
||||||
|
|
||||||
// Add the same contact for each local pseudonym
|
// Add the same contact for each local pseudonym
|
||||||
ContactId contactId = db.addContact(txn, author, localAuthorId);
|
ContactId contactId = db.addContact(txn, author, localAuthorId, true);
|
||||||
ContactId contactId1 = db.addContact(txn, author, localAuthorId1);
|
ContactId contactId1 = db.addContact(txn, author, localAuthorId1, true);
|
||||||
|
|
||||||
// The contacts should be distinct
|
// The contacts should be distinct
|
||||||
assertNotEquals(contactId, contactId1);
|
assertNotEquals(contactId, contactId1);
|
||||||
@@ -1050,7 +1069,8 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
|
|
||||||
// Add a contact, a group and a message
|
// Add a contact, a group and a message
|
||||||
db.addLocalAuthor(txn, localAuthor);
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
db.addGroup(txn, group);
|
db.addGroup(txn, group);
|
||||||
db.addVisibility(txn, contactId, groupId);
|
db.addVisibility(txn, contactId, groupId);
|
||||||
db.addMessage(txn, message, VALID, true);
|
db.addMessage(txn, message, VALID, true);
|
||||||
|
|||||||
@@ -134,7 +134,8 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
|||||||
// Add Bob as a contact
|
// Add Bob as a contact
|
||||||
Author bobAuthor = new Author(bobId, "Bob",
|
Author bobAuthor = new Author(bobId, "Bob",
|
||||||
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||||
ContactId contactId = contactManager.addContact(bobAuthor, aliceId);
|
ContactId contactId = contactManager.addContact(bobAuthor, aliceId,
|
||||||
|
true);
|
||||||
// Derive and store the transport keys
|
// Derive and store the transport keys
|
||||||
keyManager.addContact(contactId, master, timestamp, true);
|
keyManager.addContact(contactId, master, timestamp, true);
|
||||||
|
|
||||||
@@ -204,7 +205,8 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
|||||||
// Add Alice as a contact
|
// Add Alice as a contact
|
||||||
Author aliceAuthor = new Author(aliceId, "Alice",
|
Author aliceAuthor = new Author(aliceId, "Alice",
|
||||||
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||||
ContactId contactId = contactManager.addContact(aliceAuthor, bobId);
|
ContactId contactId = contactManager.addContact(aliceAuthor, bobId,
|
||||||
|
true);
|
||||||
// Derive and store the transport keys
|
// Derive and store the transport keys
|
||||||
keyManager.addContact(contactId, master, timestamp, false);
|
keyManager.addContact(contactId, master, timestamp, false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user