Add ContactRelationshipRevealedEvent and address review comments

This commit is contained in:
Torsten Grote
2016-11-09 17:45:25 -02:00
parent 3eed0bfe81
commit 5e5bf7ec05
10 changed files with 101 additions and 71 deletions

View File

@@ -0,0 +1,30 @@
package org.briarproject.api.privategroup;
import org.briarproject.api.event.Event;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.sync.GroupId;
import javax.annotation.concurrent.Immutable;
@Immutable
@NotNullByDefault
public class ContactRelationshipRevealedEvent extends Event {
private final GroupId groupId;
private final Visibility visibility;
public ContactRelationshipRevealedEvent(GroupId groupId,
Visibility visibility) {
this.groupId = groupId;
this.visibility = visibility;
}
public GroupId getGroupId() {
return groupId;
}
public Visibility getVisibility() {
return visibility;
}
}

View File

@@ -25,9 +25,7 @@ public class PrivateGroup extends NamedGroup implements Shareable {
@Override
public boolean equals(Object o) {
return o instanceof PrivateGroup &&
creator.equals(((PrivateGroup) o).getCreator()) &&
super.equals(o);
return o instanceof PrivateGroup && super.equals(o);
}
}

View File

@@ -22,22 +22,24 @@ public interface PrivateGroupManager extends MessageTracker {
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.privategroup");
/**
* Adds a new private group and joins it as the creator.
* Adds a new private group and joins it.
*
* @param group The private group to add
* @param joinMsg The creators's join message
* @param creator True if the group is added by its creator
*/
void addPrivateGroup(PrivateGroup group, GroupMessage joinMsg)
throws DbException;
void addPrivateGroup(PrivateGroup group, GroupMessage joinMsg,
boolean creator) throws DbException;
/**
* Adds a new private group and joins it as a member.
* Adds a new private group and joins it.
*
* @param group The private group to add
* @param joinMsg The new member's join message
* @param creator True if the group is added by its creator
*/
void addPrivateGroup(Transaction txn, PrivateGroup group,
GroupMessage joinMsg) throws DbException;
GroupMessage joinMsg, boolean creator) throws DbException;
/**
* Removes a dissolved private group.
@@ -45,7 +47,7 @@ public interface PrivateGroupManager extends MessageTracker {
void removePrivateGroup(GroupId g) throws DbException;
/**
* Gets the MessageId of your previous message sent to the group
* Gets the MessageId of the user's previous message sent to the group
*/
MessageId getPreviousMsgId(GroupId g) throws DbException;
@@ -107,7 +109,7 @@ public interface PrivateGroupManager extends MessageTracker {
/**
* This method needs to be called when a contact relationship
* has been revealed between you and the Author with AuthorId a
* has been revealed between the user and the Author with AuthorId a
* in the Group identified by the GroupId g.
*
* @param byContact true if the remote contact has revealed

View File

@@ -1,10 +1,12 @@
package org.briarproject.api.privategroup;
import org.briarproject.api.FormatException;
public enum Visibility {
INVISIBLE(0),
VISIBLE(1),
REVEALED_BY_YOU(2),
REVEALED_BY_US(2),
REVEALED_BY_CONTACT(3);
int value;
@@ -13,9 +15,9 @@ public enum Visibility {
this.value = value;
}
public static Visibility valueOf(int value) {
public static Visibility valueOf(int value) throws FormatException {
for (Visibility v : values()) if (v.value == value) return v;
throw new IllegalArgumentException();
throw new FormatException();
}
public int getInt() {