mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Facades for forums. #172
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
package org.briarproject.api.event;
|
||||
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
/** An event that is broadcast when a message is added to the database. */
|
||||
public class MessageAddedEvent extends Event {
|
||||
|
||||
private final Group group;
|
||||
private final GroupId groupId;
|
||||
private final ContactId contactId;
|
||||
|
||||
public MessageAddedEvent(Group group, ContactId contactId) {
|
||||
this.group = group;
|
||||
public MessageAddedEvent(GroupId groupId, ContactId contactId) {
|
||||
this.groupId = groupId;
|
||||
this.contactId = contactId;
|
||||
}
|
||||
|
||||
/** Returns the group to which the message belongs. */
|
||||
public Group getGroup() {
|
||||
return group;
|
||||
/** Returns the ID of the group to which the message belongs. */
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
briar-api/src/org/briarproject/api/forum/Forum.java
Normal file
10
briar-api/src/org/briarproject/api/forum/Forum.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.briarproject.api.forum;
|
||||
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
public interface Forum {
|
||||
|
||||
GroupId getId();
|
||||
|
||||
String getName();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.briarproject.api.forum;
|
||||
|
||||
public interface ForumFactory {
|
||||
|
||||
/** Creates a forum with the given name and a random salt. */
|
||||
Forum createForum(String name);
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package org.briarproject.api.forum;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageHeader;
|
||||
@@ -14,56 +13,54 @@ import java.util.Collection;
|
||||
public interface ForumManager {
|
||||
|
||||
/**
|
||||
* Subscribes to a group, or returns false if the user already has the
|
||||
* maximum number of public subscriptions.
|
||||
* Subscribes to a forum, or returns false if the user already has the
|
||||
* maximum number of forum subscriptions.
|
||||
*/
|
||||
boolean addGroup(Group g) throws DbException;
|
||||
boolean addForum(Forum f) throws DbException;
|
||||
|
||||
/** Stores a local message. */
|
||||
void addLocalMessage(Message m) throws DbException;
|
||||
|
||||
/** Returns all groups to which the user could subscribe. */
|
||||
Collection<Group> getAvailableGroups() throws DbException;
|
||||
/** Returns all forums to which the user could subscribe. */
|
||||
Collection<Forum> getAvailableForums() throws DbException;
|
||||
|
||||
/** Returns the group with the given ID, if the user subscribes to it. */
|
||||
Group getGroup(GroupId g) throws DbException;
|
||||
/** Returns the forum with the given ID, if the user subscribes to it. */
|
||||
Forum getForum(GroupId g) throws DbException;
|
||||
|
||||
/** Returns all groups to which the user subscribes, excluding inboxes. */
|
||||
Collection<Group> getGroups() throws DbException;
|
||||
/** Returns all forums to which the user subscribes. */
|
||||
Collection<Forum> getForums() throws DbException;
|
||||
|
||||
/** Returns the body of the message with the given ID. */
|
||||
byte[] getMessageBody(MessageId m) throws DbException;
|
||||
|
||||
/** Returns the headers of all messages in the given group. */
|
||||
/** Returns the headers of all messages in the given forum. */
|
||||
Collection<MessageHeader> getMessageHeaders(GroupId g)
|
||||
throws DbException;
|
||||
|
||||
/** Returns all contacts who subscribe to the given group. */
|
||||
/** Returns all contacts who subscribe to the given forum. */
|
||||
Collection<Contact> getSubscribers(GroupId g) throws DbException;
|
||||
|
||||
/** Returns the IDs of all contacts to which the given group is visible. */
|
||||
/** Returns the IDs of all contacts to which the given forum is visible. */
|
||||
Collection<ContactId> getVisibility(GroupId g) throws DbException;
|
||||
|
||||
/**
|
||||
* Unsubscribes from a group. Any messages belonging to the group
|
||||
* are deleted.
|
||||
* Unsubscribes from a forum. Any messages belonging to the forum are
|
||||
* deleted.
|
||||
*/
|
||||
void removeGroup(Group g) throws DbException;
|
||||
void removeForum(Forum f) throws DbException;
|
||||
|
||||
/**
|
||||
* Marks a message as read or unread.
|
||||
*/
|
||||
/** Marks a message as read or unread. */
|
||||
void setReadFlag(MessageId m, boolean read) throws DbException;
|
||||
|
||||
/**
|
||||
* Makes a group visible to the given set of contacts and invisible to any
|
||||
* Makes a forum visible to the given set of contacts and invisible to any
|
||||
* other current or future contacts.
|
||||
*/
|
||||
void setVisibility(GroupId g, Collection<ContactId> visible)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Makes a group visible to all current and future contacts, or invisible
|
||||
* Makes a forum visible to all current and future contacts, or invisible
|
||||
* to future contacts.
|
||||
*/
|
||||
void setVisibleToAll(GroupId g, boolean all) throws DbException;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.briarproject.api.forum;
|
||||
|
||||
import org.briarproject.api.crypto.PrivateKey;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
public interface ForumPostFactory {
|
||||
|
||||
Message createAnonymousPost(MessageId parent, Forum forum,
|
||||
String contentType, long timestamp, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
|
||||
Message createPseudonymousPost(MessageId parent, Forum forum,
|
||||
Author author, PrivateKey privateKey, String contentType,
|
||||
long timestamp, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
}
|
||||
Reference in New Issue
Block a user