mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Compare commits
2 Commits
fix-screen
...
client-ver
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72136cc627 | ||
|
|
411ace13aa |
@@ -22,6 +22,7 @@ import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.InvalidMessageException;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.sync.MessageStatus;
|
||||
import org.briarproject.bramble.api.sync.validation.IncomingMessageHook;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.api.versioning.ClientMajorVersion;
|
||||
@@ -36,17 +37,20 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.api.sync.Group.Visibility.INVISIBLE;
|
||||
import static org.briarproject.bramble.api.sync.Group.Visibility.SHARED;
|
||||
import static org.briarproject.bramble.api.sync.Group.Visibility.VISIBLE;
|
||||
@@ -58,6 +62,9 @@ import static org.briarproject.bramble.versioning.ClientVersioningConstants.MSG_
|
||||
class ClientVersioningManagerImpl implements ClientVersioningManager,
|
||||
Service, OpenDatabaseHook, ContactHook, IncomingMessageHook {
|
||||
|
||||
private static final Logger LOG =
|
||||
getLogger(ClientVersioningManagerImpl.class.getName());
|
||||
|
||||
private final DatabaseComponent db;
|
||||
private final ClientHelper clientHelper;
|
||||
private final ContactGroupFactory contactGroupFactory;
|
||||
@@ -128,12 +135,68 @@ class ClientVersioningManagerImpl implements ClientVersioningManager,
|
||||
|
||||
@Override
|
||||
public void onDatabaseOpened(Transaction txn) throws DbException {
|
||||
LOG.info("onDatabaseOpened " + localGroup.getId());
|
||||
for (Contact c : db.getContacts(txn)) {
|
||||
try {
|
||||
// FIXME: DO NOT MERGE, this logs the contact name and alias
|
||||
LOG.info(String.format(Locale.US,
|
||||
"find latest updates for %d: %s (%s)",
|
||||
c.getId().getInt(),
|
||||
c.getAuthor().getName(),
|
||||
c.getAlias()));
|
||||
LatestUpdates latestUpdates = findLatestUpdates(txn, c.getId());
|
||||
if (latestUpdates == null) {
|
||||
LOG.info("none found");
|
||||
} else {
|
||||
if (latestUpdates.local != null) {
|
||||
MessageStatus status = db.getMessageStatus(txn,
|
||||
c.getId(), latestUpdates.local.messageId);
|
||||
LOG.info(String.format(Locale.US,
|
||||
"local: %s; sent: %b; seen: %b%n",
|
||||
latestUpdates.local.messageId,
|
||||
status.isSent(),
|
||||
status.isSeen()));
|
||||
Update update =
|
||||
loadUpdate(txn, latestUpdates.local.messageId);
|
||||
printUpdate(update);
|
||||
}
|
||||
if (latestUpdates.remote != null) {
|
||||
MessageStatus status = db.getMessageStatus(txn,
|
||||
c.getId(), latestUpdates.remote.messageId);
|
||||
LOG.info(String.format(Locale.US,
|
||||
"remote: %s; sent: %b; seen: %b%n",
|
||||
latestUpdates.remote.messageId,
|
||||
status.isSent(),
|
||||
status.isSeen()));
|
||||
Update update =
|
||||
loadUpdate(txn, latestUpdates.remote.messageId);
|
||||
printUpdate(update);
|
||||
}
|
||||
}
|
||||
} catch (FormatException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if (db.containsGroup(txn, localGroup.getId())) return;
|
||||
db.addGroup(txn, localGroup);
|
||||
// Set things up for any pre-existing contacts
|
||||
for (Contact c : db.getContacts(txn)) addingContact(txn, c);
|
||||
}
|
||||
|
||||
private void printUpdate(Update update) {
|
||||
LOG.info(String.format(Locale.US, "update version: %d%n",
|
||||
update.updateVersion));
|
||||
for (ClientState state : update.states) {
|
||||
LOG.info(String.format(Locale.US,
|
||||
"id: %s, major: %d, minor: %d, active: %b, %n",
|
||||
state.clientVersion.getClientId().getString(),
|
||||
state.clientVersion.getClientMajorVersion()
|
||||
.getMajorVersion(),
|
||||
state.clientVersion.getMinorVersion(),
|
||||
state.active));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startService() throws ServiceException {
|
||||
List<ClientVersion> versions = new ArrayList<>(clients);
|
||||
|
||||
Submodule briar-mailbox updated: 64147fd1d0...d887c49ab3
Reference in New Issue
Block a user