mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Use namespaced strings for client IDs
This commit is contained in:
@@ -13,8 +13,8 @@ import java.util.Collection;
|
||||
|
||||
public interface BlogManager {
|
||||
|
||||
/** Returns the unique ID of the blog client. */
|
||||
ClientId getClientId();
|
||||
/** Unique ID of the blog client. */
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.blogs");
|
||||
|
||||
/** Returns true if a blog can be removed. */
|
||||
boolean canBeRemoved(GroupId g) throws DbException;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.briarproject.api.blogs;
|
||||
|
||||
import org.briarproject.api.sharing.SharingManager;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
|
||||
public interface BlogSharingManager extends SharingManager<Blog> {
|
||||
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.blogs.sharing");
|
||||
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import java.util.List;
|
||||
|
||||
public interface FeedManager {
|
||||
|
||||
/** Returns the unique ID of the client. */
|
||||
ClientId getClientId();
|
||||
/** The unique ID of the RSS feed client. */
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.feed");
|
||||
|
||||
/** Adds a RSS feed. */
|
||||
void addFeed(String url, GroupId g) throws DbException, IOException;
|
||||
|
||||
@@ -14,8 +14,8 @@ import java.util.Collection;
|
||||
|
||||
public interface ForumManager extends MessageTracker {
|
||||
|
||||
/** Returns the unique ID of the forum client. */
|
||||
ClientId getClientId();
|
||||
/** The unique ID of the forum client. */
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.forum");
|
||||
|
||||
/** Subscribes to a forum. */
|
||||
Forum addForum(String name) throws DbException;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.briarproject.api.forum;
|
||||
|
||||
import org.briarproject.api.sharing.SharingManager;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
|
||||
public interface ForumSharingManager extends SharingManager<Forum> {
|
||||
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.forum.sharing");
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import java.util.Collection;
|
||||
|
||||
public interface IntroductionManager extends MessageTracker {
|
||||
|
||||
/** Returns the unique ID of the introduction client. */
|
||||
ClientId getClientId();
|
||||
/** The unique ID of the introduction client. */
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.introduction");
|
||||
|
||||
/**
|
||||
* sends two initial introduction messages
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.util.Collection;
|
||||
|
||||
public interface MessagingManager extends MessageTracker {
|
||||
|
||||
/** Returns the unique ID of the messaging client. */
|
||||
ClientId getClientId();
|
||||
/** The unique ID of the messaging client. */
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.messaging");
|
||||
|
||||
/** Stores a local private message. */
|
||||
void addLocalMessage(PrivateMessage m) throws DbException;
|
||||
|
||||
@@ -14,8 +14,8 @@ import java.util.Collection;
|
||||
@NotNullByDefault
|
||||
public interface PrivateGroupManager extends MessageTracker {
|
||||
|
||||
/** Returns the unique ID of the private group client. */
|
||||
ClientId getClientId();
|
||||
/** The unique ID of the private group client. */
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.privategroup");
|
||||
|
||||
/**
|
||||
* Adds a new private group and joins it.
|
||||
|
||||
@@ -14,8 +14,9 @@ import java.util.Collection;
|
||||
|
||||
public interface GroupInvitationManager extends MessageTracker {
|
||||
|
||||
/** Returns the unique ID of the private group invitation client. */
|
||||
ClientId getClientId();
|
||||
/** The unique ID of the private group invitation client. */
|
||||
ClientId CLIENT_ID =
|
||||
new ClientId("org.briarproject.briar.privategroup.invitation");
|
||||
|
||||
/**
|
||||
* Sends an invitation to share the given forum with the given contact
|
||||
|
||||
@@ -4,11 +4,15 @@ import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface TransportPropertyManager {
|
||||
|
||||
/** The unique ID of the transport property client. */
|
||||
ClientId CLIENT_ID = new ClientId("org.briarproject.briar.properties");
|
||||
|
||||
/**
|
||||
* Stores the given properties received while adding a contact - they will
|
||||
* be superseded by any properties synced from the contact.
|
||||
|
||||
@@ -5,18 +5,12 @@ import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface SharingManager<S extends Shareable> extends MessageTracker {
|
||||
|
||||
/**
|
||||
* Returns the unique ID of the group sharing client.
|
||||
*/
|
||||
ClientId getClientId();
|
||||
|
||||
/**
|
||||
* Sends an invitation to share the given group with the given contact
|
||||
* and sends an optional message along with it.
|
||||
|
||||
@@ -1,18 +1,39 @@
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.UniqueId;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* Type-safe wrapper for a byte array that uniquely identifies a sync client.
|
||||
* Wrapper for a name-spaced string that uniquely identifies a sync client.
|
||||
*/
|
||||
public class ClientId extends UniqueId {
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class ClientId implements Comparable<ClientId> {
|
||||
|
||||
public ClientId(byte[] id) {
|
||||
super(id);
|
||||
private final String id;
|
||||
|
||||
public ClientId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClientId clientId) {
|
||||
return id.compareTo(clientId.getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ClientId && super.equals(o);
|
||||
return o instanceof ClientId && id.equals(((ClientId) o).id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user