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