Add GroupId to conversation items

This commit is contained in:
Torsten Grote
2016-10-05 12:09:08 -03:00
parent 1731369d7a
commit 457c30f3f2
27 changed files with 158 additions and 113 deletions

View File

@@ -681,11 +681,10 @@ public class ConversationActivity extends BriarActivity
long duration = System.currentTimeMillis() - now; long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO)) if (LOG.isLoggable(INFO))
LOG.info("Storing message took " + duration + " ms"); LOG.info("Storing message took " + duration + " ms");
MessageId id = m.getMessage().getId(); MessageId id = m.getMessage().getId();
PrivateMessageHeader h = new PrivateMessageHeader(id, PrivateMessageHeader h = new PrivateMessageHeader(id,
m.getMessage().getTimestamp(), m.getContentType(), groupId, m.getMessage().getTimestamp(),
true, false, false, false); m.getContentType(), true, false, false, false);
ConversationMessageItem item = ConversationItem.from(h); ConversationMessageItem item = ConversationItem.from(h);
item.setBody(body); item.setBody(body);
bodyCache.put(id, body); bodyCache.put(id, body);

View File

@@ -9,7 +9,7 @@ abstract class ConversationIntroductionItem extends ConversationItem {
private boolean answered; private boolean answered;
ConversationIntroductionItem(IntroductionRequest ir) { ConversationIntroductionItem(IntroductionRequest ir) {
super(ir.getMessageId(), ir.getTimestamp()); super(ir.getMessageId(), ir.getGroupId(), ir.getTimestamp());
this.ir = ir; this.ir = ir;
this.answered = ir.wasAnswered(); this.answered = ir.wasAnswered();

View File

@@ -12,6 +12,7 @@ import org.briarproject.api.messaging.PrivateMessageHeader;
import org.briarproject.api.sharing.InvitationMessage; import org.briarproject.api.sharing.InvitationMessage;
import org.briarproject.api.sharing.InvitationRequest; import org.briarproject.api.sharing.InvitationRequest;
import org.briarproject.api.sharing.InvitationResponse; import org.briarproject.api.sharing.InvitationResponse;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
// This class is not thread-safe // This class is not thread-safe
@@ -31,10 +32,12 @@ public abstract class ConversationItem {
final static int BLOG_INVITATION_OUT = 10; final static int BLOG_INVITATION_OUT = 10;
private MessageId id; private MessageId id;
private GroupId groupId;
private long time; private long time;
public ConversationItem(MessageId id, long time) { public ConversationItem(MessageId id, GroupId groupId, long time) {
this.id = id; this.id = id;
this.groupId = groupId;
this.time = time; this.time = time;
} }
@@ -44,6 +47,10 @@ public abstract class ConversationItem {
return id; return id;
} }
public GroupId getGroupId() {
return groupId;
}
long getTime() { long getTime() {
return time; return time;
} }
@@ -78,8 +85,9 @@ public abstract class ConversationItem {
R.string.introduction_response_declined_sent, R.string.introduction_response_declined_sent,
ir.getName()); ir.getName());
} }
return new ConversationNoticeOutItem(ir.getMessageId(), text, return new ConversationNoticeOutItem(ir.getMessageId(),
ir.getTimestamp(), ir.isSent(), ir.isSeen()); ir.getGroupId(), text, ir.getTimestamp(), ir.isSent(),
ir.isSeen());
} else { } else {
String text; String text;
if (ir.wasAccepted()) { if (ir.wasAccepted()) {
@@ -97,8 +105,8 @@ public abstract class ConversationItem {
contactName, ir.getName()); contactName, ir.getName());
} }
} }
return new ConversationNoticeInItem(ir.getMessageId(), text, return new ConversationNoticeInItem(ir.getMessageId(),
ir.getTimestamp(), ir.isRead()); ir.getGroupId(), text, ir.getTimestamp(), ir.isRead());
} }
} }
@@ -137,8 +145,8 @@ public abstract class ConversationItem {
R.string.forum_invitation_response_declined_sent, R.string.forum_invitation_response_declined_sent,
contactName); contactName);
} }
return new ConversationNoticeOutItem(fir.getId(), text, return new ConversationNoticeOutItem(fir.getId(), fir.getGroupId(),
fir.getTimestamp(), fir.isSent(), fir.isSeen()); text, fir.getTimestamp(), fir.isSent(), fir.isSeen());
} else { } else {
String text; String text;
if (fir.wasAccepted()) { if (fir.wasAccepted()) {
@@ -150,8 +158,8 @@ public abstract class ConversationItem {
R.string.forum_invitation_response_declined_received, R.string.forum_invitation_response_declined_received,
contactName); contactName);
} }
return new ConversationNoticeInItem(fir.getId(), text, return new ConversationNoticeInItem(fir.getId(), fir.getGroupId(),
fir.getTimestamp(), fir.isRead()); text, fir.getTimestamp(), fir.isRead());
} }
} }
@@ -169,8 +177,8 @@ public abstract class ConversationItem {
R.string.blogs_sharing_response_declined_sent, R.string.blogs_sharing_response_declined_sent,
contactName); contactName);
} }
return new ConversationNoticeOutItem(fir.getId(), text, return new ConversationNoticeOutItem(fir.getId(), fir.getGroupId(),
fir.getTimestamp(), fir.isSent(), fir.isSeen()); text, fir.getTimestamp(), fir.isSent(), fir.isSeen());
} else { } else {
String text; String text;
if (fir.wasAccepted()) { if (fir.wasAccepted()) {
@@ -182,8 +190,8 @@ public abstract class ConversationItem {
R.string.blogs_sharing_response_declined_received, R.string.blogs_sharing_response_declined_received,
contactName); contactName);
} }
return new ConversationNoticeInItem(fir.getId(), text, return new ConversationNoticeInItem(fir.getId(), fir.getGroupId(),
fir.getTimestamp(), fir.isRead()); text, fir.getTimestamp(), fir.isRead());
} }
} }
@@ -193,10 +201,10 @@ public abstract class ConversationItem {
*/ */
public static ConversationItem from(IntroductionMessage im) { public static ConversationItem from(IntroductionMessage im) {
if (im.isLocal()) if (im.isLocal())
return new ConversationNoticeOutItem(im.getMessageId(), "", return new ConversationNoticeOutItem(im.getMessageId(),
im.getTimestamp(), false, false); im.getGroupId(), "", im.getTimestamp(), false, false);
return new ConversationNoticeInItem(im.getMessageId(), "", return new ConversationNoticeInItem(im.getMessageId(), im.getGroupId(),
im.getTimestamp(), im.isRead()); "", im.getTimestamp(), im.isRead());
} }
/** /**
@@ -205,9 +213,9 @@ public abstract class ConversationItem {
*/ */
public static ConversationItem from(InvitationMessage im) { public static ConversationItem from(InvitationMessage im) {
if (im.isLocal()) if (im.isLocal())
return new ConversationNoticeOutItem(im.getId(), "", return new ConversationNoticeOutItem(im.getId(), im.getGroupId(),
im.getTimestamp(), false, false); "", im.getTimestamp(), false, false);
return new ConversationNoticeInItem(im.getId(), "", return new ConversationNoticeInItem(im.getId(), im.getGroupId(), "",
im.getTimestamp(), im.isRead()); im.getTimestamp(), im.isRead());
} }
@@ -228,6 +236,8 @@ public abstract class ConversationItem {
MessageId getId(); MessageId getId();
GroupId getGroupId();
boolean isRead(); boolean isRead();
void setRead(boolean read); void setRead(boolean read);

View File

@@ -9,7 +9,7 @@ abstract class ConversationMessageItem extends ConversationItem {
private byte[] body; private byte[] body;
ConversationMessageItem(PrivateMessageHeader header) { ConversationMessageItem(PrivateMessageHeader header) {
super(header.getId(), header.getTimestamp()); super(header.getId(), header.getGroupId(), header.getTimestamp());
this.header = header; this.header = header;
body = null; body = null;

View File

@@ -1,5 +1,6 @@
package org.briarproject.android.contact; package org.briarproject.android.contact;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
// This class is not thread-safe // This class is not thread-safe
@@ -8,9 +9,9 @@ class ConversationNoticeInItem extends ConversationNoticeItem
private boolean read; private boolean read;
ConversationNoticeInItem(MessageId id, String text, long time, ConversationNoticeInItem(MessageId id, GroupId groupId, String text,
boolean read) { long time, boolean read) {
super(id, text, time); super(id, groupId, text, time);
this.read = read; this.read = read;
} }

View File

@@ -1,13 +1,15 @@
package org.briarproject.android.contact; package org.briarproject.android.contact;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
abstract class ConversationNoticeItem extends ConversationItem { abstract class ConversationNoticeItem extends ConversationItem {
private final String text; private final String text;
ConversationNoticeItem(MessageId id, String text, long time) { ConversationNoticeItem(MessageId id, GroupId groupId, String text,
super(id, time); long time) {
super(id, groupId, time);
this.text = text; this.text = text;
} }

View File

@@ -1,5 +1,6 @@
package org.briarproject.android.contact; package org.briarproject.android.contact;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
// This class is not thread-safe // This class is not thread-safe
@@ -8,9 +9,9 @@ class ConversationNoticeOutItem extends ConversationNoticeItem
private boolean sent, seen; private boolean sent, seen;
ConversationNoticeOutItem(MessageId id, String text, long time, ConversationNoticeOutItem(MessageId id, GroupId groupId, String text,
boolean sent, boolean seen) { long time, boolean sent, boolean seen) {
super(id, text, time); super(id, groupId, text, time);
this.sent = sent; this.sent = sent;
this.seen = seen; this.seen = seen;

View File

@@ -7,7 +7,7 @@ abstract class ConversationShareableInvitationItem extends ConversationItem {
private final InvitationRequest fim; private final InvitationRequest fim;
ConversationShareableInvitationItem(InvitationRequest fim) { ConversationShareableInvitationItem(InvitationRequest fim) {
super(fim.getId(), fim.getTimestamp()); super(fim.getId(), fim.getGroupId(), fim.getTimestamp());
this.fim = fim; this.fim = fim;
} }

View File

@@ -2,8 +2,8 @@ package org.briarproject.api.blogs;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.sharing.InvitationMessage;
import org.briarproject.api.sharing.InvitationRequest; import org.briarproject.api.sharing.InvitationRequest;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
public class BlogInvitationRequest extends InvitationRequest { public class BlogInvitationRequest extends InvitationRequest {
@@ -11,12 +11,12 @@ public class BlogInvitationRequest extends InvitationRequest {
private final String blogAuthorName; private final String blogAuthorName;
public BlogInvitationRequest(MessageId id, SessionId sessionId, public BlogInvitationRequest(MessageId id, SessionId sessionId,
ContactId contactId, String blogAuthorName, String message, GroupId groupId, ContactId contactId, String blogAuthorName,
boolean available, long time, boolean local, boolean sent, String message, boolean available, long time, boolean local,
boolean seen, boolean read) { boolean sent, boolean seen, boolean read) {
super(id, sessionId, contactId, message, available, time, local, sent, super(id, sessionId, groupId, contactId, message, available, time,
seen, read); local, sent, seen, read);
this.blogAuthorName = blogAuthorName; this.blogAuthorName = blogAuthorName;
} }

View File

@@ -3,15 +3,17 @@ package org.briarproject.api.blogs;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.sharing.InvitationResponse; import org.briarproject.api.sharing.InvitationResponse;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
public class BlogInvitationResponse extends InvitationResponse { public class BlogInvitationResponse extends InvitationResponse {
public BlogInvitationResponse(MessageId id, SessionId sessionId, public BlogInvitationResponse(MessageId id, SessionId sessionId,
ContactId contactId, boolean accept, long time, boolean local, GroupId groupId, ContactId contactId, boolean accept, long time,
boolean sent, boolean seen, boolean read) { boolean local, boolean sent, boolean seen, boolean read) {
super(id, sessionId, contactId, accept, time, local, sent, seen, read); super(id, sessionId, groupId, contactId, accept, time, local, sent,
seen, read);
} }
} }

View File

@@ -1,17 +1,20 @@
package org.briarproject.api.clients; package org.briarproject.api.clients;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
public abstract class BaseMessageHeader { public abstract class BaseMessageHeader {
private final MessageId id; private final MessageId id;
private final GroupId groupId;
private final long timestamp; private final long timestamp;
private final boolean local, read, sent, seen; private final boolean local, read, sent, seen;
public BaseMessageHeader(MessageId id, long timestamp, boolean local, public BaseMessageHeader(MessageId id, GroupId groupId, long timestamp,
boolean read, boolean sent, boolean seen) { boolean local, boolean read, boolean sent, boolean seen) {
this.id = id; this.id = id;
this.groupId = groupId;
this.timestamp = timestamp; this.timestamp = timestamp;
this.local = local; this.local = local;
this.read = read; this.read = read;
@@ -23,6 +26,10 @@ public abstract class BaseMessageHeader {
return id; return id;
} }
public GroupId getGroupId() {
return groupId;
}
public long getTimestamp() { public long getTimestamp() {
return timestamp; return timestamp;
} }
@@ -42,4 +49,5 @@ public abstract class BaseMessageHeader {
public boolean isSeen() { public boolean isSeen() {
return seen; return seen;
} }
} }

View File

@@ -3,6 +3,7 @@ package org.briarproject.api.forum;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.sharing.InvitationRequest; import org.briarproject.api.sharing.InvitationRequest;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -10,13 +11,13 @@ public class ForumInvitationRequest extends InvitationRequest {
private final String forumName; private final String forumName;
public ForumInvitationRequest(@Nullable MessageId id, SessionId sessionId, public ForumInvitationRequest(MessageId id, SessionId sessionId,
ContactId contactId, String forumName, String message, GroupId groupId, ContactId contactId, String forumName, String message,
boolean available, long time, boolean local, boolean sent, boolean available, long time, boolean local, boolean sent,
boolean seen, boolean read) { boolean seen, boolean read) {
super(id, sessionId, contactId, message, available, time, local, sent, super(id, sessionId, groupId, contactId, message, available, time,
seen, read); local, sent, seen, read);
this.forumName = forumName; this.forumName = forumName;
} }

View File

@@ -3,16 +3,18 @@ package org.briarproject.api.forum;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.sharing.InvitationResponse; import org.briarproject.api.sharing.InvitationResponse;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class ForumInvitationResponse extends InvitationResponse { public class ForumInvitationResponse extends InvitationResponse {
public ForumInvitationResponse(@Nullable MessageId id, SessionId sessionId, public ForumInvitationResponse(MessageId id, SessionId sessionId,
ContactId contactId, boolean accept, long time, boolean local, GroupId groupId, ContactId contactId, boolean accept, long time, boolean local,
boolean sent, boolean seen, boolean read) { boolean sent, boolean seen, boolean read) {
super(id, sessionId, contactId, accept, time, local, sent, seen, read); super(id, sessionId, groupId, contactId, accept, time, local, sent,
seen, read);
} }
} }

View File

@@ -2,6 +2,7 @@ package org.briarproject.api.introduction;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.clients.BaseMessageHeader; import org.briarproject.api.clients.BaseMessageHeader;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import static org.briarproject.api.introduction.IntroductionConstants.ROLE_INTRODUCEE; import static org.briarproject.api.introduction.IntroductionConstants.ROLE_INTRODUCEE;
@@ -14,10 +15,10 @@ import static org.briarproject.api.introduction.IntroductionConstants.ROLE_INTRO
private final int role; private final int role;
public IntroductionMessage(SessionId sessionId, MessageId messageId, public IntroductionMessage(SessionId sessionId, MessageId messageId,
int role, long time, boolean local, boolean sent, boolean seen, GroupId groupId, int role, long time, boolean local, boolean sent,
boolean read) { boolean seen, boolean read) {
super(messageId, time, local, read, sent, seen); super(messageId, groupId, time, local, read, sent, seen);
this.sessionId = sessionId; this.sessionId = sessionId;
this.messageId = messageId; this.messageId = messageId;
this.role = role; this.role = role;

View File

@@ -2,6 +2,7 @@ package org.briarproject.api.introduction;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.identity.AuthorId; import org.briarproject.api.identity.AuthorId;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
public class IntroductionRequest extends IntroductionResponse { public class IntroductionRequest extends IntroductionResponse {
@@ -10,13 +11,13 @@ public class IntroductionRequest extends IntroductionResponse {
private final boolean answered, exists, introducesOtherIdentity; private final boolean answered, exists, introducesOtherIdentity;
public IntroductionRequest(SessionId sessionId, MessageId messageId, public IntroductionRequest(SessionId sessionId, MessageId messageId,
int role, long time, boolean local, boolean sent, boolean seen, GroupId groupId, int role, long time, boolean local, boolean sent,
boolean read, AuthorId authorId, String name, boolean accepted, boolean seen, boolean read, AuthorId authorId, String name,
String message, boolean answered, boolean exists, boolean accepted, String message, boolean answered, boolean exists,
boolean introducesOtherIdentity) { boolean introducesOtherIdentity) {
super(sessionId, messageId, role, time, local, sent, seen, read, super(sessionId, messageId, groupId, role, time, local, sent, seen,
authorId, name, accepted); read, authorId, name, accepted);
this.message = message; this.message = message;
this.answered = answered; this.answered = answered;

View File

@@ -2,6 +2,7 @@ package org.briarproject.api.introduction;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.identity.AuthorId; import org.briarproject.api.identity.AuthorId;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
public class IntroductionResponse extends IntroductionMessage { public class IntroductionResponse extends IntroductionMessage {
@@ -11,11 +12,12 @@ public class IntroductionResponse extends IntroductionMessage {
private final boolean accepted; private final boolean accepted;
public IntroductionResponse(SessionId sessionId, MessageId messageId, public IntroductionResponse(SessionId sessionId, MessageId messageId,
int role, long time, boolean local, boolean sent, boolean seen, GroupId groupId, int role, long time, boolean local, boolean sent,
boolean read, AuthorId remoteAuthorId, String name, boolean seen, boolean read, AuthorId remoteAuthorId, String name,
boolean accepted) { boolean accepted) {
super(sessionId, messageId, role, time, local, sent, seen, read); super(sessionId, messageId, groupId, role, time, local, sent, seen,
read);
this.remoteAuthorId = remoteAuthorId; this.remoteAuthorId = remoteAuthorId;
this.name = name; this.name = name;

View File

@@ -1,17 +1,18 @@
package org.briarproject.api.messaging; package org.briarproject.api.messaging;
import org.briarproject.api.clients.BaseMessageHeader; import org.briarproject.api.clients.BaseMessageHeader;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
public class PrivateMessageHeader extends BaseMessageHeader { public class PrivateMessageHeader extends BaseMessageHeader {
private final String contentType; private final String contentType;
public PrivateMessageHeader(MessageId id, long timestamp, public PrivateMessageHeader(MessageId id, GroupId groupId, long timestamp,
String contentType, boolean local, boolean read, boolean sent, String contentType, boolean local, boolean read, boolean sent,
boolean seen) { boolean seen) {
super(id, timestamp, local, read, sent, seen); super(id, groupId, timestamp, local, read, sent, seen);
this.contentType = contentType; this.contentType = contentType;
} }

View File

@@ -1,8 +1,9 @@
package org.briarproject.api.sharing; package org.briarproject.api.sharing;
import org.briarproject.api.clients.BaseMessageHeader;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.clients.BaseMessageHeader; import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
public abstract class InvitationMessage extends BaseMessageHeader { public abstract class InvitationMessage extends BaseMessageHeader {
@@ -10,11 +11,11 @@ public abstract class InvitationMessage extends BaseMessageHeader {
private final SessionId sessionId; private final SessionId sessionId;
private final ContactId contactId; private final ContactId contactId;
public InvitationMessage(MessageId id, SessionId sessionId, public InvitationMessage(MessageId id, SessionId sessionId, GroupId groupId,
ContactId contactId, long time, boolean local, boolean sent, ContactId contactId, long time, boolean local, boolean sent,
boolean seen, boolean read) { boolean seen, boolean read) {
super(id, time, local, read, sent, seen); super(id, groupId, time, local, read, sent, seen);
this.sessionId = sessionId; this.sessionId = sessionId;
this.contactId = contactId; this.contactId = contactId;
} }

View File

@@ -2,6 +2,7 @@ package org.briarproject.api.sharing;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -10,12 +11,12 @@ public abstract class InvitationRequest extends InvitationMessage {
private final String message; private final String message;
private final boolean available; private final boolean available;
public InvitationRequest(MessageId id, SessionId sessionId, public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId,
ContactId contactId, String message, ContactId contactId, String message,
boolean available, long time, boolean local, boolean sent, boolean available, long time, boolean local, boolean sent,
boolean seen, boolean read) { boolean seen, boolean read) {
super(id, sessionId, contactId, time, local, read, sent, seen); super(id, sessionId, groupId, contactId, time, local, read, sent, seen);
this.message = message; this.message = message;
this.available = available; this.available = available;
} }

View File

@@ -2,6 +2,7 @@ package org.briarproject.api.sharing;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
public abstract class InvitationResponse extends InvitationMessage { public abstract class InvitationResponse extends InvitationMessage {
@@ -9,10 +10,10 @@ public abstract class InvitationResponse extends InvitationMessage {
private final boolean accept; private final boolean accept;
public InvitationResponse(MessageId id, SessionId sessionId, public InvitationResponse(MessageId id, SessionId sessionId,
ContactId contactId, boolean accept, long time, boolean local, GroupId groupId, ContactId contactId, boolean accept, long time,
boolean sent, boolean seen, boolean read) { boolean local, boolean sent, boolean seen, boolean read) {
super(id, sessionId, contactId, time, local, read, sent, seen); super(id, sessionId, groupId, contactId, time, local, read, sent, seen);
this.accept = accept; this.accept = accept;
} }

View File

@@ -12,6 +12,7 @@ import org.briarproject.api.introduction.IntroduceeAction;
import org.briarproject.api.introduction.IntroduceeProtocolState; import org.briarproject.api.introduction.IntroduceeProtocolState;
import org.briarproject.api.introduction.IntroductionRequest; import org.briarproject.api.introduction.IntroductionRequest;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import java.util.ArrayList; import java.util.ArrayList;
@@ -343,6 +344,7 @@ public class IntroduceeEngine
SessionId sessionId = new SessionId(localState.getRaw(SESSION_ID)); SessionId sessionId = new SessionId(localState.getRaw(SESSION_ID));
MessageId messageId = new MessageId(msg.getRaw(MESSAGE_ID)); MessageId messageId = new MessageId(msg.getRaw(MESSAGE_ID));
GroupId groupId = new GroupId(msg.getRaw(GROUP_ID));
long time = msg.getLong(MESSAGE_TIME); long time = msg.getLong(MESSAGE_TIME);
String name = msg.getString(NAME); String name = msg.getString(NAME);
String message = msg.getOptionalString(MSG); String message = msg.getOptionalString(MSG);
@@ -351,8 +353,9 @@ public class IntroduceeEngine
localState.getBoolean(REMOTE_AUTHOR_IS_US); localState.getBoolean(REMOTE_AUTHOR_IS_US);
IntroductionRequest ir = new IntroductionRequest(sessionId, messageId, IntroductionRequest ir = new IntroductionRequest(sessionId, messageId,
ROLE_INTRODUCEE, time, false, false, false, false, authorId, groupId, ROLE_INTRODUCEE, time, false, false, false, false,
name, false, message, false, exists, introducesOtherIdentity); authorId, name, false, message, false, exists,
introducesOtherIdentity);
return new IntroductionRequestReceivedEvent(contactId, ir); return new IntroductionRequestReceivedEvent(contactId, ir);
} }

View File

@@ -12,6 +12,7 @@ import org.briarproject.api.introduction.IntroducerAction;
import org.briarproject.api.introduction.IntroducerProtocolState; import org.briarproject.api.introduction.IntroducerProtocolState;
import org.briarproject.api.introduction.IntroductionResponse; import org.briarproject.api.introduction.IntroductionResponse;
import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.SessionId;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
import java.util.ArrayList; import java.util.ArrayList;
@@ -298,14 +299,15 @@ public class IntroducerEngine
SessionId sessionId = new SessionId(localState.getRaw(SESSION_ID)); SessionId sessionId = new SessionId(localState.getRaw(SESSION_ID));
MessageId messageId = new MessageId(msg.getRaw(MESSAGE_ID)); MessageId messageId = new MessageId(msg.getRaw(MESSAGE_ID));
GroupId groupId = new GroupId(msg.getRaw(GROUP_ID));
long time = msg.getLong(MESSAGE_TIME); long time = msg.getLong(MESSAGE_TIME);
String name = getOtherContact(localState, msg); String name = getOtherContact(localState, msg);
boolean accept = msg.getBoolean(ACCEPT); boolean accept = msg.getBoolean(ACCEPT);
IntroductionResponse ir = IntroductionResponse ir =
new IntroductionResponse(sessionId, messageId, ROLE_INTRODUCER, new IntroductionResponse(sessionId, messageId, groupId,
time, false, false, false, false, authorId, name, ROLE_INTRODUCER, time, false, false, false, false,
accept); authorId, name, accept);
return new IntroductionResponseReceivedEvent(contactId, ir); return new IntroductionResponseReceivedEvent(contactId, ir);
} }

View File

@@ -415,7 +415,7 @@ class IntroductionManagerImpl extends BdfIncomingMessageHook
name = state.getString(NAME); name = state.getString(NAME);
} }
IntroductionResponse ir = new IntroductionResponse( IntroductionResponse ir = new IntroductionResponse(
sessionId, messageId, role, time, local, sessionId, messageId, g, role, time, local,
s.isSent(), s.isSeen(), read, authorId, name, s.isSent(), s.isSeen(), read, authorId, name,
accepted); accepted);
list.add(ir); list.add(ir);
@@ -445,7 +445,7 @@ class IntroductionManagerImpl extends BdfIncomingMessageHook
state.getBoolean(REMOTE_AUTHOR_IS_US); state.getBoolean(REMOTE_AUTHOR_IS_US);
} }
IntroductionRequest ir = new IntroductionRequest( IntroductionRequest ir = new IntroductionRequest(
sessionId, messageId, role, time, local, sessionId, messageId, g, role, time, local,
s.isSent(), s.isSeen(), read, authorId, name, s.isSent(), s.isSeen(), read, authorId, name,
accepted, message, answered, exists, accepted, message, answered, exists,
introducesOtherIdentity); introducesOtherIdentity);

View File

@@ -101,7 +101,8 @@ class MessagingManagerImpl extends BdfIncomingMessageHook
boolean local = meta.getBoolean("local"); boolean local = meta.getBoolean("local");
boolean read = meta.getBoolean(MSG_KEY_READ); boolean read = meta.getBoolean(MSG_KEY_READ);
PrivateMessageHeader header = new PrivateMessageHeader( PrivateMessageHeader header = new PrivateMessageHeader(
m.getId(), timestamp, contentType, local, read, false, false); m.getId(), m.getGroupId(), timestamp, contentType, local, read,
false, false);
PrivateMessageReceivedEvent event = new PrivateMessageReceivedEvent( PrivateMessageReceivedEvent event = new PrivateMessageReceivedEvent(
header, groupId); header, groupId);
txn.attach(event); txn.attach(event);
@@ -159,9 +160,10 @@ class MessagingManagerImpl extends BdfIncomingMessageHook
throws DbException { throws DbException {
Map<MessageId, BdfDictionary> metadata; Map<MessageId, BdfDictionary> metadata;
Collection<MessageStatus> statuses; Collection<MessageStatus> statuses;
GroupId g;
Transaction txn = db.startTransaction(true); Transaction txn = db.startTransaction(true);
try { try {
GroupId g = getContactGroup(db.getContact(txn, c)).getId(); g = getContactGroup(db.getContact(txn, c)).getId();
metadata = clientHelper.getMessageMetadataAsDictionary(txn, g); metadata = clientHelper.getMessageMetadataAsDictionary(txn, g);
statuses = db.getMessageStatus(txn, c, g); statuses = db.getMessageStatus(txn, c, g);
txn.setComplete(); txn.setComplete();
@@ -181,8 +183,8 @@ class MessagingManagerImpl extends BdfIncomingMessageHook
String contentType = meta.getString("contentType"); String contentType = meta.getString("contentType");
boolean local = meta.getBoolean("local"); boolean local = meta.getBoolean("local");
boolean read = meta.getBoolean("read"); boolean read = meta.getBoolean("read");
headers.add(new PrivateMessageHeader(id, timestamp, contentType, headers.add(new PrivateMessageHeader(id, g, timestamp,
local, read, s.isSent(), s.isSeen())); contentType, local, read, s.isSent(), s.isSeen()));
} catch (FormatException e) { } catch (FormatException e) {
throw new DbException(e); throw new DbException(e);
} }

View File

@@ -109,17 +109,18 @@ class BlogSharingManagerImpl extends
BlogInvitation msg, ContactId contactId, boolean available, BlogInvitation msg, ContactId contactId, boolean available,
long time, boolean local, boolean sent, boolean seen, long time, boolean local, boolean sent, boolean seen,
boolean read) { boolean read) {
return new BlogInvitationRequest(id, msg.getSessionId(), contactId, return new BlogInvitationRequest(id, msg.getSessionId(),
msg.getBlogAuthorName(), msg.getMessage(), available, time, msg.getGroupId(), contactId, msg.getBlogAuthorName(),
local, sent, seen, read); msg.getMessage(), available, time, local, sent, seen, read);
} }
@Override @Override
protected InvitationMessage createInvitationResponse(MessageId id, protected InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, ContactId contactId, boolean accept, long time, SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time,
boolean local, boolean sent, boolean seen, boolean read) { boolean local, boolean sent, boolean seen, boolean read) {
return new BlogInvitationResponse(id, sessionId, contactId, accept, return new BlogInvitationResponse(id, sessionId, groupId, contactId,
time, local, sent, seen, read); accept, time, local, sent, seen, read);
} }
@Override @Override
@@ -321,9 +322,9 @@ class BlogSharingManagerImpl extends
ContactId contactId = localState.getContactId(); ContactId contactId = localState.getContactId();
BlogInvitationRequest request = BlogInvitationRequest request =
new BlogInvitationRequest(localState.getInvitationId(), new BlogInvitationRequest(localState.getInvitationId(),
localState.getSessionId(), contactId, localState.getSessionId(), localState.getGroupId(),
blog.getAuthor().getName(), msg, true, time, false, contactId, blog.getAuthor().getName(), msg, true,
false, false, false); time, false, false, false, false);
return new BlogInvitationReceivedEvent(blog, contactId, request); return new BlogInvitationReceivedEvent(blog, contactId, request);
} }
} }
@@ -337,7 +338,7 @@ class BlogSharingManagerImpl extends
ContactId c = localState.getContactId(); ContactId c = localState.getContactId();
BlogInvitationResponse response = BlogInvitationResponse response =
new BlogInvitationResponse(localState.getResponseId(), new BlogInvitationResponse(localState.getResponseId(),
localState.getSessionId(), localState.getSessionId(), localState.getGroupId(),
localState.getContactId(), accept, time, false, localState.getContactId(), accept, time, false,
false, false, false); false, false, false);
return new BlogInvitationResponseReceivedEvent(title, c, response); return new BlogInvitationResponseReceivedEvent(title, c, response);

View File

@@ -83,17 +83,18 @@ class ForumSharingManagerImpl extends
ForumInvitation msg, ContactId contactId, boolean available, ForumInvitation msg, ContactId contactId, boolean available,
long time, boolean local, boolean sent, boolean seen, long time, boolean local, boolean sent, boolean seen,
boolean read) { boolean read) {
return new ForumInvitationRequest(id, msg.getSessionId(), contactId, return new ForumInvitationRequest(id, msg.getSessionId(),
msg.getForumName(), msg.getMessage(), available, time, local, msg.getGroupId(), contactId, msg.getForumName(),
sent, seen, read); msg.getMessage(), available, time, local, sent, seen, read);
} }
@Override @Override
protected InvitationMessage createInvitationResponse(MessageId id, protected InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, ContactId contactId, boolean accept, SessionId sessionId, GroupId groupId, ContactId contactId,
long time, boolean local, boolean sent, boolean seen, boolean read) { boolean accept, long time, boolean local, boolean sent,
return new ForumInvitationResponse(id, sessionId, contactId, accept, boolean seen, boolean read) {
time, local, sent, seen, read); return new ForumInvitationResponse(id, sessionId, groupId, contactId,
accept, time, local, sent, seen, read);
} }
@Override @Override
@@ -268,8 +269,8 @@ class ForumSharingManagerImpl extends
ContactId contactId = localState.getContactId(); ContactId contactId = localState.getContactId();
ForumInvitationRequest request = new ForumInvitationRequest( ForumInvitationRequest request = new ForumInvitationRequest(
localState.getInvitationId(), localState.getSessionId(), localState.getInvitationId(), localState.getSessionId(),
contactId, forum.getName(), msg, true, time, false, false, localState.getGroupId(), contactId, forum.getName(), msg,
false, false); true, time, false, false, false, false);
return new ForumInvitationReceivedEvent(forum, contactId, request); return new ForumInvitationReceivedEvent(forum, contactId, request);
} }
} }
@@ -282,9 +283,9 @@ class ForumSharingManagerImpl extends
String name = localState.getForumName(); String name = localState.getForumName();
ContactId c = localState.getContactId(); ContactId c = localState.getContactId();
ForumInvitationResponse response = new ForumInvitationResponse( ForumInvitationResponse response = new ForumInvitationResponse(
localState.getResponseId(), localState.getResponseId(), localState.getSessionId(),
localState.getSessionId(), localState.getContactId(), localState.getGroupId(), localState.getContactId(), accept,
accept, time, false, false, false, false); time, false, false, false, false);
return new ForumInvitationResponseReceivedEvent(name, c, response); return new ForumInvitationResponseReceivedEvent(name, c, response);
} }
} }

View File

@@ -117,13 +117,14 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
public abstract ClientId getClientId(); public abstract ClientId getClientId();
protected abstract InvitationMessage createInvitationRequest(MessageId id, I msg, protected abstract InvitationMessage createInvitationRequest(MessageId id,
ContactId contactId, boolean available, long time, boolean local, I msg, ContactId contactId, boolean available, long time,
boolean sent, boolean seen, boolean read); boolean local, boolean sent, boolean seen, boolean read);
protected abstract InvitationMessage createInvitationResponse(MessageId id, protected abstract InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, ContactId contactId, boolean accept, long time, SessionId sessionId, GroupId groupId, ContactId contactId,
boolean local, boolean sent, boolean seen, boolean read); boolean accept, long time, boolean local, boolean sent,
boolean seen, boolean read);
protected abstract ShareableFactory<S, I, IS, SS> getSFactory(); protected abstract ShareableFactory<S, I, IS, SS> getSFactory();
@@ -394,8 +395,9 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
.from(getIFactory(), group.getId(), d); .from(getIFactory(), group.getId(), d);
SessionId sessionId = msg.getSessionId(); SessionId sessionId = msg.getSessionId();
InvitationMessage im = createInvitationResponse( InvitationMessage im = createInvitationResponse(
m.getKey(), sessionId, contactId, accept, time, m.getKey(), sessionId, group.getId(), contactId,
local, status.isSent(), status.isSeen(), read); accept, time, local, status.isSent(),
status.isSeen(), read);
list.add(im); list.add(im);
} }
else { else {