mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Moved classes from messaging package to sync package.
This commit is contained in:
@@ -2,7 +2,7 @@ package org.briarproject.api.android;
|
||||
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.lifecycle.Service;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
/**
|
||||
* Manages notifications for private messages and group posts. All methods must
|
||||
|
||||
@@ -9,19 +9,19 @@ import org.briarproject.api.Settings;
|
||||
import org.briarproject.api.TransportConfig;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.TransportProperties;
|
||||
import org.briarproject.api.messaging.Ack;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
import org.briarproject.api.messaging.Message;
|
||||
import org.briarproject.api.messaging.MessageId;
|
||||
import org.briarproject.api.messaging.Offer;
|
||||
import org.briarproject.api.messaging.Request;
|
||||
import org.briarproject.api.messaging.RetentionAck;
|
||||
import org.briarproject.api.messaging.RetentionUpdate;
|
||||
import org.briarproject.api.messaging.SubscriptionAck;
|
||||
import org.briarproject.api.messaging.SubscriptionUpdate;
|
||||
import org.briarproject.api.messaging.TransportAck;
|
||||
import org.briarproject.api.messaging.TransportUpdate;
|
||||
import org.briarproject.api.sync.Ack;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.api.sync.Offer;
|
||||
import org.briarproject.api.sync.Request;
|
||||
import org.briarproject.api.sync.RetentionAck;
|
||||
import org.briarproject.api.sync.RetentionUpdate;
|
||||
import org.briarproject.api.sync.SubscriptionAck;
|
||||
import org.briarproject.api.sync.SubscriptionUpdate;
|
||||
import org.briarproject.api.sync.TransportAck;
|
||||
import org.briarproject.api.sync.TransportUpdate;
|
||||
import org.briarproject.api.transport.TransportKeys;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.api.db;
|
||||
|
||||
import org.briarproject.api.Author;
|
||||
import org.briarproject.api.messaging.GroupId;
|
||||
import org.briarproject.api.messaging.MessageId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
public class MessageHeader {
|
||||
|
||||
public enum State { STORED, SENT, DELIVERED };
|
||||
public enum State { STORED, SENT, DELIVERED }
|
||||
|
||||
private final MessageId id, parent;
|
||||
private final GroupId groupId;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.api.event;
|
||||
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.sync.Group;
|
||||
|
||||
/** An event that is broadcast when a message is added to the database. */
|
||||
public class MessageAddedEvent extends Event {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.api.event;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.messaging.MessageId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/** An event that is broadcast when messages are acked by a contact. */
|
||||
public class MessagesAckedEvent extends Event {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.api.event;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.messaging.MessageId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/** An event that is broadcast when messages are sent to a contact. */
|
||||
public class MessagesSentEvent extends Event {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.api.event;
|
||||
|
||||
import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.sync.Group;
|
||||
|
||||
/** An event that is broadcast when the user subscribes to a group. */
|
||||
public class SubscriptionAddedEvent extends Event {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.briarproject.api.event;
|
||||
|
||||
import org.briarproject.api.messaging.Group;
|
||||
import org.briarproject.api.sync.Group;
|
||||
|
||||
/** An event that is broadcast when the user unsubscribes from a group. */
|
||||
public class SubscriptionRemovedEvent extends Event {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package org.briarproject.api.messaging;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface PacketWriter {
|
||||
|
||||
int getMaxMessagesForAck(long capacity);
|
||||
|
||||
int getMaxMessagesForRequest(long capacity);
|
||||
|
||||
int getMaxMessagesForOffer(long capacity);
|
||||
|
||||
void writeAck(Ack a) throws IOException;
|
||||
|
||||
void writeMessage(byte[] raw) throws IOException;
|
||||
|
||||
void writeOffer(Offer o) throws IOException;
|
||||
|
||||
void writeRequest(Request r) throws IOException;
|
||||
|
||||
void writeRetentionAck(RetentionAck a) throws IOException;
|
||||
|
||||
void writeRetentionUpdate(RetentionUpdate u) throws IOException;
|
||||
|
||||
void writeSubscriptionAck(SubscriptionAck a) throws IOException;
|
||||
|
||||
void writeSubscriptionUpdate(SubscriptionUpdate u) throws IOException;
|
||||
|
||||
void writeTransportAck(TransportAck a) throws IOException;
|
||||
|
||||
void writeTransportUpdate(TransportUpdate u) throws IOException;
|
||||
|
||||
void flush() throws IOException;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.briarproject.api.messaging;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/** A packet requesting one or more {@link Message}s from the recipient. */
|
||||
public class Request {
|
||||
|
||||
private final Collection<MessageId> requested;
|
||||
|
||||
public Request(Collection<MessageId> requested) {
|
||||
this.requested = requested;
|
||||
}
|
||||
|
||||
/** Returns the identifiers of the requested messages. */
|
||||
public Collection<MessageId> getMessageIds() {
|
||||
return requested;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
|
||||
import static org.briarproject.api.messaging.MessagingConstants.GROUP_SALT_LENGTH;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_GROUP_NAME_LENGTH;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@@ -19,9 +16,9 @@ public class Group {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (length == 0 || length > MAX_GROUP_NAME_LENGTH)
|
||||
if (length == 0 || length > MessagingConstants.MAX_GROUP_NAME_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
if (salt.length != GROUP_SALT_LENGTH)
|
||||
if (salt.length != MessagingConstants.GROUP_SALT_LENGTH)
|
||||
throw new IllegalArgumentException();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
public interface GroupFactory {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.api.messaging;
|
||||
|
||||
import java.util.Arrays;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.UniqueId;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Type-safe wrapper for a byte array that uniquely identifies a {@link Group}.
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.Author;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package org.briarproject.api.messaging;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.Author;
|
||||
import org.briarproject.api.crypto.PrivateKey;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
public interface MessageFactory {
|
||||
|
||||
Message createAnonymousMessage(MessageId parent, Group group,
|
||||
Message createAnonymousMessage(MessageId parent, org.briarproject.api.sync.Group group,
|
||||
String contentType, long timestamp, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
|
||||
Message createPseudonymousMessage(MessageId parent, Group group,
|
||||
Message createPseudonymousMessage(MessageId parent, org.briarproject.api.sync.Group group,
|
||||
Author author, PrivateKey privateKey, String contentType,
|
||||
long timestamp, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.api.messaging;
|
||||
|
||||
import java.util.Arrays;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.UniqueId;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Type-safe wrapper for a byte array that uniquely identifies a
|
||||
* {@link Message}.
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
|
||||
public interface MessagingConstants {
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.briarproject.api.messaging;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.ContactId;
|
||||
import org.briarproject.api.TransportId;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public interface MessagingSessionFactory {
|
||||
|
||||
MessagingSession createIncomingSession(ContactId c, TransportId t,
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/** A packet offering the recipient one or more {@link Messages}. */
|
||||
/** A packet offering the recipient one or more {@link Message}s. */
|
||||
public class Offer {
|
||||
|
||||
private final Collection<MessageId> offered;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -19,20 +19,20 @@ public interface PacketReader {
|
||||
Request readRequest() throws IOException;
|
||||
|
||||
boolean hasRetentionAck() throws IOException;
|
||||
RetentionAck readRetentionAck() throws IOException;
|
||||
org.briarproject.api.sync.RetentionAck readRetentionAck() throws IOException;
|
||||
|
||||
boolean hasRetentionUpdate() throws IOException;
|
||||
RetentionUpdate readRetentionUpdate() throws IOException;
|
||||
org.briarproject.api.sync.RetentionUpdate readRetentionUpdate() throws IOException;
|
||||
|
||||
boolean hasSubscriptionAck() throws IOException;
|
||||
SubscriptionAck readSubscriptionAck() throws IOException;
|
||||
org.briarproject.api.sync.SubscriptionAck readSubscriptionAck() throws IOException;
|
||||
|
||||
boolean hasSubscriptionUpdate() throws IOException;
|
||||
SubscriptionUpdate readSubscriptionUpdate() throws IOException;
|
||||
org.briarproject.api.sync.SubscriptionUpdate readSubscriptionUpdate() throws IOException;
|
||||
|
||||
boolean hasTransportAck() throws IOException;
|
||||
TransportAck readTransportAck() throws IOException;
|
||||
|
||||
boolean hasTransportUpdate() throws IOException;
|
||||
TransportUpdate readTransportUpdate() throws IOException;
|
||||
org.briarproject.api.sync.TransportUpdate readTransportUpdate() throws IOException;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
/** Packet types for the messaging protocol. */
|
||||
public interface PacketTypes {
|
||||
34
briar-api/src/org/briarproject/api/sync/PacketWriter.java
Normal file
34
briar-api/src/org/briarproject/api/sync/PacketWriter.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface PacketWriter {
|
||||
|
||||
int getMaxMessagesForAck(long capacity);
|
||||
|
||||
int getMaxMessagesForRequest(long capacity);
|
||||
|
||||
int getMaxMessagesForOffer(long capacity);
|
||||
|
||||
void writeAck(Ack a) throws IOException;
|
||||
|
||||
void writeMessage(byte[] raw) throws IOException;
|
||||
|
||||
void writeOffer(org.briarproject.api.sync.Offer o) throws IOException;
|
||||
|
||||
void writeRequest(Request r) throws IOException;
|
||||
|
||||
void writeRetentionAck(org.briarproject.api.sync.RetentionAck a) throws IOException;
|
||||
|
||||
void writeRetentionUpdate(org.briarproject.api.sync.RetentionUpdate u) throws IOException;
|
||||
|
||||
void writeSubscriptionAck(org.briarproject.api.sync.SubscriptionAck a) throws IOException;
|
||||
|
||||
void writeSubscriptionUpdate(org.briarproject.api.sync.SubscriptionUpdate u) throws IOException;
|
||||
|
||||
void writeTransportAck(org.briarproject.api.sync.TransportAck a) throws IOException;
|
||||
|
||||
void writeTransportUpdate(org.briarproject.api.sync.TransportUpdate u) throws IOException;
|
||||
|
||||
void flush() throws IOException;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
18
briar-api/src/org/briarproject/api/sync/Request.java
Normal file
18
briar-api/src/org/briarproject/api/sync/Request.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/** A packet requesting one or more {@link Message}s from the recipient. */
|
||||
public class Request {
|
||||
|
||||
private final Collection<org.briarproject.api.sync.MessageId> requested;
|
||||
|
||||
public Request(Collection<org.briarproject.api.sync.MessageId> requested) {
|
||||
this.requested = requested;
|
||||
}
|
||||
|
||||
/** Returns the identifiers of the requested messages. */
|
||||
public Collection<org.briarproject.api.sync.MessageId> getMessageIds() {
|
||||
return requested;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
/** A packet acknowledging a (@link RetentionUpdate} */
|
||||
public class RetentionAck {
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
/**
|
||||
* A packet updating the recipient's view of the retention time of the sender's
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
/** A packet acknowledging a {@link SubscriptionUpdate}. */
|
||||
public class SubscriptionAck {
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.TransportId;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.TransportProperties;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.messaging;
|
||||
package org.briarproject.api.sync;
|
||||
|
||||
import org.briarproject.api.Author;
|
||||
|
||||
@@ -6,14 +6,14 @@ import org.briarproject.api.Author;
|
||||
public class UnverifiedMessage {
|
||||
|
||||
private final MessageId parent;
|
||||
private final Group group;
|
||||
private final org.briarproject.api.sync.Group group;
|
||||
private final Author author;
|
||||
private final String contentType;
|
||||
private final long timestamp;
|
||||
private final byte[] raw, signature;
|
||||
private final int bodyStart, bodyLength, signedLength;
|
||||
|
||||
public UnverifiedMessage(MessageId parent, Group group, Author author,
|
||||
public UnverifiedMessage(MessageId parent, org.briarproject.api.sync.Group group, Author author,
|
||||
String contentType, long timestamp, byte[] raw, byte[] signature,
|
||||
int bodyStart, int bodyLength, int signedLength) {
|
||||
this.parent = parent;
|
||||
@@ -37,10 +37,10 @@ public class UnverifiedMessage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Group} to which the message belongs, or null if this
|
||||
* Returns the {@link org.briarproject.api.sync.Group} to which the message belongs, or null if this
|
||||
* is a private message.
|
||||
*/
|
||||
public Group getGroup() {
|
||||
public org.briarproject.api.sync.Group getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user