mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Facades for private messaging. #173
This commit is contained in:
@@ -142,9 +142,9 @@ EventListener {
|
|||||||
try {
|
try {
|
||||||
ContactId id = c.getId();
|
ContactId id = c.getId();
|
||||||
GroupId inbox =
|
GroupId inbox =
|
||||||
messagingManager.getInboxGroupId(id);
|
messagingManager.getConversationId(id);
|
||||||
Collection<MessageHeader> headers =
|
Collection<MessageHeader> headers =
|
||||||
messagingManager.getInboxMessageHeaders(id);
|
messagingManager.getMessageHeaders(id);
|
||||||
displayContact(c, inbox, headers);
|
displayContact(c, inbox, headers);
|
||||||
} catch (NoSuchContactException e) {
|
} catch (NoSuchContactException e) {
|
||||||
// Continue
|
// Continue
|
||||||
@@ -294,7 +294,7 @@ EventListener {
|
|||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
Collection<MessageHeader> headers =
|
Collection<MessageHeader> headers =
|
||||||
messagingManager.getInboxMessageHeaders(c);
|
messagingManager.getMessageHeaders(c);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Partial load took " + duration + " ms");
|
LOG.info("Partial load took " + duration + " ms");
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ import org.briarproject.api.event.MessagesAckedEvent;
|
|||||||
import org.briarproject.api.event.MessagesSentEvent;
|
import org.briarproject.api.event.MessagesSentEvent;
|
||||||
import org.briarproject.api.identity.AuthorId;
|
import org.briarproject.api.identity.AuthorId;
|
||||||
import org.briarproject.api.messaging.MessagingManager;
|
import org.briarproject.api.messaging.MessagingManager;
|
||||||
|
import org.briarproject.api.messaging.PrivateConversation;
|
||||||
|
import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||||
import org.briarproject.api.plugins.ConnectionRegistry;
|
import org.briarproject.api.plugins.ConnectionRegistry;
|
||||||
import org.briarproject.api.sync.Group;
|
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.Message;
|
import org.briarproject.api.sync.Message;
|
||||||
import org.briarproject.api.sync.MessageFactory;
|
|
||||||
import org.briarproject.api.sync.MessageHeader;
|
import org.briarproject.api.sync.MessageHeader;
|
||||||
import org.briarproject.api.sync.MessageHeader.State;
|
import org.briarproject.api.sync.MessageHeader.State;
|
||||||
import org.briarproject.api.sync.MessageId;
|
import org.briarproject.api.sync.MessageId;
|
||||||
@@ -93,11 +93,11 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
@Inject private volatile ContactManager contactManager;
|
@Inject private volatile ContactManager contactManager;
|
||||||
@Inject private volatile MessagingManager messagingManager;
|
@Inject private volatile MessagingManager messagingManager;
|
||||||
@Inject private volatile EventBus eventBus;
|
@Inject private volatile EventBus eventBus;
|
||||||
@Inject private volatile MessageFactory messageFactory;
|
@Inject private volatile PrivateMessageFactory privateMessageFactory;
|
||||||
private volatile ContactId contactId = null;
|
private volatile ContactId contactId = null;
|
||||||
private volatile String contactName = null;
|
private volatile String contactName = null;
|
||||||
private volatile GroupId groupId = null;
|
private volatile GroupId groupId = null;
|
||||||
private volatile Group group = null;
|
private volatile PrivateConversation conversation = null;
|
||||||
private volatile AuthorId localAuthorId = null;
|
private volatile AuthorId localAuthorId = null;
|
||||||
private volatile boolean connected;
|
private volatile boolean connected;
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
|
|
||||||
content = (EditText) findViewById(R.id.contentView);
|
content = (EditText) findViewById(R.id.contentView);
|
||||||
sendButton = (ImageButton) findViewById(R.id.sendButton);
|
sendButton = (ImageButton) findViewById(R.id.sendButton);
|
||||||
sendButton.setEnabled(false); // Enabled after loading the group
|
sendButton.setEnabled(false); // Enabled after loading the conversation
|
||||||
sendButton.setOnClickListener(this);
|
sendButton.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,12 +167,12 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
Contact contact = contactManager.getContact(contactId);
|
Contact contact = contactManager.getContact(contactId);
|
||||||
contactName = contact.getAuthor().getName();
|
contactName = contact.getAuthor().getName();
|
||||||
localAuthorId = contact.getLocalAuthorId();
|
localAuthorId = contact.getLocalAuthorId();
|
||||||
groupId = messagingManager.getInboxGroupId(contactId);
|
groupId = messagingManager.getConversationId(contactId);
|
||||||
group = messagingManager.getGroup(groupId);
|
conversation = messagingManager.getConversation(groupId);
|
||||||
connected = connectionRegistry.isConnected(contactId);
|
connected = connectionRegistry.isConnected(contactId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO)) {
|
if (LOG.isLoggable(INFO)) {
|
||||||
LOG.info("Loading contact and group took "
|
LOG.info("Loading contact and conversation took "
|
||||||
+ duration + " ms");
|
+ duration + " ms");
|
||||||
}
|
}
|
||||||
displayContactDetails();
|
displayContactDetails();
|
||||||
@@ -210,7 +210,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
Collection<MessageHeader> headers =
|
Collection<MessageHeader> headers =
|
||||||
messagingManager.getInboxMessageHeaders(contactId);
|
messagingManager.getMessageHeaders(contactId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Loading headers took " + duration + " ms");
|
LOG.info("Loading headers took " + duration + " ms");
|
||||||
@@ -424,8 +424,8 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
cryptoExecutor.execute(new Runnable() {
|
cryptoExecutor.execute(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Message m = messageFactory.createAnonymousMessage(null,
|
Message m = privateMessageFactory.createPrivateMessage(null,
|
||||||
group, "text/plain", timestamp, body);
|
conversation, "text/plain", timestamp, body);
|
||||||
storeMessage(m);
|
storeMessage(m);
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import org.briarproject.api.identity.AuthorId;
|
|||||||
import org.briarproject.api.identity.IdentityManager;
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
import org.briarproject.api.identity.LocalAuthor;
|
import org.briarproject.api.identity.LocalAuthor;
|
||||||
import org.briarproject.api.messaging.MessagingManager;
|
import org.briarproject.api.messaging.MessagingManager;
|
||||||
import org.briarproject.api.sync.Group;
|
import org.briarproject.api.messaging.PrivateConversation;
|
||||||
|
import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.Message;
|
import org.briarproject.api.sync.Message;
|
||||||
import org.briarproject.api.sync.MessageFactory;
|
|
||||||
import org.briarproject.api.sync.MessageId;
|
import org.briarproject.api.sync.MessageId;
|
||||||
import org.briarproject.util.StringUtils;
|
import org.briarproject.util.StringUtils;
|
||||||
|
|
||||||
@@ -65,21 +65,20 @@ implements OnClickListener {
|
|||||||
// Fields that are accessed from background threads must be volatile
|
// Fields that are accessed from background threads must be volatile
|
||||||
@Inject private volatile IdentityManager identityManager;
|
@Inject private volatile IdentityManager identityManager;
|
||||||
@Inject private volatile MessagingManager messagingManager;
|
@Inject private volatile MessagingManager messagingManager;
|
||||||
@Inject private volatile MessageFactory messageFactory;
|
@Inject private volatile PrivateMessageFactory privateMessageFactory;
|
||||||
private volatile String contactName = null;
|
|
||||||
private volatile GroupId groupId = null;
|
private volatile GroupId groupId = null;
|
||||||
private volatile AuthorId localAuthorId = null;
|
private volatile AuthorId localAuthorId = null;
|
||||||
private volatile MessageId parentId = null;
|
private volatile MessageId parentId = null;
|
||||||
private volatile long minTimestamp = -1;
|
private volatile long minTimestamp = -1;
|
||||||
private volatile LocalAuthor localAuthor = null;
|
private volatile LocalAuthor localAuthor = null;
|
||||||
private volatile Group group = null;
|
private volatile PrivateConversation conversation = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
contactName = i.getStringExtra("briar.CONTACT_NAME");
|
String contactName = i.getStringExtra("briar.CONTACT_NAME");
|
||||||
if (contactName == null) throw new IllegalStateException();
|
if (contactName == null) throw new IllegalStateException();
|
||||||
setTitle(contactName);
|
setTitle(contactName);
|
||||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||||
@@ -118,7 +117,7 @@ implements OnClickListener {
|
|||||||
sendButton.setId(2);
|
sendButton.setId(2);
|
||||||
sendButton.setBackgroundResource(0);
|
sendButton.setBackgroundResource(0);
|
||||||
sendButton.setImageResource(R.drawable.social_send_now);
|
sendButton.setImageResource(R.drawable.social_send_now);
|
||||||
sendButton.setEnabled(false); // Enabled after loading the group
|
sendButton.setEnabled(false); // Enabled after loading the conversation
|
||||||
sendButton.setOnClickListener(this);
|
sendButton.setOnClickListener(this);
|
||||||
RelativeLayout.LayoutParams right = CommonLayoutParams.relative();
|
RelativeLayout.LayoutParams right = CommonLayoutParams.relative();
|
||||||
right.addRule(ALIGN_PARENT_RIGHT);
|
right.addRule(ALIGN_PARENT_RIGHT);
|
||||||
@@ -140,16 +139,17 @@ implements OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (localAuthor == null || group == null) loadAuthorAndGroup();
|
if (localAuthor == null || conversation == null)
|
||||||
|
loadAuthorAndConversation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadAuthorAndGroup() {
|
private void loadAuthorAndConversation() {
|
||||||
runOnDbThread(new Runnable() {
|
runOnDbThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
localAuthor = identityManager.getLocalAuthor(localAuthorId);
|
localAuthor = identityManager.getLocalAuthor(localAuthorId);
|
||||||
group = messagingManager.getGroup(groupId);
|
conversation = messagingManager.getConversation(groupId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Load took " + duration + " ms");
|
LOG.info("Load took " + duration + " ms");
|
||||||
@@ -192,8 +192,9 @@ implements OnClickListener {
|
|||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
timestamp = Math.max(timestamp, minTimestamp);
|
timestamp = Math.max(timestamp, minTimestamp);
|
||||||
try {
|
try {
|
||||||
Message m = messageFactory.createAnonymousMessage(parentId,
|
Message m = privateMessageFactory.createPrivateMessage(
|
||||||
group, "text/plain", timestamp, body);
|
parentId, conversation, "text/plain", timestamp,
|
||||||
|
body);
|
||||||
storeMessage(m);
|
storeMessage(m);
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.briarproject.api.messaging;
|
|||||||
|
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.sync.Group;
|
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.Message;
|
import org.briarproject.api.sync.Message;
|
||||||
import org.briarproject.api.sync.MessageHeader;
|
import org.briarproject.api.sync.MessageHeader;
|
||||||
@@ -12,43 +11,35 @@ import java.util.Collection;
|
|||||||
|
|
||||||
public interface MessagingManager {
|
public interface MessagingManager {
|
||||||
|
|
||||||
/**
|
/** Stores a local private message. */
|
||||||
* Subscribes to a group, or returns false if the user already has the
|
|
||||||
* maximum number of public subscriptions.
|
|
||||||
*/
|
|
||||||
boolean addGroup(Group g) throws DbException;
|
|
||||||
|
|
||||||
/** Stores a local message. */
|
|
||||||
void addLocalMessage(Message m) throws DbException;
|
void addLocalMessage(Message m) throws DbException;
|
||||||
|
|
||||||
/** Returns the group with the given ID, if the user subscribes to it. */
|
/** Returns the private conversation with the given ID. */
|
||||||
Group getGroup(GroupId g) throws DbException;
|
PrivateConversation getConversation(GroupId g) throws DbException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the inbox group for the given contact, or null if no
|
* Returns the ID of the private conversation with the given contact, or
|
||||||
* inbox group has been set.
|
* null if no private conversation ID has been set.
|
||||||
*/
|
*/
|
||||||
GroupId getInboxGroupId(ContactId c) throws DbException;
|
GroupId getConversationId(ContactId c) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the headers of all messages in the inbox group for the given
|
* Returns the headers of all messages in the private conversation with the
|
||||||
* contact, or null if no inbox group has been set.
|
* given contact, or null if no private conversation ID has been set.
|
||||||
*/
|
*/
|
||||||
Collection<MessageHeader> getInboxMessageHeaders(ContactId c)
|
Collection<MessageHeader> getMessageHeaders(ContactId c)
|
||||||
throws DbException;
|
throws DbException;
|
||||||
|
|
||||||
/** Returns the body of the message with the given ID. */
|
/** Returns the body of the private message with the given ID. */
|
||||||
byte[] getMessageBody(MessageId m) throws DbException;
|
byte[] getMessageBody(MessageId m) throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a group visible to the given contact, adds it to the contact's
|
* Makes a private conversation visible to the given contact, adds it to
|
||||||
* subscriptions, and sets it as the inbox group for the contact.
|
* the contact's subscriptions, and sets it as the private conversation for
|
||||||
|
* the contact.
|
||||||
*/
|
*/
|
||||||
void setInboxGroup(ContactId c, Group g) throws DbException;
|
void setConversation(ContactId c, PrivateConversation p) throws DbException;
|
||||||
|
|
||||||
/**
|
/** Marks a private message as read or unread. */
|
||||||
* Marks a message as read or unread.
|
|
||||||
*/
|
|
||||||
void setReadFlag(MessageId m, boolean read) throws DbException;
|
void setReadFlag(MessageId m, boolean read) throws DbException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.briarproject.api.messaging;
|
||||||
|
|
||||||
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
|
public interface PrivateConversation {
|
||||||
|
|
||||||
|
GroupId getId();
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.briarproject.api.messaging;
|
||||||
|
|
||||||
|
import org.briarproject.api.sync.Message;
|
||||||
|
import org.briarproject.api.sync.MessageId;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.GeneralSecurityException;
|
||||||
|
|
||||||
|
public interface PrivateMessageFactory {
|
||||||
|
|
||||||
|
Message createPrivateMessage(MessageId parent,
|
||||||
|
PrivateConversation conversation, String contentType,
|
||||||
|
long timestamp, byte[] body) throws IOException,
|
||||||
|
GeneralSecurityException;
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import org.briarproject.api.contact.ContactId;
|
|||||||
import org.briarproject.api.db.DatabaseComponent;
|
import org.briarproject.api.db.DatabaseComponent;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.messaging.MessagingManager;
|
import org.briarproject.api.messaging.MessagingManager;
|
||||||
import org.briarproject.api.sync.Group;
|
import org.briarproject.api.messaging.PrivateConversation;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.Message;
|
import org.briarproject.api.sync.Message;
|
||||||
import org.briarproject.api.sync.MessageHeader;
|
import org.briarproject.api.sync.MessageHeader;
|
||||||
@@ -14,6 +14,7 @@ import org.briarproject.api.sync.MessageId;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
// Temporary facade during sync protocol refactoring
|
||||||
class MessagingManagerImpl implements MessagingManager {
|
class MessagingManagerImpl implements MessagingManager {
|
||||||
|
|
||||||
private final DatabaseComponent db;
|
private final DatabaseComponent db;
|
||||||
@@ -23,28 +24,23 @@ class MessagingManagerImpl implements MessagingManager {
|
|||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addGroup(Group g) throws DbException {
|
|
||||||
return db.addGroup(g);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLocalMessage(Message m) throws DbException {
|
public void addLocalMessage(Message m) throws DbException {
|
||||||
db.addLocalMessage(m);
|
db.addLocalMessage(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group getGroup(GroupId g) throws DbException {
|
public PrivateConversation getConversation(GroupId g) throws DbException {
|
||||||
return db.getGroup(g);
|
return new PrivateConversationImpl(db.getGroup(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupId getInboxGroupId(ContactId c) throws DbException {
|
public GroupId getConversationId(ContactId c) throws DbException {
|
||||||
return db.getInboxGroupId(c);
|
return db.getInboxGroupId(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<MessageHeader> getInboxMessageHeaders(ContactId c)
|
public Collection<MessageHeader> getMessageHeaders(ContactId c)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
return db.getInboxMessageHeaders(c);
|
return db.getInboxMessageHeaders(c);
|
||||||
}
|
}
|
||||||
@@ -55,8 +51,9 @@ class MessagingManagerImpl implements MessagingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInboxGroup(ContactId c, Group g) throws DbException {
|
public void setConversation(ContactId c, PrivateConversation p)
|
||||||
db.setInboxGroup(c, g);
|
throws DbException {
|
||||||
|
db.setInboxGroup(c, ((PrivateConversationImpl) p).getGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ package org.briarproject.messaging;
|
|||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
import org.briarproject.api.messaging.MessagingManager;
|
import org.briarproject.api.messaging.MessagingManager;
|
||||||
|
import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||||
|
|
||||||
public class MessagingModule extends AbstractModule {
|
public class MessagingModule extends AbstractModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(MessagingManager.class).to(MessagingManagerImpl.class);
|
bind(MessagingManager.class).to(MessagingManagerImpl.class);
|
||||||
|
bind(PrivateMessageFactory.class).to(PrivateMessageFactoryImpl.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.briarproject.messaging;
|
||||||
|
|
||||||
|
import org.briarproject.api.messaging.PrivateConversation;
|
||||||
|
import org.briarproject.api.sync.Group;
|
||||||
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
|
// Temporary facade during sync protocol refactoring
|
||||||
|
class PrivateConversationImpl implements PrivateConversation {
|
||||||
|
|
||||||
|
private final Group group;
|
||||||
|
|
||||||
|
PrivateConversationImpl(Group group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GroupId getId() {
|
||||||
|
return group.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
Group getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return group.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o instanceof PrivateConversationImpl
|
||||||
|
&& group.equals(((PrivateConversationImpl) o).group);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.briarproject.messaging;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import org.briarproject.api.messaging.PrivateConversation;
|
||||||
|
import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||||
|
import org.briarproject.api.sync.Message;
|
||||||
|
import org.briarproject.api.sync.MessageFactory;
|
||||||
|
import org.briarproject.api.sync.MessageId;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.GeneralSecurityException;
|
||||||
|
|
||||||
|
// Temporary facade during sync protocol refactoring
|
||||||
|
class PrivateMessageFactoryImpl implements PrivateMessageFactory {
|
||||||
|
|
||||||
|
private final MessageFactory messageFactory;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
PrivateMessageFactoryImpl(MessageFactory messageFactory) {
|
||||||
|
this.messageFactory = messageFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Message createPrivateMessage(MessageId parent,
|
||||||
|
PrivateConversation conversation, String contentType,
|
||||||
|
long timestamp, byte[] body)
|
||||||
|
throws IOException, GeneralSecurityException {
|
||||||
|
return messageFactory.createAnonymousMessage(parent,
|
||||||
|
((PrivateConversationImpl) conversation).getGroup(),
|
||||||
|
contentType, timestamp, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user