mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Addressed issues from code review.
This commit is contained in:
@@ -1,37 +1,18 @@
|
||||
package org.briarproject.api.contact;
|
||||
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
|
||||
public class Contact {
|
||||
|
||||
public enum Status {
|
||||
|
||||
ADDING(0), ACTIVE(1), REMOVING(2);
|
||||
|
||||
private final int value;
|
||||
|
||||
Status(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Status fromValue(int value) {
|
||||
for (Status s : values()) if (s.value == value) return s;
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private final ContactId id;
|
||||
private final Author author;
|
||||
private final AuthorId localAuthorId;
|
||||
private final Status status;
|
||||
private final StorageStatus status;
|
||||
|
||||
public Contact(ContactId id, Author author, AuthorId localAuthorId,
|
||||
Status status) {
|
||||
StorageStatus status) {
|
||||
this.id = id;
|
||||
this.author = author;
|
||||
this.localAuthorId = localAuthorId;
|
||||
@@ -50,7 +31,7 @@ public class Contact {
|
||||
return localAuthorId;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
public StorageStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import java.util.Collection;
|
||||
public interface ContactManager {
|
||||
|
||||
/** Registers a hook to be called whenever a contact is added. */
|
||||
void registerContactAddedHook(ContactAddedHook hook);
|
||||
void registerAddContactHook(AddContactHook hook);
|
||||
|
||||
/** Registers a hook to be called whenever a contact is removed. */
|
||||
void registerContactRemovedHook(ContactRemovedHook hook);
|
||||
void registerRemoveContactHook(RemoveContactHook hook);
|
||||
|
||||
/**
|
||||
* Stores a contact associated with the given local and remote pseudonyms,
|
||||
@@ -29,11 +29,11 @@ public interface ContactManager {
|
||||
/** Removes a contact and all associated state. */
|
||||
void removeContact(ContactId c) throws DbException;
|
||||
|
||||
interface ContactAddedHook {
|
||||
void contactAdded(ContactId c);
|
||||
interface AddContactHook {
|
||||
void addingContact(ContactId c);
|
||||
}
|
||||
|
||||
interface ContactRemovedHook {
|
||||
void contactRemoved(ContactId c);
|
||||
interface RemoveContactHook {
|
||||
void removingContact(ContactId c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,10 +301,10 @@ public interface DatabaseComponent {
|
||||
void removeTransport(TransportId t) throws DbException;
|
||||
|
||||
/** Sets the status of the given contact. */
|
||||
void setContactStatus(ContactId c, Contact.Status s) throws DbException;
|
||||
void setContactStatus(ContactId c, StorageStatus s) throws DbException;
|
||||
|
||||
/** Sets the status of the given local pseudonym. */
|
||||
void setLocalAuthorStatus(AuthorId a, LocalAuthor.Status s)
|
||||
void setLocalAuthorStatus(AuthorId a, StorageStatus s)
|
||||
throws DbException;
|
||||
|
||||
/** Marks the given message as valid or invalid. */
|
||||
|
||||
21
briar-api/src/org/briarproject/api/db/StorageStatus.java
Normal file
21
briar-api/src/org/briarproject/api/db/StorageStatus.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package org.briarproject.api.db;
|
||||
|
||||
public enum StorageStatus {
|
||||
|
||||
ADDING(0), ACTIVE(1), REMOVING(2);
|
||||
|
||||
private final int value;
|
||||
|
||||
StorageStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static StorageStatus fromValue(int value) {
|
||||
for (StorageStatus s : values()) if (s.value == value) return s;
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import java.util.Collection;
|
||||
public interface IdentityManager {
|
||||
|
||||
/** Registers a hook to be called whenever a local pseudonym is added. */
|
||||
void registerIdentityAddedHook(IdentityAddedHook hook);
|
||||
void registerAddIdentityHook(AddIdentityHook hook);
|
||||
|
||||
/** Registers a hook to be called whenever a local pseudonym is removed. */
|
||||
void registerIdentityRemovedHook(IdentityRemovedHook hook);
|
||||
void registerRemoveIdentityHook(RemoveIdentityHook hook);
|
||||
|
||||
/** Stores a local pseudonym. */
|
||||
void addLocalAuthor(LocalAuthor a) throws DbException;
|
||||
@@ -24,11 +24,11 @@ public interface IdentityManager {
|
||||
/** Removes a local pseudonym and all associated state. */
|
||||
void removeLocalAuthor(AuthorId a) throws DbException;
|
||||
|
||||
interface IdentityAddedHook {
|
||||
void identityAdded(AuthorId a);
|
||||
interface AddIdentityHook {
|
||||
void addingIdentity(AuthorId a);
|
||||
}
|
||||
|
||||
interface IdentityRemovedHook {
|
||||
void identityRemoved(AuthorId a);
|
||||
interface RemoveIdentityHook {
|
||||
void removingIdentity(AuthorId a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,16 @@
|
||||
package org.briarproject.api.identity;
|
||||
|
||||
import org.briarproject.api.db.StorageStatus;
|
||||
|
||||
/** A pseudonym for the local user. */
|
||||
public class LocalAuthor extends Author {
|
||||
|
||||
public enum Status {
|
||||
|
||||
ADDING(0), ACTIVE(1), REMOVING(2);
|
||||
|
||||
private final int value;
|
||||
|
||||
Status(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Status fromValue(int value) {
|
||||
for (Status s : values()) if (s.value == value) return s;
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private final byte[] privateKey;
|
||||
private final long created;
|
||||
private final Status status;
|
||||
private final StorageStatus status;
|
||||
|
||||
public LocalAuthor(AuthorId id, String name, byte[] publicKey,
|
||||
byte[] privateKey, long created, Status status) {
|
||||
byte[] privateKey, long created, StorageStatus status) {
|
||||
super(id, name, publicKey);
|
||||
this.privateKey = privateKey;
|
||||
this.created = created;
|
||||
@@ -49,7 +31,7 @@ public class LocalAuthor extends Author {
|
||||
}
|
||||
|
||||
/** Returns the status of the pseudonym. */
|
||||
public Status getStatus() {
|
||||
public StorageStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user