diff --git a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java index 6f3f1f4e894eb470fb2cd70c80dad556932d8bc2..1329892656f3b76b761171c4ebc635a0a63341d1 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java @@ -681,11 +681,10 @@ public class ConversationActivity extends BriarActivity long duration = System.currentTimeMillis() - now; if (LOG.isLoggable(INFO)) LOG.info("Storing message took " + duration + " ms"); - MessageId id = m.getMessage().getId(); PrivateMessageHeader h = new PrivateMessageHeader(id, - m.getMessage().getTimestamp(), m.getContentType(), - true, false, false, false); + groupId, m.getMessage().getTimestamp(), + m.getContentType(), true, false, false, false); ConversationMessageItem item = ConversationItem.from(h); item.setBody(body); bodyCache.put(id, body); diff --git a/briar-android/src/org/briarproject/android/contact/ConversationIntroductionItem.java b/briar-android/src/org/briarproject/android/contact/ConversationIntroductionItem.java index 5fb30a23d96611efffbaa7ba13541082109e8483..123887df8d394f5827b2fcc777170b4886e0a3dc 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationIntroductionItem.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationIntroductionItem.java @@ -9,7 +9,7 @@ abstract class ConversationIntroductionItem extends ConversationItem { private boolean answered; ConversationIntroductionItem(IntroductionRequest ir) { - super(ir.getMessageId(), ir.getTimestamp()); + super(ir.getMessageId(), ir.getGroupId(), ir.getTimestamp()); this.ir = ir; this.answered = ir.wasAnswered(); diff --git a/briar-android/src/org/briarproject/android/contact/ConversationItem.java b/briar-android/src/org/briarproject/android/contact/ConversationItem.java index 083dc6bf7840ce47c8611d729e2ec5de1dc583dd..99b9d116d3d4e67014634764c857f4b777f338f2 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationItem.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationItem.java @@ -12,6 +12,7 @@ import org.briarproject.api.messaging.PrivateMessageHeader; import org.briarproject.api.sharing.InvitationMessage; import org.briarproject.api.sharing.InvitationRequest; import org.briarproject.api.sharing.InvitationResponse; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; // This class is not thread-safe @@ -31,10 +32,12 @@ public abstract class ConversationItem { final static int BLOG_INVITATION_OUT = 10; private MessageId id; + private GroupId groupId; private long time; - public ConversationItem(MessageId id, long time) { + public ConversationItem(MessageId id, GroupId groupId, long time) { this.id = id; + this.groupId = groupId; this.time = time; } @@ -44,6 +47,10 @@ public abstract class ConversationItem { return id; } + public GroupId getGroupId() { + return groupId; + } + long getTime() { return time; } @@ -78,8 +85,9 @@ public abstract class ConversationItem { R.string.introduction_response_declined_sent, ir.getName()); } - return new ConversationNoticeOutItem(ir.getMessageId(), text, - ir.getTimestamp(), ir.isSent(), ir.isSeen()); + return new ConversationNoticeOutItem(ir.getMessageId(), + ir.getGroupId(), text, ir.getTimestamp(), ir.isSent(), + ir.isSeen()); } else { String text; if (ir.wasAccepted()) { @@ -97,8 +105,8 @@ public abstract class ConversationItem { contactName, ir.getName()); } } - return new ConversationNoticeInItem(ir.getMessageId(), text, - ir.getTimestamp(), ir.isRead()); + return new ConversationNoticeInItem(ir.getMessageId(), + ir.getGroupId(), text, ir.getTimestamp(), ir.isRead()); } } @@ -137,8 +145,8 @@ public abstract class ConversationItem { R.string.forum_invitation_response_declined_sent, contactName); } - return new ConversationNoticeOutItem(fir.getId(), text, - fir.getTimestamp(), fir.isSent(), fir.isSeen()); + return new ConversationNoticeOutItem(fir.getId(), fir.getGroupId(), + text, fir.getTimestamp(), fir.isSent(), fir.isSeen()); } else { String text; if (fir.wasAccepted()) { @@ -150,8 +158,8 @@ public abstract class ConversationItem { R.string.forum_invitation_response_declined_received, contactName); } - return new ConversationNoticeInItem(fir.getId(), text, - fir.getTimestamp(), fir.isRead()); + return new ConversationNoticeInItem(fir.getId(), fir.getGroupId(), + text, fir.getTimestamp(), fir.isRead()); } } @@ -169,8 +177,8 @@ public abstract class ConversationItem { R.string.blogs_sharing_response_declined_sent, contactName); } - return new ConversationNoticeOutItem(fir.getId(), text, - fir.getTimestamp(), fir.isSent(), fir.isSeen()); + return new ConversationNoticeOutItem(fir.getId(), fir.getGroupId(), + text, fir.getTimestamp(), fir.isSent(), fir.isSeen()); } else { String text; if (fir.wasAccepted()) { @@ -182,8 +190,8 @@ public abstract class ConversationItem { R.string.blogs_sharing_response_declined_received, contactName); } - return new ConversationNoticeInItem(fir.getId(), text, - fir.getTimestamp(), fir.isRead()); + return new ConversationNoticeInItem(fir.getId(), fir.getGroupId(), + text, fir.getTimestamp(), fir.isRead()); } } @@ -193,10 +201,10 @@ public abstract class ConversationItem { */ public static ConversationItem from(IntroductionMessage im) { if (im.isLocal()) - return new ConversationNoticeOutItem(im.getMessageId(), "", - im.getTimestamp(), false, false); - return new ConversationNoticeInItem(im.getMessageId(), "", - im.getTimestamp(), im.isRead()); + return new ConversationNoticeOutItem(im.getMessageId(), + im.getGroupId(), "", im.getTimestamp(), false, false); + return new ConversationNoticeInItem(im.getMessageId(), im.getGroupId(), + "", im.getTimestamp(), im.isRead()); } /** @@ -205,9 +213,9 @@ public abstract class ConversationItem { */ public static ConversationItem from(InvitationMessage im) { if (im.isLocal()) - return new ConversationNoticeOutItem(im.getId(), "", - im.getTimestamp(), false, false); - return new ConversationNoticeInItem(im.getId(), "", + return new ConversationNoticeOutItem(im.getId(), im.getGroupId(), + "", im.getTimestamp(), false, false); + return new ConversationNoticeInItem(im.getId(), im.getGroupId(), "", im.getTimestamp(), im.isRead()); } @@ -228,6 +236,8 @@ public abstract class ConversationItem { MessageId getId(); + GroupId getGroupId(); + boolean isRead(); void setRead(boolean read); diff --git a/briar-android/src/org/briarproject/android/contact/ConversationMessageItem.java b/briar-android/src/org/briarproject/android/contact/ConversationMessageItem.java index b7a6aac44a9b35698ae9a5a59c744be1b46d0034..b4dc64b6cc8c2aa86e729f545b19a7a78776b04d 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationMessageItem.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationMessageItem.java @@ -9,7 +9,7 @@ abstract class ConversationMessageItem extends ConversationItem { private byte[] body; ConversationMessageItem(PrivateMessageHeader header) { - super(header.getId(), header.getTimestamp()); + super(header.getId(), header.getGroupId(), header.getTimestamp()); this.header = header; body = null; diff --git a/briar-android/src/org/briarproject/android/contact/ConversationNoticeInItem.java b/briar-android/src/org/briarproject/android/contact/ConversationNoticeInItem.java index bfa83160b167cac8761a3cde87a59fc195cfdde5..6e8fbfc8bcb3331b817bea7793f3295eb30b1cfa 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationNoticeInItem.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationNoticeInItem.java @@ -1,5 +1,6 @@ package org.briarproject.android.contact; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; // This class is not thread-safe @@ -8,9 +9,9 @@ class ConversationNoticeInItem extends ConversationNoticeItem private boolean read; - ConversationNoticeInItem(MessageId id, String text, long time, - boolean read) { - super(id, text, time); + ConversationNoticeInItem(MessageId id, GroupId groupId, String text, + long time, boolean read) { + super(id, groupId, text, time); this.read = read; } diff --git a/briar-android/src/org/briarproject/android/contact/ConversationNoticeItem.java b/briar-android/src/org/briarproject/android/contact/ConversationNoticeItem.java index b722ab95d2c32c945e544dcda0d10c5e95e8472f..758c311d01f57e9611e1a5b7411c7dcc41d4d689 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationNoticeItem.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationNoticeItem.java @@ -1,13 +1,15 @@ package org.briarproject.android.contact; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; abstract class ConversationNoticeItem extends ConversationItem { private final String text; - ConversationNoticeItem(MessageId id, String text, long time) { - super(id, time); + ConversationNoticeItem(MessageId id, GroupId groupId, String text, + long time) { + super(id, groupId, time); this.text = text; } diff --git a/briar-android/src/org/briarproject/android/contact/ConversationNoticeOutItem.java b/briar-android/src/org/briarproject/android/contact/ConversationNoticeOutItem.java index a5bdb5e20bf1fc2255c3c27214d3ecabd80fe329..95ed78510fba0d585b51044422d660a0f1d3a7ad 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationNoticeOutItem.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationNoticeOutItem.java @@ -1,5 +1,6 @@ package org.briarproject.android.contact; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; // This class is not thread-safe @@ -8,9 +9,9 @@ class ConversationNoticeOutItem extends ConversationNoticeItem private boolean sent, seen; - ConversationNoticeOutItem(MessageId id, String text, long time, - boolean sent, boolean seen) { - super(id, text, time); + ConversationNoticeOutItem(MessageId id, GroupId groupId, String text, + long time, boolean sent, boolean seen) { + super(id, groupId, text, time); this.sent = sent; this.seen = seen; diff --git a/briar-android/src/org/briarproject/android/contact/ConversationShareableInvitationItem.java b/briar-android/src/org/briarproject/android/contact/ConversationShareableInvitationItem.java index a2e9b91cf06166a1c626e8b3de00cdb5e4e345f3..60f8a70b1ca4bd1f331925cb771c35813e1f422e 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationShareableInvitationItem.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationShareableInvitationItem.java @@ -7,7 +7,7 @@ abstract class ConversationShareableInvitationItem extends ConversationItem { private final InvitationRequest fim; ConversationShareableInvitationItem(InvitationRequest fim) { - super(fim.getId(), fim.getTimestamp()); + super(fim.getId(), fim.getGroupId(), fim.getTimestamp()); this.fim = fim; } diff --git a/briar-api/src/org/briarproject/api/blogs/BlogInvitationRequest.java b/briar-api/src/org/briarproject/api/blogs/BlogInvitationRequest.java index 0f2970b25825ab134f338fa414a97023eae7336a..3fc41b9ddc1c67af73565aa7be09bea9cf3bec7d 100644 --- a/briar-api/src/org/briarproject/api/blogs/BlogInvitationRequest.java +++ b/briar-api/src/org/briarproject/api/blogs/BlogInvitationRequest.java @@ -2,8 +2,8 @@ package org.briarproject.api.blogs; import org.briarproject.api.clients.SessionId; import org.briarproject.api.contact.ContactId; -import org.briarproject.api.sharing.InvitationMessage; import org.briarproject.api.sharing.InvitationRequest; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; public class BlogInvitationRequest extends InvitationRequest { @@ -11,12 +11,12 @@ public class BlogInvitationRequest extends InvitationRequest { private final String blogAuthorName; public BlogInvitationRequest(MessageId id, SessionId sessionId, - ContactId contactId, String blogAuthorName, String message, - boolean available, long time, boolean local, boolean sent, - boolean seen, boolean read) { + GroupId groupId, ContactId contactId, String blogAuthorName, + String message, boolean available, long time, boolean local, + boolean sent, boolean seen, boolean read) { - super(id, sessionId, contactId, message, available, time, local, sent, - seen, read); + super(id, sessionId, groupId, contactId, message, available, time, + local, sent, seen, read); this.blogAuthorName = blogAuthorName; } diff --git a/briar-api/src/org/briarproject/api/blogs/BlogInvitationResponse.java b/briar-api/src/org/briarproject/api/blogs/BlogInvitationResponse.java index e3e7cdf692c78197d81c214fcc3ef600e59522c5..523aeed2605f42e52f9c9154e6324a843116a70e 100644 --- a/briar-api/src/org/briarproject/api/blogs/BlogInvitationResponse.java +++ b/briar-api/src/org/briarproject/api/blogs/BlogInvitationResponse.java @@ -3,15 +3,17 @@ package org.briarproject.api.blogs; import org.briarproject.api.clients.SessionId; import org.briarproject.api.contact.ContactId; import org.briarproject.api.sharing.InvitationResponse; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; public class BlogInvitationResponse extends InvitationResponse { public BlogInvitationResponse(MessageId id, SessionId sessionId, - ContactId contactId, boolean accept, long time, boolean local, - boolean sent, boolean seen, boolean read) { + GroupId groupId, ContactId contactId, boolean accept, long time, + 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); } } diff --git a/briar-api/src/org/briarproject/api/clients/BaseMessageHeader.java b/briar-api/src/org/briarproject/api/clients/BaseMessageHeader.java index 852cf0b5dc39205a718685f8e975ccd51398dad0..fa8b6bc8609b7464eacd31e9204a8449a2f6c182 100644 --- a/briar-api/src/org/briarproject/api/clients/BaseMessageHeader.java +++ b/briar-api/src/org/briarproject/api/clients/BaseMessageHeader.java @@ -1,17 +1,20 @@ package org.briarproject.api.clients; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; public abstract class BaseMessageHeader { private final MessageId id; + private final GroupId groupId; private final long timestamp; private final boolean local, read, sent, seen; - public BaseMessageHeader(MessageId id, long timestamp, boolean local, - boolean read, boolean sent, boolean seen) { + public BaseMessageHeader(MessageId id, GroupId groupId, long timestamp, + boolean local, boolean read, boolean sent, boolean seen) { this.id = id; + this.groupId = groupId; this.timestamp = timestamp; this.local = local; this.read = read; @@ -23,6 +26,10 @@ public abstract class BaseMessageHeader { return id; } + public GroupId getGroupId() { + return groupId; + } + public long getTimestamp() { return timestamp; } @@ -42,4 +49,5 @@ public abstract class BaseMessageHeader { public boolean isSeen() { return seen; } + } diff --git a/briar-api/src/org/briarproject/api/forum/ForumInvitationRequest.java b/briar-api/src/org/briarproject/api/forum/ForumInvitationRequest.java index 7099bf37b2b64caf2b3ff7866e5e4471b3f46eb2..3e90116c0b63554169b2dbc382b4fb8367c13461 100644 --- a/briar-api/src/org/briarproject/api/forum/ForumInvitationRequest.java +++ b/briar-api/src/org/briarproject/api/forum/ForumInvitationRequest.java @@ -3,6 +3,7 @@ package org.briarproject.api.forum; import org.briarproject.api.clients.SessionId; import org.briarproject.api.contact.ContactId; import org.briarproject.api.sharing.InvitationRequest; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; import org.jetbrains.annotations.Nullable; @@ -10,13 +11,13 @@ public class ForumInvitationRequest extends InvitationRequest { private final String forumName; - public ForumInvitationRequest(@Nullable MessageId id, SessionId sessionId, - ContactId contactId, String forumName, String message, + public ForumInvitationRequest(MessageId id, SessionId sessionId, + GroupId groupId, ContactId contactId, String forumName, String message, boolean available, long time, boolean local, boolean sent, boolean seen, boolean read) { - super(id, sessionId, contactId, message, available, time, local, sent, - seen, read); + super(id, sessionId, groupId, contactId, message, available, time, + local, sent, seen, read); this.forumName = forumName; } diff --git a/briar-api/src/org/briarproject/api/forum/ForumInvitationResponse.java b/briar-api/src/org/briarproject/api/forum/ForumInvitationResponse.java index 1a76ccb65f963685988675b4631d793e4cb5076d..059c7d385bb185cd3248a7a2b02f7e29eeb4e920 100644 --- a/briar-api/src/org/briarproject/api/forum/ForumInvitationResponse.java +++ b/briar-api/src/org/briarproject/api/forum/ForumInvitationResponse.java @@ -3,16 +3,18 @@ package org.briarproject.api.forum; import org.briarproject.api.clients.SessionId; import org.briarproject.api.contact.ContactId; import org.briarproject.api.sharing.InvitationResponse; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; import org.jetbrains.annotations.Nullable; public class ForumInvitationResponse extends InvitationResponse { - public ForumInvitationResponse(@Nullable MessageId id, SessionId sessionId, - ContactId contactId, boolean accept, long time, boolean local, + public ForumInvitationResponse(MessageId id, SessionId sessionId, + GroupId groupId, ContactId contactId, boolean accept, long time, 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); } } diff --git a/briar-api/src/org/briarproject/api/introduction/IntroductionMessage.java b/briar-api/src/org/briarproject/api/introduction/IntroductionMessage.java index 7ddf97aeadae65c87ed6455f01bd87bd407e3bb4..e218e1d095ad263e1162f6921fdc2942f74c70ca 100644 --- a/briar-api/src/org/briarproject/api/introduction/IntroductionMessage.java +++ b/briar-api/src/org/briarproject/api/introduction/IntroductionMessage.java @@ -2,6 +2,7 @@ package org.briarproject.api.introduction; import org.briarproject.api.clients.SessionId; import org.briarproject.api.clients.BaseMessageHeader; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; 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; public IntroductionMessage(SessionId sessionId, MessageId messageId, - int role, long time, boolean local, boolean sent, boolean seen, - boolean read) { + GroupId groupId, int role, long time, boolean local, boolean sent, + boolean seen, boolean read) { - super(messageId, time, local, read, sent, seen); + super(messageId, groupId, time, local, read, sent, seen); this.sessionId = sessionId; this.messageId = messageId; this.role = role; diff --git a/briar-api/src/org/briarproject/api/introduction/IntroductionRequest.java b/briar-api/src/org/briarproject/api/introduction/IntroductionRequest.java index 912f8a3fba8ff0507e9618a55fbfe64cc07ab519..1942b7f3f7e227fb69fc76ef2d9c81611a605868 100644 --- a/briar-api/src/org/briarproject/api/introduction/IntroductionRequest.java +++ b/briar-api/src/org/briarproject/api/introduction/IntroductionRequest.java @@ -2,6 +2,7 @@ package org.briarproject.api.introduction; import org.briarproject.api.clients.SessionId; import org.briarproject.api.identity.AuthorId; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; public class IntroductionRequest extends IntroductionResponse { @@ -10,13 +11,13 @@ public class IntroductionRequest extends IntroductionResponse { private final boolean answered, exists, introducesOtherIdentity; public IntroductionRequest(SessionId sessionId, MessageId messageId, - int role, long time, boolean local, boolean sent, boolean seen, - boolean read, AuthorId authorId, String name, boolean accepted, - String message, boolean answered, boolean exists, + GroupId groupId, int role, long time, boolean local, boolean sent, + boolean seen, boolean read, AuthorId authorId, String name, + boolean accepted, String message, boolean answered, boolean exists, boolean introducesOtherIdentity) { - super(sessionId, messageId, role, time, local, sent, seen, read, - authorId, name, accepted); + super(sessionId, messageId, groupId, role, time, local, sent, seen, + read, authorId, name, accepted); this.message = message; this.answered = answered; diff --git a/briar-api/src/org/briarproject/api/introduction/IntroductionResponse.java b/briar-api/src/org/briarproject/api/introduction/IntroductionResponse.java index be4cb57072cabc32dcb2cfb7037c3de164a57a7a..c2423ce2e6b7d4ff4a62bfd7525284d48659a7d1 100644 --- a/briar-api/src/org/briarproject/api/introduction/IntroductionResponse.java +++ b/briar-api/src/org/briarproject/api/introduction/IntroductionResponse.java @@ -2,6 +2,7 @@ package org.briarproject.api.introduction; import org.briarproject.api.clients.SessionId; import org.briarproject.api.identity.AuthorId; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; public class IntroductionResponse extends IntroductionMessage { @@ -11,11 +12,12 @@ public class IntroductionResponse extends IntroductionMessage { private final boolean accepted; public IntroductionResponse(SessionId sessionId, MessageId messageId, - int role, long time, boolean local, boolean sent, boolean seen, - boolean read, AuthorId remoteAuthorId, String name, + GroupId groupId, int role, long time, boolean local, boolean sent, + boolean seen, boolean read, AuthorId remoteAuthorId, String name, 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.name = name; diff --git a/briar-api/src/org/briarproject/api/messaging/PrivateMessageHeader.java b/briar-api/src/org/briarproject/api/messaging/PrivateMessageHeader.java index e30a0ba636c91d0b4043201c61edd52202718df0..9fd76de6c8435c8030732219355a8c70d664aab7 100644 --- a/briar-api/src/org/briarproject/api/messaging/PrivateMessageHeader.java +++ b/briar-api/src/org/briarproject/api/messaging/PrivateMessageHeader.java @@ -1,17 +1,18 @@ package org.briarproject.api.messaging; import org.briarproject.api.clients.BaseMessageHeader; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; public class PrivateMessageHeader extends BaseMessageHeader { 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, boolean seen) { - super(id, timestamp, local, read, sent, seen); + super(id, groupId, timestamp, local, read, sent, seen); this.contentType = contentType; } diff --git a/briar-api/src/org/briarproject/api/sharing/InvitationMessage.java b/briar-api/src/org/briarproject/api/sharing/InvitationMessage.java index adc8d8932b38b84e19a355a2d4d384d9b8d308b3..d67d479cd8da421f8d82370aba062662e82b1565 100644 --- a/briar-api/src/org/briarproject/api/sharing/InvitationMessage.java +++ b/briar-api/src/org/briarproject/api/sharing/InvitationMessage.java @@ -1,8 +1,9 @@ package org.briarproject.api.sharing; +import org.briarproject.api.clients.BaseMessageHeader; import org.briarproject.api.clients.SessionId; import org.briarproject.api.contact.ContactId; -import org.briarproject.api.clients.BaseMessageHeader; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; public abstract class InvitationMessage extends BaseMessageHeader { @@ -10,11 +11,11 @@ public abstract class InvitationMessage extends BaseMessageHeader { private final SessionId sessionId; 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, boolean seen, boolean read) { - super(id, time, local, read, sent, seen); + super(id, groupId, time, local, read, sent, seen); this.sessionId = sessionId; this.contactId = contactId; } diff --git a/briar-api/src/org/briarproject/api/sharing/InvitationRequest.java b/briar-api/src/org/briarproject/api/sharing/InvitationRequest.java index 6fe51d88e9d3aebdaceeaf17417b23d88d87785c..203ca6ec608e7280f50270ed924bf43be8756589 100644 --- a/briar-api/src/org/briarproject/api/sharing/InvitationRequest.java +++ b/briar-api/src/org/briarproject/api/sharing/InvitationRequest.java @@ -2,6 +2,7 @@ package org.briarproject.api.sharing; import org.briarproject.api.clients.SessionId; import org.briarproject.api.contact.ContactId; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; import org.jetbrains.annotations.Nullable; @@ -10,12 +11,12 @@ public abstract class InvitationRequest extends InvitationMessage { private final String message; private final boolean available; - public InvitationRequest(MessageId id, SessionId sessionId, + public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId, ContactId contactId, String message, boolean available, long time, 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.message = message; this.available = available; } diff --git a/briar-api/src/org/briarproject/api/sharing/InvitationResponse.java b/briar-api/src/org/briarproject/api/sharing/InvitationResponse.java index cf4d53774e4efcadb1c4bbdedd1a2a299cf0097c..16a769398bad0060e789e51a35e84a2d2acb3bdb 100644 --- a/briar-api/src/org/briarproject/api/sharing/InvitationResponse.java +++ b/briar-api/src/org/briarproject/api/sharing/InvitationResponse.java @@ -2,6 +2,7 @@ package org.briarproject.api.sharing; import org.briarproject.api.clients.SessionId; import org.briarproject.api.contact.ContactId; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; public abstract class InvitationResponse extends InvitationMessage { @@ -9,10 +10,10 @@ public abstract class InvitationResponse extends InvitationMessage { private final boolean accept; public InvitationResponse(MessageId id, SessionId sessionId, - ContactId contactId, boolean accept, long time, boolean local, - boolean sent, boolean seen, boolean read) { + GroupId groupId, ContactId contactId, boolean accept, long time, + 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; } diff --git a/briar-core/src/org/briarproject/introduction/IntroduceeEngine.java b/briar-core/src/org/briarproject/introduction/IntroduceeEngine.java index 8f77539c79faee46489301b2fe982740ad089fa3..4115fe0c09e695096360b78c5f215f285cdf3384 100644 --- a/briar-core/src/org/briarproject/introduction/IntroduceeEngine.java +++ b/briar-core/src/org/briarproject/introduction/IntroduceeEngine.java @@ -12,6 +12,7 @@ import org.briarproject.api.introduction.IntroduceeAction; import org.briarproject.api.introduction.IntroduceeProtocolState; import org.briarproject.api.introduction.IntroductionRequest; import org.briarproject.api.clients.SessionId; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; import java.util.ArrayList; @@ -343,6 +344,7 @@ public class IntroduceeEngine SessionId sessionId = new SessionId(localState.getRaw(SESSION_ID)); MessageId messageId = new MessageId(msg.getRaw(MESSAGE_ID)); + GroupId groupId = new GroupId(msg.getRaw(GROUP_ID)); long time = msg.getLong(MESSAGE_TIME); String name = msg.getString(NAME); String message = msg.getOptionalString(MSG); @@ -351,8 +353,9 @@ public class IntroduceeEngine localState.getBoolean(REMOTE_AUTHOR_IS_US); IntroductionRequest ir = new IntroductionRequest(sessionId, messageId, - ROLE_INTRODUCEE, time, false, false, false, false, authorId, - name, false, message, false, exists, introducesOtherIdentity); + groupId, ROLE_INTRODUCEE, time, false, false, false, false, + authorId, name, false, message, false, exists, + introducesOtherIdentity); return new IntroductionRequestReceivedEvent(contactId, ir); } diff --git a/briar-core/src/org/briarproject/introduction/IntroducerEngine.java b/briar-core/src/org/briarproject/introduction/IntroducerEngine.java index a431fd7e46d9040696c97abd99b815341d03ee98..0f180a622f01eea69da8f3c7aa0cb0775a3e6bd6 100644 --- a/briar-core/src/org/briarproject/introduction/IntroducerEngine.java +++ b/briar-core/src/org/briarproject/introduction/IntroducerEngine.java @@ -12,6 +12,7 @@ import org.briarproject.api.introduction.IntroducerAction; import org.briarproject.api.introduction.IntroducerProtocolState; import org.briarproject.api.introduction.IntroductionResponse; import org.briarproject.api.clients.SessionId; +import org.briarproject.api.sync.GroupId; import org.briarproject.api.sync.MessageId; import java.util.ArrayList; @@ -298,14 +299,15 @@ public class IntroducerEngine SessionId sessionId = new SessionId(localState.getRaw(SESSION_ID)); MessageId messageId = new MessageId(msg.getRaw(MESSAGE_ID)); + GroupId groupId = new GroupId(msg.getRaw(GROUP_ID)); long time = msg.getLong(MESSAGE_TIME); String name = getOtherContact(localState, msg); boolean accept = msg.getBoolean(ACCEPT); IntroductionResponse ir = - new IntroductionResponse(sessionId, messageId, ROLE_INTRODUCER, - time, false, false, false, false, authorId, name, - accept); + new IntroductionResponse(sessionId, messageId, groupId, + ROLE_INTRODUCER, time, false, false, false, false, + authorId, name, accept); return new IntroductionResponseReceivedEvent(contactId, ir); } diff --git a/briar-core/src/org/briarproject/introduction/IntroductionManagerImpl.java b/briar-core/src/org/briarproject/introduction/IntroductionManagerImpl.java index 6c44e83e6bbf60d403a431bf59194c592b8f6ca3..e44472f8c711ace3ab60dc7099c803c4d8d352f9 100644 --- a/briar-core/src/org/briarproject/introduction/IntroductionManagerImpl.java +++ b/briar-core/src/org/briarproject/introduction/IntroductionManagerImpl.java @@ -415,7 +415,7 @@ class IntroductionManagerImpl extends BdfIncomingMessageHook name = state.getString(NAME); } IntroductionResponse ir = new IntroductionResponse( - sessionId, messageId, role, time, local, + sessionId, messageId, g, role, time, local, s.isSent(), s.isSeen(), read, authorId, name, accepted); list.add(ir); @@ -445,7 +445,7 @@ class IntroductionManagerImpl extends BdfIncomingMessageHook state.getBoolean(REMOTE_AUTHOR_IS_US); } IntroductionRequest ir = new IntroductionRequest( - sessionId, messageId, role, time, local, + sessionId, messageId, g, role, time, local, s.isSent(), s.isSeen(), read, authorId, name, accepted, message, answered, exists, introducesOtherIdentity); diff --git a/briar-core/src/org/briarproject/messaging/MessagingManagerImpl.java b/briar-core/src/org/briarproject/messaging/MessagingManagerImpl.java index d5bc6db1d374b6d70c9a9ecbc17fb8d867bca709..9e2918d0fa8143ccd3d0c00407ca02596c446672 100644 --- a/briar-core/src/org/briarproject/messaging/MessagingManagerImpl.java +++ b/briar-core/src/org/briarproject/messaging/MessagingManagerImpl.java @@ -101,7 +101,8 @@ class MessagingManagerImpl extends BdfIncomingMessageHook boolean local = meta.getBoolean("local"); boolean read = meta.getBoolean(MSG_KEY_READ); 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( header, groupId); txn.attach(event); @@ -159,9 +160,10 @@ class MessagingManagerImpl extends BdfIncomingMessageHook throws DbException { Map<MessageId, BdfDictionary> metadata; Collection<MessageStatus> statuses; + GroupId g; Transaction txn = db.startTransaction(true); try { - GroupId g = getContactGroup(db.getContact(txn, c)).getId(); + g = getContactGroup(db.getContact(txn, c)).getId(); metadata = clientHelper.getMessageMetadataAsDictionary(txn, g); statuses = db.getMessageStatus(txn, c, g); txn.setComplete(); @@ -181,8 +183,8 @@ class MessagingManagerImpl extends BdfIncomingMessageHook String contentType = meta.getString("contentType"); boolean local = meta.getBoolean("local"); boolean read = meta.getBoolean("read"); - headers.add(new PrivateMessageHeader(id, timestamp, contentType, - local, read, s.isSent(), s.isSeen())); + headers.add(new PrivateMessageHeader(id, g, timestamp, + contentType, local, read, s.isSent(), s.isSeen())); } catch (FormatException e) { throw new DbException(e); } diff --git a/briar-core/src/org/briarproject/sharing/BlogSharingManagerImpl.java b/briar-core/src/org/briarproject/sharing/BlogSharingManagerImpl.java index a596bcb2c379250528b567ad4a98327e26734a0d..eb492cc610b6f9ba771cac28dc081921f830a93e 100644 --- a/briar-core/src/org/briarproject/sharing/BlogSharingManagerImpl.java +++ b/briar-core/src/org/briarproject/sharing/BlogSharingManagerImpl.java @@ -109,17 +109,18 @@ class BlogSharingManagerImpl extends BlogInvitation msg, ContactId contactId, boolean available, long time, boolean local, boolean sent, boolean seen, boolean read) { - return new BlogInvitationRequest(id, msg.getSessionId(), contactId, - msg.getBlogAuthorName(), msg.getMessage(), available, time, - local, sent, seen, read); + return new BlogInvitationRequest(id, msg.getSessionId(), + msg.getGroupId(), contactId, msg.getBlogAuthorName(), + msg.getMessage(), available, time, local, sent, seen, read); } @Override 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) { - return new BlogInvitationResponse(id, sessionId, contactId, accept, - time, local, sent, seen, read); + return new BlogInvitationResponse(id, sessionId, groupId, contactId, + accept, time, local, sent, seen, read); } @Override @@ -321,9 +322,9 @@ class BlogSharingManagerImpl extends ContactId contactId = localState.getContactId(); BlogInvitationRequest request = new BlogInvitationRequest(localState.getInvitationId(), - localState.getSessionId(), contactId, - blog.getAuthor().getName(), msg, true, time, false, - false, false, false); + localState.getSessionId(), localState.getGroupId(), + contactId, blog.getAuthor().getName(), msg, true, + time, false, false, false, false); return new BlogInvitationReceivedEvent(blog, contactId, request); } } @@ -337,7 +338,7 @@ class BlogSharingManagerImpl extends ContactId c = localState.getContactId(); BlogInvitationResponse response = new BlogInvitationResponse(localState.getResponseId(), - localState.getSessionId(), + localState.getSessionId(), localState.getGroupId(), localState.getContactId(), accept, time, false, false, false, false); return new BlogInvitationResponseReceivedEvent(title, c, response); diff --git a/briar-core/src/org/briarproject/sharing/ForumSharingManagerImpl.java b/briar-core/src/org/briarproject/sharing/ForumSharingManagerImpl.java index d0d4a9e8a304b4b56de23bdcc7b88af47aeedbd3..ab47bea6a29f49575c0de450d5679fcb974c9c0d 100644 --- a/briar-core/src/org/briarproject/sharing/ForumSharingManagerImpl.java +++ b/briar-core/src/org/briarproject/sharing/ForumSharingManagerImpl.java @@ -83,17 +83,18 @@ class ForumSharingManagerImpl extends ForumInvitation msg, ContactId contactId, boolean available, long time, boolean local, boolean sent, boolean seen, boolean read) { - return new ForumInvitationRequest(id, msg.getSessionId(), contactId, - msg.getForumName(), msg.getMessage(), available, time, local, - sent, seen, read); + return new ForumInvitationRequest(id, msg.getSessionId(), + msg.getGroupId(), contactId, msg.getForumName(), + msg.getMessage(), available, time, local, sent, seen, read); } @Override protected InvitationMessage createInvitationResponse(MessageId id, - SessionId sessionId, ContactId contactId, boolean accept, - long time, boolean local, boolean sent, boolean seen, boolean read) { - return new ForumInvitationResponse(id, sessionId, contactId, accept, - time, local, sent, seen, read); + SessionId sessionId, GroupId groupId, ContactId contactId, + boolean accept, long time, boolean local, boolean sent, + boolean seen, boolean read) { + return new ForumInvitationResponse(id, sessionId, groupId, contactId, + accept, time, local, sent, seen, read); } @Override @@ -268,8 +269,8 @@ class ForumSharingManagerImpl extends ContactId contactId = localState.getContactId(); ForumInvitationRequest request = new ForumInvitationRequest( localState.getInvitationId(), localState.getSessionId(), - contactId, forum.getName(), msg, true, time, false, false, - false, false); + localState.getGroupId(), contactId, forum.getName(), msg, + true, time, false, false, false, false); return new ForumInvitationReceivedEvent(forum, contactId, request); } } @@ -282,9 +283,9 @@ class ForumSharingManagerImpl extends String name = localState.getForumName(); ContactId c = localState.getContactId(); ForumInvitationResponse response = new ForumInvitationResponse( - localState.getResponseId(), - localState.getSessionId(), localState.getContactId(), - accept, time, false, false, false, false); + localState.getResponseId(), localState.getSessionId(), + localState.getGroupId(), localState.getContactId(), accept, + time, false, false, false, false); return new ForumInvitationResponseReceivedEvent(name, c, response); } } diff --git a/briar-core/src/org/briarproject/sharing/SharingManagerImpl.java b/briar-core/src/org/briarproject/sharing/SharingManagerImpl.java index f0a88ff5fa3dfe2ec867c13a05e76e8649ba1726..a8d6fde681741176f7c04d4ffdd0fd18aec3ce56 100644 --- a/briar-core/src/org/briarproject/sharing/SharingManagerImpl.java +++ b/briar-core/src/org/briarproject/sharing/SharingManagerImpl.java @@ -117,13 +117,14 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS public abstract ClientId getClientId(); - protected abstract InvitationMessage createInvitationRequest(MessageId id, I msg, - ContactId contactId, boolean available, long time, boolean local, - boolean sent, boolean seen, boolean read); + protected abstract InvitationMessage createInvitationRequest(MessageId id, + I msg, ContactId contactId, boolean available, long time, + boolean local, boolean sent, boolean seen, boolean read); protected abstract InvitationMessage createInvitationResponse(MessageId id, - SessionId sessionId, ContactId contactId, boolean accept, long time, - boolean local, boolean sent, boolean seen, boolean read); + SessionId sessionId, GroupId groupId, ContactId contactId, + boolean accept, long time, boolean local, boolean sent, + boolean seen, boolean read); 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); SessionId sessionId = msg.getSessionId(); InvitationMessage im = createInvitationResponse( - m.getKey(), sessionId, contactId, accept, time, - local, status.isSent(), status.isSeen(), read); + m.getKey(), sessionId, group.getId(), contactId, + accept, time, local, status.isSent(), + status.isSeen(), read); list.add(im); } else {