mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Removed subject line from wire format, added content type.
This commit is contained in:
@@ -9,10 +9,10 @@ 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);
|
||||
public GroupMessageHeader(MessageId id, MessageId parent,
|
||||
String contentType, String subject, long timestamp, boolean read,
|
||||
boolean starred, GroupId groupId, Author author) {
|
||||
super(id, parent, contentType, subject, timestamp, read, starred);
|
||||
this.groupId = groupId;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,15 @@ import net.sf.briar.api.messaging.MessageId;
|
||||
public abstract class MessageHeader {
|
||||
|
||||
private final MessageId id, parent;
|
||||
private final String subject;
|
||||
private final String contentType, subject;
|
||||
private final long timestamp;
|
||||
private final boolean read, starred;
|
||||
|
||||
protected MessageHeader(MessageId id, MessageId parent, String subject,
|
||||
long timestamp, boolean read, boolean starred) {
|
||||
protected MessageHeader(MessageId id, MessageId parent, String contentType,
|
||||
String subject, long timestamp, boolean read, boolean starred) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
this.contentType = contentType;
|
||||
this.subject = subject;
|
||||
this.timestamp = timestamp;
|
||||
this.read = read;
|
||||
@@ -32,6 +33,11 @@ public abstract class MessageHeader {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/** Returns the message's content type. */
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
/** Returns the message's subject line. */
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
|
||||
@@ -8,10 +8,10 @@ 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);
|
||||
public PrivateMessageHeader(MessageId id, MessageId parent,
|
||||
String contentType, String subject, long timestamp, boolean read,
|
||||
boolean starred, ContactId contactId, boolean incoming) {
|
||||
super(id, parent, contentType, subject, timestamp, read, starred);
|
||||
this.contactId = contactId;
|
||||
this.incoming = incoming;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,14 @@ public interface Message {
|
||||
*/
|
||||
Author getAuthor();
|
||||
|
||||
/** Returns the message's subject line. */
|
||||
/** Returns the message's content type. */
|
||||
String getContentType();
|
||||
|
||||
/**
|
||||
* Returns the message's subject line, which is created from the first 50
|
||||
* bytes of the message body if the content type is text/plain, or is the
|
||||
* empty string otherwise.
|
||||
*/
|
||||
String getSubject();
|
||||
|
||||
/** Returns the timestamp created by the message's {@link Author}. */
|
||||
|
||||
@@ -7,27 +7,27 @@ import java.security.PrivateKey;
|
||||
public interface MessageFactory {
|
||||
|
||||
/** Creates a private message. */
|
||||
Message createPrivateMessage(MessageId parent, String subject, byte[] body)
|
||||
throws IOException, GeneralSecurityException;
|
||||
Message createPrivateMessage(MessageId parent, String contentType,
|
||||
byte[] body) throws IOException, GeneralSecurityException;
|
||||
|
||||
/** Creates an anonymous message to an unrestricted group. */
|
||||
Message createAnonymousGroupMessage(MessageId parent, Group group,
|
||||
String subject, byte[] body) throws IOException,
|
||||
String contentType, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
|
||||
/** Creates an anonymous message to a restricted group. */
|
||||
Message createAnonymousGroupMessage(MessageId parent, Group group,
|
||||
PrivateKey groupKey, String subject, byte[] body)
|
||||
PrivateKey groupKey, String contentType, byte[] body)
|
||||
throws IOException, GeneralSecurityException;
|
||||
|
||||
/** Creates a pseudonymous message to an unrestricted group. */
|
||||
Message createPseudonymousMessage(MessageId parent, Group group,
|
||||
Author author, PrivateKey authorKey, String subject, byte[] body)
|
||||
throws IOException, GeneralSecurityException;
|
||||
Author author, PrivateKey authorKey, String contentType,
|
||||
byte[] body) throws IOException, GeneralSecurityException;
|
||||
|
||||
/** Creates a pseudonymous message to a restricted group. */
|
||||
Message createPseudonymousMessage(MessageId parent, Group group,
|
||||
PrivateKey groupKey, Author author, PrivateKey authorKey,
|
||||
String subject, byte[] body) throws IOException,
|
||||
String contentType, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ public interface MessagingConstants {
|
||||
*/
|
||||
int MAX_BODY_LENGTH = MAX_PACKET_LENGTH - 1024;
|
||||
|
||||
/** The maximum length of a message's content type in UTF-8 bytes. */
|
||||
int MAX_CONTENT_TYPE_LENGTH = 50;
|
||||
|
||||
/** The maximum length of a message's subject line in UTF-8 bytes. */
|
||||
int MAX_SUBJECT_LENGTH = 100;
|
||||
|
||||
|
||||
@@ -6,18 +6,19 @@ public class UnverifiedMessage {
|
||||
private final MessageId parent;
|
||||
private final Group group;
|
||||
private final Author author;
|
||||
private final String subject;
|
||||
private final String contentType, subject;
|
||||
private final long timestamp;
|
||||
private final byte[] raw, authorSig, groupSig;
|
||||
private final int bodyStart, bodyLength, signedByAuthor, signedByGroup;
|
||||
|
||||
public UnverifiedMessage(MessageId parent, Group group, Author author,
|
||||
String subject, long timestamp, byte[] raw, byte[] authorSig,
|
||||
byte[] groupSig, int bodyStart, int bodyLength, int signedByAuthor,
|
||||
int signedByGroup) {
|
||||
String contentType, String subject, long timestamp, byte[] raw,
|
||||
byte[] authorSig, byte[] groupSig, int bodyStart, int bodyLength,
|
||||
int signedByAuthor, int signedByGroup) {
|
||||
this.parent = parent;
|
||||
this.group = group;
|
||||
this.author = author;
|
||||
this.contentType = contentType;
|
||||
this.subject = subject;
|
||||
this.timestamp = timestamp;
|
||||
this.raw = raw;
|
||||
@@ -53,7 +54,16 @@ public class UnverifiedMessage {
|
||||
return author;
|
||||
}
|
||||
|
||||
/** Returns the message's subject line. */
|
||||
/** Returns the message's content type. */
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message's subject line, which is created from the first 50
|
||||
* bytes of the message body if the content type is text/plain, or is the
|
||||
* empty string otherwise.
|
||||
*/
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user