Show open button in private conversation after accepting invitations

This commit is contained in:
Torsten Grote
2016-12-13 10:28:25 -02:00
parent d63d15329c
commit 2ef9b8f4b6
23 changed files with 180 additions and 101 deletions

View File

@@ -49,8 +49,11 @@ import org.briarproject.bramble.util.StringUtils;
import org.briarproject.briar.R; import org.briarproject.briar.R;
import org.briarproject.briar.android.activity.ActivityComponent; import org.briarproject.briar.android.activity.ActivityComponent;
import org.briarproject.briar.android.activity.BriarActivity; import org.briarproject.briar.android.activity.BriarActivity;
import org.briarproject.briar.android.blog.BlogActivity;
import org.briarproject.briar.android.contact.ConversationAdapter.ConversationListener; import org.briarproject.briar.android.contact.ConversationAdapter.ConversationListener;
import org.briarproject.briar.android.forum.ForumActivity;
import org.briarproject.briar.android.introduction.IntroductionActivity; import org.briarproject.briar.android.introduction.IntroductionActivity;
import org.briarproject.briar.android.privategroup.conversation.GroupActivity;
import org.briarproject.briar.android.view.BriarRecyclerView; import org.briarproject.briar.android.view.BriarRecyclerView;
import org.briarproject.briar.android.view.TextInputView; import org.briarproject.briar.android.view.TextInputView;
import org.briarproject.briar.android.view.TextInputView.TextInputListener; import org.briarproject.briar.android.view.TextInputView.TextInputListener;
@@ -850,6 +853,28 @@ public class ConversationActivity extends BriarActivity
}); });
} }
@UiThread
@Override
public void open(ConversationRequestItem item) {
if (item.getRequestedGroupId() == null) return;
Intent i;
switch (item.getRequestType()) {
case FORUM:
i = new Intent(this, ForumActivity.class);
break;
case BLOG:
i = new Intent(this, BlogActivity.class);
break;
case GROUP:
i = new Intent(this, GroupActivity.class);
break;
default:
throw new IllegalArgumentException("Unknown Request Type");
}
i.putExtra(GROUP_ID, item.getRequestedGroupId().getBytes());
startActivity(i);
}
@DatabaseExecutor @DatabaseExecutor
private void respondToIntroductionRequest(SessionId sessionId, private void respondToIntroductionRequest(SessionId sessionId,
boolean accept, long time) throws DbException, FormatException { boolean accept, long time) throws DbException, FormatException {

View File

@@ -139,6 +139,9 @@ class ConversationAdapter
void onItemVisible(ConversationItem item); void onItemVisible(ConversationItem item);
void respondToRequest(ConversationRequestItem item, boolean accept); void respondToRequest(ConversationRequestItem item, boolean accept);
void open(ConversationRequestItem item);
} }
} }

View File

@@ -101,9 +101,6 @@ abstract class ConversationItem {
text = ctx.getString( text = ctx.getString(
R.string.introduction_request_answered_received, R.string.introduction_request_answered_received,
contactName, ir.getName()); contactName, ir.getName());
return new ConversationNoticeInItem(ir.getMessageId(),
ir.getGroupId(), text, ir.getMessage(), ir.getTimestamp(),
ir.isRead());
} else if (ir.contactExists()){ } else if (ir.contactExists()){
text = ctx.getString( text = ctx.getString(
R.string.introduction_request_exists_received, R.string.introduction_request_exists_received,
@@ -114,7 +111,7 @@ abstract class ConversationItem {
} }
return new ConversationRequestItem(ir.getMessageId(), return new ConversationRequestItem(ir.getMessageId(),
ir.getGroupId(), INTRODUCTION, ir.getSessionId(), text, ir.getGroupId(), INTRODUCTION, ir.getSessionId(), text,
ir.getMessage(), ir.getTimestamp(), ir.isRead(), ir.getMessage(), ir.getTimestamp(), ir.isRead(), null,
ir.wasAnswered()); ir.wasAnswered());
} }
} }
@@ -203,14 +200,10 @@ abstract class ConversationItem {
} else { } else {
throw new IllegalArgumentException("Unknown InvitationRequest"); throw new IllegalArgumentException("Unknown InvitationRequest");
} }
if (!ir.isAvailable()) {
return new ConversationNoticeInItem(ir.getId(), ir.getGroupId(),
text, ir.getMessage(), ir.getTimestamp(), ir.isRead());
}
return new ConversationRequestItem(ir.getId(), return new ConversationRequestItem(ir.getId(),
ir.getGroupId(), type, ir.getSessionId(), text, ir.getGroupId(), type, ir.getSessionId(), text,
ir.getMessage(), ir.getTimestamp(), ir.isRead(), ir.getMessage(), ir.getTimestamp(), ir.isRead(),
!ir.isAvailable()); ir.getInvitedGroupId(), !ir.isAvailable());
} }
} }

View File

@@ -17,6 +17,8 @@ class ConversationRequestItem extends ConversationNoticeInItem {
enum RequestType { INTRODUCTION, FORUM, BLOG, GROUP } enum RequestType { INTRODUCTION, FORUM, BLOG, GROUP }
@Nullable
private final GroupId requestedGroupId;
private final RequestType requestType; private final RequestType requestType;
private final SessionId sessionId; private final SessionId sessionId;
private boolean answered; private boolean answered;
@@ -24,10 +26,11 @@ class ConversationRequestItem extends ConversationNoticeInItem {
ConversationRequestItem(MessageId id, GroupId groupId, ConversationRequestItem(MessageId id, GroupId groupId,
RequestType requestType, SessionId sessionId, String text, RequestType requestType, SessionId sessionId, String text,
@Nullable String msgText, long time, boolean read, @Nullable String msgText, long time, boolean read,
boolean answered) { @Nullable GroupId requestedGroupId, boolean answered) {
super(id, groupId, text, msgText, time, read); super(id, groupId, text, msgText, time, read);
this.requestType = requestType; this.requestType = requestType;
this.sessionId = sessionId; this.sessionId = sessionId;
this.requestedGroupId = requestedGroupId;
this.answered = answered; this.answered = answered;
} }
@@ -39,6 +42,11 @@ class ConversationRequestItem extends ConversationNoticeInItem {
return sessionId; return sessionId;
} }
@Nullable
public GroupId getRequestedGroupId() {
return requestedGroupId;
}
boolean wasAnswered() { boolean wasAnswered() {
return answered; return answered;
} }

View File

@@ -11,6 +11,7 @@ import org.briarproject.briar.android.contact.ConversationAdapter.ConversationLi
import static android.view.View.GONE; import static android.view.View.GONE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.INTRODUCTION;
@UiThread @UiThread
@NotNullByDefault @NotNullByDefault
@@ -32,11 +33,23 @@ class ConversationRequestViewHolder extends ConversationNoticeInViewHolder {
final ConversationRequestItem item = final ConversationRequestItem item =
(ConversationRequestItem) conversationItem; (ConversationRequestItem) conversationItem;
if (item.wasAnswered()) { if (item.getRequestType() == INTRODUCTION && item.wasAnswered()) {
acceptButton.setVisibility(GONE); acceptButton.setVisibility(GONE);
declineButton.setVisibility(GONE); declineButton.setVisibility(GONE);
} else if (item.wasAnswered()) {
acceptButton.setVisibility(VISIBLE);
acceptButton.setText(R.string.open);
acceptButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
item.setAnswered(true);
listener.open(item);
}
});
declineButton.setVisibility(GONE);
} else { } else {
acceptButton.setVisibility(VISIBLE); acceptButton.setVisibility(VISIBLE);
acceptButton.setText(R.string.accept);
acceptButton.setOnClickListener(new OnClickListener() { acceptButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@@ -43,7 +43,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignEnd="@+id/text" android:layout_alignEnd="@+id/text"
android:layout_alignRight="@+id/text" android:layout_alignRight="@+id/text"
android:layout_below="@+id/declineButton" android:layout_below="@+id/acceptButton"
android:layout_marginTop="@dimen/message_bubble_timestamp_margin" android:layout_marginTop="@dimen/message_bubble_timestamp_margin"
android:textColor="@color/private_message_date" android:textColor="@color/private_message_date"
android:textSize="@dimen/text_size_tiny" android:textSize="@dimen/text_size_tiny"
@@ -57,6 +57,7 @@
android:layout_alignEnd="@+id/text" android:layout_alignEnd="@+id/text"
android:layout_alignRight="@+id/text" android:layout_alignRight="@+id/text"
android:layout_below="@+id/text" android:layout_below="@+id/text"
android:layout_marginBottom="-10dp"
android:text="@string/accept"/> android:text="@string/accept"/>
<Button <Button
@@ -64,8 +65,8 @@
style="@style/BriarButtonFlat.Negative" style="@style/BriarButtonFlat.Negative"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/text" android:layout_alignBottom="@+id/acceptButton"
android:layout_marginBottom="-15dp" android:layout_alignTop="@+id/acceptButton"
android:layout_toLeftOf="@+id/acceptButton" android:layout_toLeftOf="@+id/acceptButton"
android:layout_toStartOf="@+id/acceptButton" android:layout_toStartOf="@+id/acceptButton"
android:text="@string/decline"/> android:text="@string/decline"/>

View File

@@ -77,6 +77,7 @@
<string name="offline">Offline</string> <string name="offline">Offline</string>
<string name="send">Send</string> <string name="send">Send</string>
<string name="allow">Allow</string> <string name="allow">Allow</string>
<string name="open">Open</string>
<string name="no_data">No data</string> <string name="no_data">No data</string>
<string name="ellipsis"></string> <string name="ellipsis"></string>
<string name="text_too_long">The entered text is too long</string> <string name="text_too_long">The entered text is too long</string>
@@ -182,8 +183,8 @@
<!-- Private Group Invitations --> <!-- Private Group Invitations -->
<string name="groups_invitations_title">Group Invitations</string> <string name="groups_invitations_title">Group Invitations</string>
<string name="groups_invitations_invitation_sent">You have invited %1$s to join the group "%2$s".</string> <string name="groups_invitations_invitation_sent">You have invited %1$s to join the group \"%2$s\".</string>
<string name="groups_invitations_invitation_received">%1$s has invited you to join the group "%2$s".</string> <string name="groups_invitations_invitation_received">%1$s has invited you to join the group \"%2$s\".</string>
<string name="groups_invitations_joined">Joined group</string> <string name="groups_invitations_joined">Joined group</string>
<string name="groups_invitations_declined">Group invitation declined</string> <string name="groups_invitations_declined">Group invitation declined</string>
<plurals name="groups_invitations_open"> <plurals name="groups_invitations_open">

View File

@@ -37,13 +37,11 @@
<style name="BriarButtonFlat.Negative" parent="Widget.AppCompat.Button.Borderless"> <style name="BriarButtonFlat.Negative" parent="Widget.AppCompat.Button.Borderless">
<item name="android:textColor">@color/briar_button_negative</item> <item name="android:textColor">@color/briar_button_negative</item>
<item name="android:textSize">@dimen/text_size_medium</item> <item name="android:textSize">@dimen/text_size_medium</item>
<item name="android:padding">@dimen/margin_large</item>
</style> </style>
<style name="BriarButtonFlat.Positive" parent="Widget.AppCompat.Button.Borderless"> <style name="BriarButtonFlat.Positive" parent="Widget.AppCompat.Button.Borderless">
<item name="android:textColor">@color/briar_button_positive</item> <item name="android:textColor">@color/briar_button_positive</item>
<item name="android:textSize">@dimen/text_size_medium</item> <item name="android:textSize">@dimen/text_size_medium</item>
<item name="android:padding">@dimen/margin_large</item>
</style> </style>
<style name="BriarButtonFlat.Positive.Tiny" parent="BriarButtonFlat.Positive"> <style name="BriarButtonFlat.Positive.Tiny" parent="BriarButtonFlat.Positive">

View File

@@ -16,11 +16,12 @@ public class BlogInvitationRequest extends InvitationRequest {
public BlogInvitationRequest(MessageId id, SessionId sessionId, public BlogInvitationRequest(MessageId id, SessionId sessionId,
GroupId groupId, ContactId contactId, String blogAuthorName, GroupId groupId, ContactId contactId, String blogAuthorName,
@Nullable String message, boolean available, long time, @Nullable String message, @Nullable GroupId blogId,
boolean local, boolean sent, boolean seen, boolean read) { boolean available, long time, boolean local, boolean sent,
boolean seen, boolean read) {
super(id, sessionId, groupId, contactId, message, available, time, super(id, sessionId, groupId, contactId, message, blogId, available,
local, sent, seen, read); time, local, sent, seen, read);
this.blogAuthorName = blogAuthorName; this.blogAuthorName = blogAuthorName;
} }

View File

@@ -11,11 +11,12 @@ import org.briarproject.briar.api.sharing.InvitationResponse;
public class BlogInvitationResponse extends InvitationResponse { public class BlogInvitationResponse extends InvitationResponse {
public BlogInvitationResponse(MessageId id, SessionId sessionId, public BlogInvitationResponse(MessageId id, SessionId sessionId,
GroupId groupId, ContactId contactId, boolean accept, long time, GroupId groupId, ContactId contactId, GroupId blogId,
boolean local, boolean sent, boolean seen, boolean read) { boolean accept, long time, boolean local, boolean sent,
boolean seen, boolean read) {
super(id, sessionId, groupId, contactId, accept, time, local, sent, super(id, sessionId, groupId, contactId, blogId, accept, time, local,
seen, read); sent, seen, read);
} }
} }

View File

@@ -17,12 +17,13 @@ public class ForumInvitationRequest extends InvitationRequest {
private final String forumName; private final String forumName;
public ForumInvitationRequest(MessageId id, SessionId sessionId, public ForumInvitationRequest(MessageId id, SessionId sessionId,
GroupId groupId, ContactId contactId, String forumName, GroupId groupId, ContactId contactId, GroupId forumId,
@Nullable String message, boolean available, long time, String forumName, @Nullable String message, boolean available,
boolean local, boolean sent, boolean seen, boolean read) { long time, boolean local, boolean sent, boolean seen,
boolean read) {
super(id, sessionId, groupId, contactId, message, available, time, super(id, sessionId, groupId, contactId, message, forumId, available,
local, sent, seen, read); time, local, sent, seen, read);
this.forumName = forumName; this.forumName = forumName;
} }

View File

@@ -14,11 +14,12 @@ import javax.annotation.concurrent.Immutable;
public class ForumInvitationResponse extends InvitationResponse { public class ForumInvitationResponse extends InvitationResponse {
public ForumInvitationResponse(MessageId id, SessionId sessionId, public ForumInvitationResponse(MessageId id, SessionId sessionId,
GroupId groupId, ContactId contactId, boolean accept, long time, GroupId groupId, ContactId contactId, GroupId forumId,
boolean local, boolean sent, boolean seen, boolean read) { boolean accept, long time, boolean local, boolean sent,
boolean seen, boolean read) {
super(id, sessionId, groupId, contactId, accept, time, local, sent, super(id, sessionId, groupId, contactId, forumId, accept, time, local,
seen, read); sent, seen, read);
} }
} }

View File

@@ -20,10 +20,11 @@ public class GroupInvitationRequest extends InvitationRequest {
public GroupInvitationRequest(MessageId id, SessionId sessionId, public GroupInvitationRequest(MessageId id, SessionId sessionId,
GroupId groupId, ContactId contactId, @Nullable String message, GroupId groupId, ContactId contactId, @Nullable String message,
String groupName, Author creator, boolean available, long time, GroupId privateGroupId, String groupName, Author creator,
boolean local, boolean sent, boolean seen, boolean read) { boolean available, long time, boolean local, boolean sent,
super(id, sessionId, groupId, contactId, message, available, time, boolean seen, boolean read) {
local, sent, seen, read); super(id, sessionId, groupId, contactId, message, privateGroupId,
available, time, local, sent, seen, read);
this.groupName = groupName; this.groupName = groupName;
this.creator = creator; this.creator = creator;
} }

View File

@@ -14,9 +14,10 @@ import javax.annotation.concurrent.Immutable;
public class GroupInvitationResponse extends InvitationResponse { public class GroupInvitationResponse extends InvitationResponse {
public GroupInvitationResponse(MessageId id, SessionId sessionId, public GroupInvitationResponse(MessageId id, SessionId sessionId,
GroupId groupId, ContactId contactId, boolean accept, long time, GroupId groupId, ContactId contactId, GroupId privateGroupId,
boolean local, boolean sent, boolean seen, boolean read) { boolean accept, long time, boolean local, boolean sent,
super(id, sessionId, groupId, contactId, accept, time, local, sent, boolean seen, boolean read) {
seen, read); super(id, sessionId, groupId, contactId, privateGroupId, accept, time,
local, sent, seen, read);
} }
} }

View File

@@ -7,6 +7,7 @@ import org.briarproject.bramble.api.sync.MessageId;
import org.briarproject.briar.api.client.BaseMessageHeader; import org.briarproject.briar.api.client.BaseMessageHeader;
import org.briarproject.briar.api.client.SessionId; import org.briarproject.briar.api.client.SessionId;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
@@ -15,14 +16,17 @@ public abstract class InvitationMessage extends BaseMessageHeader {
private final SessionId sessionId; private final SessionId sessionId;
private final ContactId contactId; private final ContactId contactId;
@Nullable
private final GroupId invitedGroupId;
public InvitationMessage(MessageId id, SessionId sessionId, GroupId groupId, public InvitationMessage(MessageId id, SessionId sessionId, GroupId groupId,
ContactId contactId, long time, boolean local, boolean sent, ContactId contactId, @Nullable GroupId invitedGroupId, long time,
boolean seen, boolean read) { boolean local, boolean sent, boolean seen, boolean read) {
super(id, groupId, 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;
this.invitedGroupId = invitedGroupId;
} }
public SessionId getSessionId() { public SessionId getSessionId() {
@@ -33,4 +37,9 @@ public abstract class InvitationMessage extends BaseMessageHeader {
return contactId; return contactId;
} }
@Nullable
public GroupId getInvitedGroupId() {
return invitedGroupId;
}
} }

View File

@@ -18,11 +18,12 @@ public abstract class InvitationRequest extends InvitationMessage {
private final boolean available; private final boolean available;
public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId, public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId,
ContactId contactId, @Nullable String message, boolean available, ContactId contactId, @Nullable String message,
long time, boolean local, boolean sent, boolean seen, @Nullable GroupId invitedGroupId, boolean available, long time,
boolean read) { boolean local, boolean sent, boolean seen, boolean read) {
super(id, sessionId, groupId, contactId, time, local, sent, seen, read); super(id, sessionId, groupId, contactId, invitedGroupId, time, local,
sent, seen, read);
this.message = message; this.message = message;
this.available = available; this.available = available;
} }

View File

@@ -6,6 +6,7 @@ import org.briarproject.bramble.api.sync.GroupId;
import org.briarproject.bramble.api.sync.MessageId; import org.briarproject.bramble.api.sync.MessageId;
import org.briarproject.briar.api.client.SessionId; import org.briarproject.briar.api.client.SessionId;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
@Immutable @Immutable
@@ -15,10 +16,12 @@ 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,
GroupId groupId, ContactId contactId, boolean accept, long time, GroupId groupId, ContactId contactId,
@Nullable GroupId invitedGroupId, boolean accept, long time,
boolean local, boolean sent, boolean seen, boolean read) { boolean local, boolean sent, boolean seen, boolean read) {
super(id, sessionId, groupId, contactId, time, local, sent, seen, read); super(id, sessionId, groupId, contactId, invitedGroupId, time, local,
sent, seen, read);
this.accept = accept; this.accept = accept;
} }

View File

@@ -255,7 +255,7 @@ class CreatorProtocolEngine extends AbstractProtocolEngine<CreatorSession> {
GroupInvitationMessage m, ContactId c, boolean accept) { GroupInvitationMessage m, ContactId c, boolean accept) {
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes()); SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
return new GroupInvitationResponse(m.getId(), sessionId, return new GroupInvitationResponse(m.getId(), sessionId,
m.getPrivateGroupId(), c, accept, m.getTimestamp(), false, m.getContactGroupId(), c, m.getPrivateGroupId(), accept,
false, true, false); m.getTimestamp(), false, false, true, false);
} }
} }

View File

@@ -381,10 +381,12 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
m, meta, status)); m, meta, status));
} else if (type == JOIN) { } else if (type == JOIN) {
messages.add( messages.add(
parseInvitationResponse(c, m, meta, status, true)); parseInvitationResponse(c, contactGroupId, m, meta,
status, true));
} else if (type == LEAVE) { } else if (type == LEAVE) {
messages.add( messages.add(
parseInvitationResponse(c, m, meta, status, false)); parseInvitationResponse(c, contactGroupId, m, meta,
status, false));
} }
} }
db.commitTransaction(txn); db.commitTransaction(txn);
@@ -404,7 +406,8 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
// Look up the invite message to get the details of the private group // Look up the invite message to get the details of the private group
InviteMessage invite = getInviteMessage(txn, m); InviteMessage invite = getInviteMessage(txn, m);
return new GroupInvitationRequest(m, sessionId, contactGroupId, c, return new GroupInvitationRequest(m, sessionId, contactGroupId, c,
invite.getMessage(), invite.getGroupName(), invite.getCreator(), invite.getMessage(), invite.getPrivateGroupId(),
invite.getGroupName(), invite.getCreator(),
meta.isAvailableToAnswer(), meta.getTimestamp(), meta.isLocal(), meta.isAvailableToAnswer(), meta.getTimestamp(), meta.isLocal(),
status.isSent(), status.isSeen(), meta.isRead()); status.isSent(), status.isSeen(), meta.isRead());
} }
@@ -418,11 +421,12 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
} }
private GroupInvitationResponse parseInvitationResponse(ContactId c, private GroupInvitationResponse parseInvitationResponse(ContactId c,
MessageId m, MessageMetadata meta, MessageStatus status, GroupId contactGroupId, MessageId m, MessageMetadata meta,
boolean accept) throws DbException, FormatException { MessageStatus status, boolean accept)
throws DbException, FormatException {
SessionId sessionId = getSessionId(meta.getPrivateGroupId()); SessionId sessionId = getSessionId(meta.getPrivateGroupId());
return new GroupInvitationResponse(m, sessionId, return new GroupInvitationResponse(m, sessionId, contactGroupId, c,
meta.getPrivateGroupId(), c, accept, meta.getTimestamp(), meta.getPrivateGroupId(), accept, meta.getTimestamp(),
meta.isLocal(), status.isSent(), status.isSeen(), meta.isLocal(), status.isSent(), status.isSeen(),
meta.isRead()); meta.isRead());
} }

View File

@@ -318,8 +318,8 @@ class InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> {
ContactId c) { ContactId c) {
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes()); SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
return new GroupInvitationRequest(m.getId(), sessionId, return new GroupInvitationRequest(m.getId(), sessionId,
m.getContactGroupId(), c, m.getMessage(), m.getGroupName(), m.getContactGroupId(), c, m.getMessage(), m.getPrivateGroupId(),
m.getCreator(), true, m.getTimestamp(), false, false, true, m.getGroupName(), m.getCreator(), true, m.getTimestamp(), false,
false); false, true, false);
} }
} }

View File

@@ -40,6 +40,7 @@ import org.briarproject.briar.api.sharing.InvitationMessage;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.Collection; import java.util.Collection;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
import javax.inject.Inject; import javax.inject.Inject;
@@ -133,21 +134,23 @@ class BlogSharingManagerImpl extends
@Override @Override
protected InvitationMessage createInvitationRequest(MessageId id, protected InvitationMessage createInvitationRequest(MessageId id,
BlogInvitation msg, ContactId contactId, boolean available, BlogInvitation msg, ContactId contactId, GroupId blogId,
long time, boolean local, boolean sent, boolean seen, boolean available, long time, boolean local, boolean sent,
boolean read) { boolean seen, boolean read) {
return new BlogInvitationRequest(id, msg.getSessionId(), return new BlogInvitationRequest(id, msg.getSessionId(),
msg.getGroupId(), contactId, msg.getBlogAuthorName(), msg.getGroupId(), contactId, msg.getBlogAuthorName(),
msg.getMessage(), available, time, local, sent, seen, read); msg.getMessage(), blogId, available, time, local, sent, seen,
read);
} }
@Override @Override
protected InvitationMessage createInvitationResponse(MessageId id, protected InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, GroupId groupId, ContactId contactId, SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time, GroupId blogId, boolean accept, long time, boolean local,
boolean local, boolean sent, boolean seen, boolean read) { boolean sent, boolean seen, boolean read) {
return new BlogInvitationResponse(id, sessionId, groupId, contactId, return new BlogInvitationResponse(id, sessionId, groupId, contactId,
accept, time, local, sent, seen, read); blogId, accept, time, local, sent, seen, read);
} }
@Override @Override
@@ -333,14 +336,17 @@ class BlogSharingManagerImpl extends
@Override @Override
public BlogInvitationRequestReceivedEvent build( public BlogInvitationRequestReceivedEvent build(
BlogInviteeSessionState localState, long time, String msg) { BlogInviteeSessionState localState, long time,
@Nullable String msg) {
Blog blog = sFactory.parse(localState); Blog blog = sFactory.parse(localState);
ContactId contactId = localState.getContactId(); ContactId contactId = localState.getContactId();
BlogInvitationRequest request = BlogInvitationRequest request =
new BlogInvitationRequest(localState.getInvitationId(), new BlogInvitationRequest(localState.getInvitationId(),
localState.getSessionId(), localState.getContactGroupId(), localState.getSessionId(),
contactId, blog.getAuthor().getName(), msg, true, localState.getContactGroupId(), contactId,
time, false, false, false, false); blog.getAuthor().getName(), msg,
localState.getShareableId(), true, time, false,
false, false, false);
return new BlogInvitationRequestReceivedEvent(blog, contactId, return new BlogInvitationRequestReceivedEvent(blog, contactId,
request); request);
} }
@@ -358,8 +364,9 @@ class BlogSharingManagerImpl extends
BlogInvitationResponse response = BlogInvitationResponse response =
new BlogInvitationResponse(responseId, new BlogInvitationResponse(responseId,
localState.getSessionId(), localState.getSessionId(),
localState.getShareableId(), localState.getContactGroupId(),
localState.getContactId(), accept, time, false, localState.getContactId(),
localState.getShareableId(), accept, time, false,
false, false, false); false, false, false);
return new BlogInvitationResponseReceivedEvent(c, response); return new BlogInvitationResponseReceivedEvent(c, response);
} }

View File

@@ -33,6 +33,7 @@ import org.briarproject.briar.api.sharing.InvitationMessage;
import java.security.SecureRandom; import java.security.SecureRandom;
import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import static org.briarproject.briar.api.forum.ForumConstants.FORUM_NAME; import static org.briarproject.briar.api.forum.ForumConstants.FORUM_NAME;
@@ -81,21 +82,21 @@ class ForumSharingManagerImpl extends
@Override @Override
protected InvitationMessage createInvitationRequest(MessageId id, protected InvitationMessage createInvitationRequest(MessageId id,
ForumInvitation msg, ContactId contactId, boolean available, ForumInvitation msg, ContactId contactId, GroupId forumId,
long time, boolean local, boolean sent, boolean seen, boolean available, long time, boolean local, boolean sent,
boolean read) { boolean seen, boolean read) {
return new ForumInvitationRequest(id, msg.getSessionId(), return new ForumInvitationRequest(id, msg.getSessionId(),
msg.getGroupId(), contactId, msg.getForumName(), msg.getGroupId(), contactId, forumId, msg.getForumName(),
msg.getMessage(), available, time, 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, GroupId groupId, ContactId contactId, SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time, boolean local, boolean sent, GroupId forumId, boolean accept, long time, boolean local,
boolean seen, boolean read) { boolean sent, boolean seen, boolean read) {
return new ForumInvitationResponse(id, sessionId, groupId, contactId, return new ForumInvitationResponse(id, sessionId, groupId, contactId,
accept, time, local, sent, seen, read); forumId, accept, time, local, sent, seen, read);
} }
@Override @Override
@@ -263,13 +264,15 @@ class ForumSharingManagerImpl extends
@Override @Override
public ForumInvitationRequestReceivedEvent build( public ForumInvitationRequestReceivedEvent build(
ForumInviteeSessionState localState, long time, String msg) { ForumInviteeSessionState localState, long time,
@Nullable String msg) {
Forum forum = sFactory.parse(localState); Forum forum = sFactory.parse(localState);
ContactId contactId = localState.getContactId(); ContactId contactId = localState.getContactId();
ForumInvitationRequest request = new ForumInvitationRequest( ForumInvitationRequest request = new ForumInvitationRequest(
localState.getInvitationId(), localState.getSessionId(), localState.getInvitationId(), localState.getSessionId(),
localState.getContactGroupId(), contactId, forum.getName(), msg, localState.getContactGroupId(), contactId,
true, time, false, false, false, false); localState.getShareableId(), forum.getName(), msg, true,
time, false, false, false, false);
return new ForumInvitationRequestReceivedEvent(forum, contactId, return new ForumInvitationRequestReceivedEvent(forum, contactId,
request); request);
} }
@@ -287,8 +290,9 @@ class ForumSharingManagerImpl extends
throw new IllegalStateException("No responseId"); throw new IllegalStateException("No responseId");
ForumInvitationResponse response = new ForumInvitationResponse( ForumInvitationResponse response = new ForumInvitationResponse(
responseId, localState.getSessionId(), responseId, localState.getSessionId(),
localState.getShareableId(), localState.getContactId(), localState.getContactGroupId(), localState.getContactId(),
accept, time, false, false, false, false); localState.getShareableId(), accept, time, false, false,
false, false);
return new ForumInvitationResponseReceivedEvent(name, c, response); return new ForumInvitationResponseReceivedEvent(name, c, response);
} }
} }

View File

@@ -125,13 +125,13 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
protected abstract ClientId getClientId(); protected abstract ClientId getClientId();
protected abstract InvitationMessage createInvitationRequest(MessageId id, protected abstract InvitationMessage createInvitationRequest(MessageId id,
I msg, ContactId contactId, boolean available, long time, I msg, ContactId contactId, GroupId shareableId, boolean available,
boolean local, boolean sent, boolean seen, boolean read); long time, boolean local, boolean sent, boolean seen, boolean read);
protected abstract InvitationMessage createInvitationResponse(MessageId id, protected abstract InvitationMessage createInvitationResponse(MessageId id,
SessionId sessionId, GroupId groupId, ContactId contactId, SessionId sessionId, GroupId groupId, ContactId contactId,
boolean accept, long time, boolean local, boolean sent, GroupId shareableId, boolean accept, long time, boolean local,
boolean seen, boolean read); boolean sent, boolean seen, boolean read);
protected abstract ShareableFactory<S, I, IS, SS> getSFactory(); protected abstract ShareableFactory<S, I, IS, SS> getSFactory();
@@ -391,6 +391,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
try { try {
MessageStatus status = MessageStatus status =
db.getMessageStatus(txn, contactId, m.getKey()); db.getMessageStatus(txn, contactId, m.getKey());
SharingSessionState s;
long time = d.getLong(TIME); long time = d.getLong(TIME);
boolean local = d.getBoolean(LOCAL); boolean local = d.getBoolean(LOCAL);
boolean read = d.getBoolean(MSG_KEY_READ, false); boolean read = d.getBoolean(MSG_KEY_READ, false);
@@ -398,11 +399,10 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
if (type == SHARE_MSG_TYPE_INVITATION) { if (type == SHARE_MSG_TYPE_INVITATION) {
I msg = getIFactory().build(group.getId(), d); I msg = getIFactory().build(group.getId(), d);
SessionId sessionId = msg.getSessionId();
s = getSessionState(txn, sessionId, true);
if (!local) { if (!local) {
// figure out whether the shareable is still available // figure out whether the shareable is still available
SharingSessionState s =
getSessionState(txn, msg.getSessionId(),
true);
if (!(s instanceof InviteeSessionState)) if (!(s instanceof InviteeSessionState))
continue; continue;
available = ((InviteeSessionState) s).getState() == available = ((InviteeSessionState) s).getState() ==
@@ -410,8 +410,9 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
} }
InvitationMessage im = InvitationMessage im =
createInvitationRequest(m.getKey(), msg, createInvitationRequest(m.getKey(), msg,
contactId, available, time, local, contactId, s.getShareableId(),
status.isSent(), status.isSeen(), read); available, time, local, status.isSent(),
status.isSeen(), read);
list.add(im); list.add(im);
} else if (type == SHARE_MSG_TYPE_ACCEPT || } else if (type == SHARE_MSG_TYPE_ACCEPT ||
type == SHARE_MSG_TYPE_DECLINE) { type == SHARE_MSG_TYPE_DECLINE) {
@@ -419,10 +420,12 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
BaseMessage msg = BaseMessage BaseMessage msg = BaseMessage
.from(getIFactory(), group.getId(), d); .from(getIFactory(), group.getId(), d);
SessionId sessionId = msg.getSessionId(); SessionId sessionId = msg.getSessionId();
InvitationMessage im = createInvitationResponse( s = getSessionState(txn, sessionId, true);
m.getKey(), sessionId, group.getId(), contactId, InvitationMessage im =
accept, time, local, status.isSent(), createInvitationResponse(m.getKey(), sessionId,
status.isSeen(), read); group.getId(), contactId,
s.getShareableId(), accept, time, local,
status.isSent(), status.isSeen(), read);
list.add(im); list.add(im);
} else { } else {
throw new RuntimeException("Unexpected Message Type"); throw new RuntimeException("Unexpected Message Type");