mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Include unique device ID in transport updates.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.db;
|
||||
|
||||
import org.briarproject.api.DeviceId;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
@@ -256,6 +257,13 @@ interface Database<T> {
|
||||
*/
|
||||
Collection<ContactId> getContacts(T txn, AuthorId a) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the unique ID for this device.
|
||||
* <p>
|
||||
* Locking: read.
|
||||
*/
|
||||
DeviceId getDeviceId(T txn) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the amount of free storage space available to the database, in
|
||||
* bytes. This is based on the minimum of the space available on the device
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.db;
|
||||
|
||||
import org.briarproject.api.DeviceId;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
@@ -542,6 +543,23 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public DeviceId getDeviceId() throws DbException {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
DeviceId id = db.getDeviceId(txn);
|
||||
db.commitTransaction(txn);
|
||||
return id;
|
||||
} catch (DbException e) {
|
||||
db.abortTransaction(txn);
|
||||
throw e;
|
||||
}
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Group getGroup(GroupId g) throws DbException {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.db;
|
||||
|
||||
import org.briarproject.api.DeviceId;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.UniqueId;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
@@ -484,6 +485,11 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
if (interrupted) Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
public DeviceId getDeviceId(Connection txn) throws DbException {
|
||||
Settings s = getSettings(txn, DEVICE_SETTINGS_NAMESPACE);
|
||||
return new DeviceId(StringUtils.fromHexString(s.get(DEVICE_ID_KEY)));
|
||||
}
|
||||
|
||||
public ContactId addContact(Connection txn, Author remote, AuthorId local)
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
|
||||
Reference in New Issue
Block a user