mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Removed unneeded visibility methods.
This commit is contained in:
@@ -638,20 +638,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<ContactId> getVisibility(GroupId g) throws DbException {
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
if (!db.containsGroup(txn, g))
|
||||
throw new NoSuchGroupException();
|
||||
Collection<ContactId> visible = db.getVisibility(txn, g);
|
||||
db.commitTransaction(txn);
|
||||
return visible;
|
||||
} catch (DbException e) {
|
||||
db.abortTransaction(txn);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public void incrementStreamCounter(ContactId c, TransportId t,
|
||||
long rotationPeriod) throws DbException {
|
||||
T txn = db.startTransaction();
|
||||
@@ -956,38 +942,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisibility(GroupId g, Collection<ContactId> visible)
|
||||
throws DbException {
|
||||
Collection<ContactId> affected = new ArrayList<ContactId>();
|
||||
T txn = db.startTransaction();
|
||||
try {
|
||||
if (!db.containsGroup(txn, g))
|
||||
throw new NoSuchGroupException();
|
||||
// Use HashSets for O(1) lookups, O(n) overall running time
|
||||
Collection<ContactId> now = new HashSet<ContactId>(visible);
|
||||
Collection<ContactId> before = db.getVisibility(txn, g);
|
||||
before = new HashSet<ContactId>(before);
|
||||
// Set the group's visibility for each current contact
|
||||
for (ContactId c : db.getContactIds(txn)) {
|
||||
boolean wasBefore = before.contains(c);
|
||||
boolean isNow = now.contains(c);
|
||||
if (!wasBefore && isNow) {
|
||||
db.addVisibility(txn, c, g);
|
||||
affected.add(c);
|
||||
} else if (wasBefore && !isNow) {
|
||||
db.removeVisibility(txn, c, g);
|
||||
affected.add(c);
|
||||
}
|
||||
}
|
||||
db.commitTransaction(txn);
|
||||
} catch (DbException e) {
|
||||
db.abortTransaction(txn);
|
||||
throw e;
|
||||
}
|
||||
if (!affected.isEmpty())
|
||||
eventBus.broadcast(new GroupVisibilityUpdatedEvent(affected));
|
||||
}
|
||||
|
||||
public void setVisibleToContact(ContactId c, GroupId g, boolean visible)
|
||||
throws DbException {
|
||||
boolean wasVisible;
|
||||
|
||||
@@ -113,7 +113,7 @@ class ForumSharingManagerImpl implements ForumSharingManager, AddContactHook,
|
||||
Group g = getContactGroup(c);
|
||||
// Store the group and share it with the contact
|
||||
db.addGroup(g);
|
||||
db.setVisibility(g.getId(), Collections.singletonList(c.getId()));
|
||||
db.setVisibleToContact(c.getId(), g.getId(), true);
|
||||
// Attach the contact ID to the group
|
||||
BdfDictionary d = new BdfDictionary();
|
||||
d.put("contactId", c.getId().getInt());
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -77,7 +76,7 @@ class MessagingManagerImpl implements MessagingManager, AddContactHook,
|
||||
Group g = getContactGroup(c);
|
||||
// Store the group and share it with the contact
|
||||
db.addGroup(g);
|
||||
db.setVisibility(g.getId(), Collections.singletonList(c.getId()));
|
||||
db.setVisibleToContact(c.getId(), g.getId(), true);
|
||||
// Attach the contact ID to the group
|
||||
BdfDictionary d = new BdfDictionary();
|
||||
d.put("contactId", c.getId().getInt());
|
||||
|
||||
@@ -102,7 +102,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
Group g = getContactGroup(c);
|
||||
// Store the group and share it with the contact
|
||||
db.addGroup(g);
|
||||
db.setVisibility(g.getId(), Collections.singletonList(c.getId()));
|
||||
db.setVisibleToContact(c.getId(), g.getId(), true);
|
||||
// Copy the latest local properties into the group
|
||||
DeviceId dev = db.getDeviceId();
|
||||
Map<TransportId, TransportProperties> local = getLocalProperties();
|
||||
|
||||
Reference in New Issue
Block a user