mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Added columns to the DB to support retrieval of message headers.
This commit is contained in:
@@ -166,11 +166,13 @@ public interface DatabaseComponent {
|
||||
/** Returns the body of the message with the given ID. */
|
||||
byte[] getMessageBody(MessageId m) throws DbException;
|
||||
|
||||
/** Returns the header of the message with the given ID. */
|
||||
MessageHeader getMessageHeader(MessageId m) throws DbException;
|
||||
|
||||
/** Returns the headers of all messages in the given group. */
|
||||
Collection<MessageHeader> getMessageHeaders(GroupId g) throws DbException;
|
||||
Collection<GroupMessageHeader> getMessageHeaders(GroupId g)
|
||||
throws DbException;
|
||||
|
||||
/** Returns the headers of all private messages. */
|
||||
Collection<PrivateMessageHeader> getPrivateMessageHeaders()
|
||||
throws DbException;
|
||||
|
||||
/** Returns the user's rating for the given author. */
|
||||
Rating getRating(AuthorId a) throws DbException;
|
||||
|
||||
31
briar-api/src/net/sf/briar/api/db/GroupMessageHeader.java
Normal file
31
briar-api/src/net/sf/briar/api/db/GroupMessageHeader.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package net.sf.briar.api.db;
|
||||
|
||||
import net.sf.briar.api.messaging.Author;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
|
||||
public class GroupMessageHeader extends MessageHeader {
|
||||
|
||||
private final GroupId groupId;
|
||||
private final Author author;
|
||||
|
||||
public GroupMessageHeader(MessageId id, MessageId parent, String subject,
|
||||
long timestamp, boolean read, boolean starred, GroupId groupId,
|
||||
Author author) {
|
||||
super(id, parent, subject, timestamp, read, starred);
|
||||
this.groupId = groupId;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/** Returns the ID of the group to which the message belongs. */
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message's author, or null if this is an anonymous message.
|
||||
*/
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,18 @@
|
||||
package net.sf.briar.api.db;
|
||||
|
||||
import net.sf.briar.api.messaging.AuthorId;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
|
||||
public class MessageHeader {
|
||||
public abstract class MessageHeader {
|
||||
|
||||
private final MessageId id, parent;
|
||||
private final GroupId group;
|
||||
private final AuthorId author;
|
||||
private final String subject;
|
||||
private final long timestamp;
|
||||
private final boolean read, starred;
|
||||
|
||||
public MessageHeader(MessageId id, MessageId parent, GroupId group,
|
||||
AuthorId author, String subject, long timestamp, boolean read,
|
||||
boolean starred) {
|
||||
protected MessageHeader(MessageId id, MessageId parent, String subject,
|
||||
long timestamp, boolean read, boolean starred) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
this.group = group;
|
||||
this.author = author;
|
||||
this.subject = subject;
|
||||
this.timestamp = timestamp;
|
||||
this.read = read;
|
||||
@@ -39,22 +32,6 @@ public class MessageHeader {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the group to which the message belongs, or null if
|
||||
* this is a private message.
|
||||
*/
|
||||
public GroupId getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the message's author, or null if this is an
|
||||
* anonymous message.
|
||||
*/
|
||||
public AuthorId getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
/** Returns the message's subject line. */
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
|
||||
31
briar-api/src/net/sf/briar/api/db/PrivateMessageHeader.java
Normal file
31
briar-api/src/net/sf/briar/api/db/PrivateMessageHeader.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package net.sf.briar.api.db;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
|
||||
public class PrivateMessageHeader extends MessageHeader {
|
||||
|
||||
private final ContactId contactId;
|
||||
private final boolean incoming;
|
||||
|
||||
public PrivateMessageHeader(MessageId id, MessageId parent, String subject,
|
||||
long timestamp, boolean read, boolean starred, ContactId contactId,
|
||||
boolean incoming) {
|
||||
super(id, parent, subject, timestamp, read, starred);
|
||||
this.contactId = contactId;
|
||||
this.incoming = incoming;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the contact who is the sender (if incoming) or
|
||||
* recipient (if outgoing) of this message.
|
||||
*/
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
/** Returns true if this is an incoming message. */
|
||||
public boolean isIncoming() {
|
||||
return incoming;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
/**
|
||||
* An event that is broadcast when the retention time of the local database
|
||||
* changes.
|
||||
*/
|
||||
public class LocalRetentionTimeUpdatedEvent extends DatabaseEvent {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
/**
|
||||
* An event that is broadcast when one or messages expire from the database,
|
||||
* potentially changing the database's retention time.
|
||||
*/
|
||||
public class MessageExpiredEvent extends DatabaseEvent {
|
||||
|
||||
}
|
||||
@@ -12,16 +12,16 @@ public interface Message {
|
||||
MessageId getParent();
|
||||
|
||||
/**
|
||||
* Returns the identifier of the {@link Group} to which the message
|
||||
* belongs, or null if this is a private message.
|
||||
* Returns the {@link Group} to which the message belongs, or null if this
|
||||
* is a private message.
|
||||
*/
|
||||
GroupId getGroup();
|
||||
Group getGroup();
|
||||
|
||||
/**
|
||||
* Returns the identifier of the message's {@link Author}, or null if this
|
||||
* is an anonymous message.
|
||||
* Returns the message's {@link Author}, or null if this is an anonymous
|
||||
* message.
|
||||
*/
|
||||
AuthorId getAuthor();
|
||||
Author getAuthor();
|
||||
|
||||
/** Returns the message's subject line. */
|
||||
String getSubject();
|
||||
|
||||
Reference in New Issue
Block a user