mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Address review comments (rename event, fix annotations, final field)
This commit is contained in:
@@ -26,7 +26,7 @@ import org.briarproject.briar.api.blog.BlogSharingManager;
|
||||
import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent;
|
||||
import org.briarproject.briar.api.blog.event.BlogPostAddedEvent;
|
||||
import org.briarproject.briar.api.sharing.InvitationResponse;
|
||||
import org.briarproject.briar.api.sharing.event.ShareableLeftEvent;
|
||||
import org.briarproject.briar.api.sharing.event.ContactLeftShareableEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -110,10 +110,10 @@ class BlogControllerImpl extends BaseControllerImpl
|
||||
LOG.info("Blog invitation accepted");
|
||||
onBlogInvitationAccepted(b.getContactId());
|
||||
}
|
||||
} else if (e instanceof ShareableLeftEvent) {
|
||||
ShareableLeftEvent s = (ShareableLeftEvent) e;
|
||||
} else if (e instanceof ContactLeftShareableEvent) {
|
||||
ContactLeftShareableEvent s = (ContactLeftShareableEvent) e;
|
||||
if (s.getGroupId().equals(groupId)) {
|
||||
LOG.info("Blog left");
|
||||
LOG.info("Blog left by contact");
|
||||
onBlogLeft(s.getContactId());
|
||||
}
|
||||
} else if (e instanceof GroupRemovedEvent) {
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
public class SharingControllerImpl implements SharingController, EventListener {
|
||||
|
||||
@@ -26,8 +25,9 @@ public class SharingControllerImpl implements SharingController, EventListener {
|
||||
private final ConnectionRegistry connectionRegistry;
|
||||
|
||||
@Nullable
|
||||
private SharingListener listener;
|
||||
private Set<ContactId> contacts = new HashSet<>();
|
||||
private volatile SharingListener listener;
|
||||
// only access on @UiThread
|
||||
private final Set<ContactId> contacts = new HashSet<>();
|
||||
|
||||
@Inject
|
||||
SharingControllerImpl(EventBus eventBus,
|
||||
|
||||
@@ -10,12 +10,12 @@ import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class ShareableLeftEvent extends Event {
|
||||
public class ContactLeftShareableEvent extends Event {
|
||||
|
||||
private final GroupId groupId;
|
||||
private final ContactId contactId;
|
||||
|
||||
public ShareableLeftEvent(GroupId groupId, ContactId contactId) {
|
||||
public ContactLeftShareableEvent(GroupId groupId, ContactId contactId) {
|
||||
this.groupId = groupId;
|
||||
this.contactId = contactId;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ class BlogSharingManagerImpl extends
|
||||
@Override
|
||||
public BlogInvitation build(BlogSharerSessionState localState,
|
||||
long time) {
|
||||
return new BlogInvitation(localState.getGroupId(),
|
||||
return new BlogInvitation(localState.getContactGroupId(),
|
||||
localState.getSessionId(), localState.getBlogAuthorName(),
|
||||
localState.getBlogPublicKey(), time,
|
||||
localState.getMessage());
|
||||
@@ -338,7 +338,7 @@ class BlogSharingManagerImpl extends
|
||||
ContactId contactId = localState.getContactId();
|
||||
BlogInvitationRequest request =
|
||||
new BlogInvitationRequest(localState.getInvitationId(),
|
||||
localState.getSessionId(), localState.getGroupId(),
|
||||
localState.getSessionId(), localState.getContactGroupId(),
|
||||
contactId, blog.getAuthor().getName(), msg, true,
|
||||
time, false, false, false, false);
|
||||
return new BlogInvitationRequestReceivedEvent(blog, contactId,
|
||||
|
||||
@@ -191,7 +191,7 @@ class ForumSharingManagerImpl extends
|
||||
@Override
|
||||
public ForumInvitation build(ForumSharerSessionState localState,
|
||||
long time) {
|
||||
return new ForumInvitation(localState.getGroupId(),
|
||||
return new ForumInvitation(localState.getContactGroupId(),
|
||||
localState.getSessionId(), localState.getForumName(),
|
||||
localState.getForumSalt(), time, localState.getMessage());
|
||||
}
|
||||
@@ -268,7 +268,7 @@ class ForumSharingManagerImpl extends
|
||||
ContactId contactId = localState.getContactId();
|
||||
ForumInvitationRequest request = new ForumInvitationRequest(
|
||||
localState.getInvitationId(), localState.getSessionId(),
|
||||
localState.getGroupId(), contactId, forum.getName(), msg,
|
||||
localState.getContactGroupId(), contactId, forum.getName(), msg,
|
||||
true, time, false, false, false, false);
|
||||
return new ForumInvitationRequestReceivedEvent(forum, contactId,
|
||||
request);
|
||||
|
||||
@@ -77,20 +77,20 @@ class InviteeEngine<IS extends InviteeSessionState, IR extends InvitationRequest
|
||||
if (action == InviteeSessionState.Action.LOCAL_ACCEPT) {
|
||||
localState.setTask(TASK_ADD_SHARED_SHAREABLE);
|
||||
msg = new SimpleMessage(SHARE_MSG_TYPE_ACCEPT,
|
||||
localState.getGroupId(), localState.getSessionId(),
|
||||
localState.getContactGroupId(), localState.getSessionId(),
|
||||
clock.currentTimeMillis());
|
||||
} else {
|
||||
localState.setTask(
|
||||
TASK_REMOVE_SHAREABLE_FROM_LIST_SHARED_WITH_US);
|
||||
msg = new SimpleMessage(SHARE_MSG_TYPE_DECLINE,
|
||||
localState.getGroupId(), localState.getSessionId(),
|
||||
localState.getContactGroupId(), localState.getSessionId(),
|
||||
clock.currentTimeMillis());
|
||||
}
|
||||
messages = Collections.singletonList(msg);
|
||||
logLocalAction(currentState, localState, msg);
|
||||
} else if (action == InviteeSessionState.Action.LOCAL_LEAVE) {
|
||||
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_LEAVE,
|
||||
localState.getGroupId(), localState.getSessionId(),
|
||||
localState.getContactGroupId(), localState.getSessionId(),
|
||||
clock.currentTimeMillis());
|
||||
messages = Collections.singletonList(msg);
|
||||
logLocalAction(currentState, localState, msg);
|
||||
@@ -221,7 +221,7 @@ class InviteeEngine<IS extends InviteeSessionState, IR extends InvitationRequest
|
||||
}
|
||||
localState.setState(InviteeSessionState.State.ERROR);
|
||||
BaseMessage msg =
|
||||
new SimpleMessage(SHARE_MSG_TYPE_ABORT, localState.getGroupId(),
|
||||
new SimpleMessage(SHARE_MSG_TYPE_ABORT, localState.getContactGroupId(),
|
||||
localState.getSessionId(), clock.currentTimeMillis());
|
||||
List<BaseMessage> messages = Collections.singletonList(msg);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class SharerEngine<I extends Invitation, SS extends SharerSessionState, IRR exte
|
||||
.setTask(TASK_ADD_SHAREABLE_TO_LIST_TO_BE_SHARED_BY_US);
|
||||
} else if (action == SharerSessionState.Action.LOCAL_LEAVE) {
|
||||
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_LEAVE,
|
||||
localState.getGroupId(), localState.getSessionId(),
|
||||
localState.getContactGroupId(), localState.getSessionId(),
|
||||
clock.currentTimeMillis());
|
||||
messages = Collections.singletonList(msg);
|
||||
logLocalAction(currentState, nextState, msg);
|
||||
@@ -217,7 +217,7 @@ class SharerEngine<I extends Invitation, SS extends SharerSessionState, IRR exte
|
||||
|
||||
localState.setState(SharerSessionState.State.ERROR);
|
||||
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_ABORT,
|
||||
localState.getGroupId(), localState.getSessionId(),
|
||||
localState.getContactGroupId(), localState.getSessionId(),
|
||||
clock.currentTimeMillis());
|
||||
List<BaseMessage> messages = Collections.singletonList(msg);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.briarproject.briar.api.sharing.SharingInvitationItem;
|
||||
import org.briarproject.briar.api.sharing.SharingManager;
|
||||
import org.briarproject.briar.api.sharing.event.InvitationRequestReceivedEvent;
|
||||
import org.briarproject.briar.api.sharing.event.InvitationResponseReceivedEvent;
|
||||
import org.briarproject.briar.api.sharing.event.ShareableLeftEvent;
|
||||
import org.briarproject.briar.api.sharing.event.ContactLeftShareableEvent;
|
||||
import org.briarproject.briar.client.ConversationClientImpl;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -302,7 +302,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
// track message
|
||||
// TODO handle this properly without engine hacks (#376)
|
||||
long time = update.toSend.get(0).getTime();
|
||||
messageTracker.trackMessage(txn, localState.getGroupId(), time,
|
||||
messageTracker.trackMessage(txn, localState.getContactGroupId(), time,
|
||||
true);
|
||||
|
||||
db.commitTransaction(txn);
|
||||
@@ -366,7 +366,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
// track message
|
||||
// TODO handle this properly without engine hacks (#376)
|
||||
long time = update.toSend.get(0).getTime();
|
||||
messageTracker.trackMessage(txn, localState.getGroupId(), time, true);
|
||||
messageTracker.trackMessage(txn, localState.getContactGroupId(), time, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -873,7 +873,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
localState.setTask(-1);
|
||||
|
||||
// get group ID for later
|
||||
GroupId groupId = localState.getGroupId();
|
||||
GroupId groupId = localState.getContactGroupId();
|
||||
// get contact ID for later
|
||||
ContactId contactId = localState.getContactId();
|
||||
|
||||
@@ -899,13 +899,15 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
db.setGroupVisibility(txn, contactId, f.getId(), INVISIBLE);
|
||||
removeFromList(txn, groupId, SHARED_BY_US, f);
|
||||
// broadcast event informing UI that contact has left the group
|
||||
ShareableLeftEvent e = new ShareableLeftEvent(f.getId(), contactId);
|
||||
ContactLeftShareableEvent
|
||||
e = new ContactLeftShareableEvent(f.getId(), contactId);
|
||||
txn.attach(e);
|
||||
} else if (task == TASK_UNSHARE_SHAREABLE_SHARED_WITH_US) {
|
||||
db.setGroupVisibility(txn, contactId, f.getId(), INVISIBLE);
|
||||
removeFromList(txn, groupId, SHARED_WITH_US, f);
|
||||
// broadcast event informing UI that contact has left the group
|
||||
ShareableLeftEvent e = new ShareableLeftEvent(f.getId(), contactId);
|
||||
ContactLeftShareableEvent
|
||||
e = new ContactLeftShareableEvent(f.getId(), contactId);
|
||||
txn.attach(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ abstract class SharingSessionState {
|
||||
BdfDictionary d = new BdfDictionary();
|
||||
d.put(SESSION_ID, getSessionId());
|
||||
d.put(STORAGE_ID, getStorageId());
|
||||
d.put(GROUP_ID, getGroupId());
|
||||
d.put(GROUP_ID, getContactGroupId());
|
||||
d.put(CONTACT_ID, getContactId().getInt());
|
||||
d.put(SHAREABLE_ID, getShareableId());
|
||||
|
||||
@@ -83,7 +83,7 @@ abstract class SharingSessionState {
|
||||
return storageId;
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
public GroupId getContactGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user