mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Addressed issues from code review.
This commit is contained in:
@@ -6,8 +6,8 @@ import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.UniqueId;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager.ContactAddedHook;
|
||||
import org.briarproject.api.contact.ContactManager.ContactRemovedHook;
|
||||
import org.briarproject.api.contact.ContactManager.AddContactHook;
|
||||
import org.briarproject.api.contact.ContactManager.RemoveContactHook;
|
||||
import org.briarproject.api.data.BdfDictionary;
|
||||
import org.briarproject.api.data.BdfReader;
|
||||
import org.briarproject.api.data.BdfReaderFactory;
|
||||
@@ -44,8 +44,8 @@ import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
|
||||
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||
|
||||
class MessagingManagerImpl implements MessagingManager, ContactAddedHook,
|
||||
ContactRemovedHook {
|
||||
class MessagingManagerImpl implements MessagingManager, AddContactHook,
|
||||
RemoveContactHook {
|
||||
|
||||
static final ClientId CLIENT_ID = new ClientId(StringUtils.fromHexString(
|
||||
"6bcdc006c0910b0f44e40644c3b31f1a"
|
||||
@@ -75,10 +75,10 @@ class MessagingManagerImpl implements MessagingManager, ContactAddedHook,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contactAdded(ContactId c) {
|
||||
public void addingContact(ContactId c) {
|
||||
try {
|
||||
// Create the conversation group
|
||||
Group g = createConversationGroup(db.getContact(c));
|
||||
Group g = getConversationGroup(db.getContact(c));
|
||||
// Subscribe to the group and share it with the contact
|
||||
db.addGroup(g);
|
||||
db.addContactGroup(c, g);
|
||||
@@ -88,7 +88,7 @@ class MessagingManagerImpl implements MessagingManager, ContactAddedHook,
|
||||
}
|
||||
}
|
||||
|
||||
private Group createConversationGroup(Contact c) {
|
||||
private Group getConversationGroup(Contact c) {
|
||||
AuthorId local = c.getLocalAuthorId();
|
||||
AuthorId remote = c.getAuthor().getId();
|
||||
byte[] descriptor = createGroupDescriptor(local, remote);
|
||||
@@ -116,9 +116,9 @@ class MessagingManagerImpl implements MessagingManager, ContactAddedHook,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contactRemoved(ContactId c) {
|
||||
public void removingContact(ContactId c) {
|
||||
try {
|
||||
db.removeGroup(createConversationGroup(db.getContact(c)));
|
||||
db.removeGroup(getConversationGroup(db.getContact(c)));
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class MessagingManagerImpl implements MessagingManager, ContactAddedHook,
|
||||
public ContactId getContactId(GroupId g) throws DbException {
|
||||
// TODO: Use metadata to attach the contact ID to the group
|
||||
for (Contact c : db.getContacts()) {
|
||||
Group conversation = createConversationGroup(c);
|
||||
Group conversation = getConversationGroup(c);
|
||||
if (conversation.getId().equals(g)) return c.getId();
|
||||
}
|
||||
throw new NoSuchContactException();
|
||||
@@ -157,7 +157,7 @@ class MessagingManagerImpl implements MessagingManager, ContactAddedHook,
|
||||
|
||||
@Override
|
||||
public GroupId getConversationId(ContactId c) throws DbException {
|
||||
return createConversationGroup(db.getContact(c)).getId();
|
||||
return getConversationGroup(db.getContact(c)).getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,8 +35,8 @@ public class MessagingModule extends AbstractModule {
|
||||
@Provides @Singleton
|
||||
MessagingManager getMessagingManager(ContactManager contactManager,
|
||||
MessagingManagerImpl messagingManager) {
|
||||
contactManager.registerContactAddedHook(messagingManager);
|
||||
contactManager.registerContactRemovedHook(messagingManager);
|
||||
contactManager.registerAddContactHook(messagingManager);
|
||||
contactManager.registerRemoveContactHook(messagingManager);
|
||||
return messagingManager;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user