mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Rename object to nameable
This commit is contained in:
@@ -108,7 +108,7 @@ class BlogControllerImpl extends BaseControllerImpl
|
||||
BlogInvitationResponseReceivedEvent b =
|
||||
(BlogInvitationResponseReceivedEvent) e;
|
||||
PrivateResponse<Blog> r = b.getMessageHeader();
|
||||
if (r.getObject().getId().equals(groupId) && r.wasAccepted()) {
|
||||
if (r.getNameable().getId().equals(groupId) && r.wasAccepted()) {
|
||||
LOG.info("Blog invitation accepted");
|
||||
onBlogInvitationAccepted(b.getContactId());
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ abstract class ConversationItem {
|
||||
return new ConversationRequestItem(ir.getId(),
|
||||
ir.getGroupId(), type, ir.getSessionId(), text,
|
||||
ir.getMessage(), ir.getTimestamp(), ir.isRead(),
|
||||
((Shareable) ir.getObject()).getId(), !ir.wasAnswered(),
|
||||
((Shareable) ir.getNameable()).getId(), !ir.wasAnswered(),
|
||||
ir.doesExist());
|
||||
}
|
||||
}
|
||||
@@ -163,14 +163,14 @@ abstract class ConversationItem {
|
||||
if (ir.wasAccepted()) {
|
||||
text = ctx.getString(
|
||||
R.string.introduction_response_accepted_sent,
|
||||
ir.getObject().getName());
|
||||
ir.getNameable().getName());
|
||||
text += "\n\n" + ctx.getString(
|
||||
R.string.introduction_response_accepted_sent_info,
|
||||
ir.getObject().getName());
|
||||
ir.getNameable().getName());
|
||||
} else {
|
||||
text = ctx.getString(
|
||||
R.string.introduction_response_declined_sent,
|
||||
ir.getObject().getName());
|
||||
ir.getNameable().getName());
|
||||
}
|
||||
return new ConversationNoticeOutItem(ir.getId(), ir.getGroupId(),
|
||||
text, null, ir.getTimestamp(), ir.isSent(), ir.isSeen());
|
||||
@@ -179,7 +179,7 @@ abstract class ConversationItem {
|
||||
if (ir.wasAccepted()) {
|
||||
res = R.string.introduction_response_accepted_received;
|
||||
} else {
|
||||
if (ir.getObject().isIntroducer()) {
|
||||
if (ir.getNameable().isIntroducer()) {
|
||||
res = R.string.introduction_response_declined_received;
|
||||
} else {
|
||||
res =
|
||||
@@ -187,7 +187,7 @@ abstract class ConversationItem {
|
||||
}
|
||||
}
|
||||
String text =
|
||||
ctx.getString(res, contactName, ir.getObject().getName());
|
||||
ctx.getString(res, contactName, ir.getNameable().getName());
|
||||
return new ConversationNoticeInItem(ir.getId(), ir.getGroupId(),
|
||||
text, null, ir.getTimestamp(), ir.isRead());
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class ForumControllerImpl extends
|
||||
ForumInvitationResponseReceivedEvent f =
|
||||
(ForumInvitationResponseReceivedEvent) e;
|
||||
ForumInvitationResponse r = f.getMessageHeader();
|
||||
if (r.getObject().getId().equals(getGroupId()) && r.wasAccepted()) {
|
||||
if (r.getNameable().getId().equals(getGroupId()) && r.wasAccepted()) {
|
||||
LOG.info("Forum invitation was accepted");
|
||||
onForumInvitationAccepted(f.getContactId());
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class GroupControllerImpl extends
|
||||
GroupInvitationResponseReceivedEvent g =
|
||||
(GroupInvitationResponseReceivedEvent) e;
|
||||
GroupInvitationResponse r = g.getMessageHeader();
|
||||
if (getGroupId().equals(r.getObject().getId()) && r.wasAccepted()) {
|
||||
if (getGroupId().equals(r.getNameable().getId()) && r.wasAccepted()) {
|
||||
listener.runOnUiThreadUnlessDestroyed(
|
||||
() -> listener.onInvitationAccepted(g.getContactId()));
|
||||
}
|
||||
|
||||
@@ -10,21 +10,21 @@ import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class PrivateRequest<O extends Nameable> extends PrivateMessageHeader {
|
||||
public class PrivateRequest<N extends Nameable> extends PrivateMessageHeader {
|
||||
|
||||
private final SessionId sessionId;
|
||||
private final O object;
|
||||
private final N nameable;
|
||||
@Nullable
|
||||
private final String message;
|
||||
private final boolean answered, exists;
|
||||
|
||||
public PrivateRequest(MessageId messageId, GroupId groupId, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read,
|
||||
SessionId sessionId, O object, @Nullable String message,
|
||||
SessionId sessionId, N nameable, @Nullable String message,
|
||||
boolean answered, boolean exists) {
|
||||
super(messageId, groupId, time, local, sent, seen, read);
|
||||
this.sessionId = sessionId;
|
||||
this.object = object;
|
||||
this.nameable = nameable;
|
||||
this.message = message;
|
||||
this.answered = answered;
|
||||
this.exists = exists;
|
||||
@@ -34,12 +34,12 @@ public class PrivateRequest<O extends Nameable> extends PrivateMessageHeader {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public O getObject() {
|
||||
return object;
|
||||
public N getNameable() {
|
||||
return nameable;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return object.getName();
|
||||
return nameable.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -9,19 +9,19 @@ import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public abstract class PrivateResponse<O extends Nameable>
|
||||
public abstract class PrivateResponse<N extends Nameable>
|
||||
extends PrivateMessageHeader {
|
||||
|
||||
private final SessionId sessionId;
|
||||
private final O object;
|
||||
private final N nameable;
|
||||
private final boolean accepted;
|
||||
|
||||
public PrivateResponse(MessageId id, GroupId groupId, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read,
|
||||
SessionId sessionId, O object, boolean accepted) {
|
||||
SessionId sessionId, N nameable, boolean accepted) {
|
||||
super(id, groupId, time, local, sent, seen, read);
|
||||
this.sessionId = sessionId;
|
||||
this.object = object;
|
||||
this.nameable = nameable;
|
||||
this.accepted = accepted;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ public abstract class PrivateResponse<O extends Nameable>
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public O getObject() {
|
||||
return object;
|
||||
public N getNameable() {
|
||||
return nameable;
|
||||
}
|
||||
|
||||
public boolean wasAccepted() {
|
||||
|
||||
@@ -390,7 +390,7 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
GroupInvitationRequest invite = parseInvitationRequest(txn,
|
||||
contactGroupId, m, meta, status);
|
||||
messages.add(invite);
|
||||
privateGroups.put(invite.getSessionId(), invite.getObject());
|
||||
privateGroups.put(invite.getSessionId(), invite.getNameable());
|
||||
}
|
||||
for (Entry<MessageId, BdfDictionary> e : results.entrySet()) {
|
||||
MessageId m = e.getKey();
|
||||
|
||||
@@ -343,7 +343,7 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
PrivateRequest<S> invite = parseInvitationRequest(txn, c, m,
|
||||
meta, status);
|
||||
messages.add(invite);
|
||||
shareables.put(invite.getObject().getId(), invite.getObject());
|
||||
shareables.put(invite.getNameable().getId(), invite.getNameable());
|
||||
}
|
||||
for (Entry<MessageId, BdfDictionary> e : results.entrySet()) {
|
||||
MessageId m = e.getKey();
|
||||
|
||||
@@ -161,7 +161,7 @@ public class IntroductionIntegrationTest
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
assertTrue(listener0.response1Received);
|
||||
assertEquals(introducee2.getAuthor().getName(),
|
||||
listener0.getResponse().getObject().getName());
|
||||
listener0.getResponse().getNameable().getName());
|
||||
assertGroupCount(messageTracker0, g1.getId(), 2, 1);
|
||||
|
||||
// sync second ACCEPT message
|
||||
@@ -169,7 +169,7 @@ public class IntroductionIntegrationTest
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
assertTrue(listener0.response2Received);
|
||||
assertEquals(introducee1.getAuthor().getName(),
|
||||
listener0.getResponse().getObject().getName());
|
||||
listener0.getResponse().getNameable().getName());
|
||||
assertGroupCount(messageTracker0, g2.getId(), 2, 1);
|
||||
|
||||
// sync forwarded ACCEPT messages to introducees
|
||||
@@ -267,7 +267,7 @@ public class IntroductionIntegrationTest
|
||||
|
||||
// assert that the name on the decline event is correct
|
||||
assertEquals(introducee2.getAuthor().getName(),
|
||||
listener0.getResponse().getObject().getName());
|
||||
listener0.getResponse().getNameable().getName());
|
||||
|
||||
// sync second response
|
||||
sync2To0(1, true);
|
||||
@@ -284,7 +284,7 @@ public class IntroductionIntegrationTest
|
||||
// assert that the name on the decline event is correct
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
assertEquals(introducee1.getAuthor().getName(),
|
||||
listener2.getResponse().getObject().getName());
|
||||
listener2.getResponse().getNameable().getName());
|
||||
|
||||
// note how the introducer does not forward the second response,
|
||||
// because after the first decline the protocol finished
|
||||
@@ -358,7 +358,7 @@ public class IntroductionIntegrationTest
|
||||
// assert that the name on the decline event is correct
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
assertEquals(contact2From0.getAuthor().getName(),
|
||||
listener1.getResponse().getObject().getName());
|
||||
listener1.getResponse().getNameable().getName());
|
||||
|
||||
assertFalse(contactManager1
|
||||
.contactExists(author2.getId(), author1.getId()));
|
||||
@@ -486,7 +486,7 @@ public class IntroductionIntegrationTest
|
||||
// assert that the name on the decline event is correct
|
||||
eventWaiter.await(TIMEOUT, 1);
|
||||
assertEquals(introducee1.getAuthor().getName(),
|
||||
listener2.getResponse().getObject().getName());
|
||||
listener2.getResponse().getNameable().getName());
|
||||
|
||||
// assert that introducee2 is in correct state
|
||||
introduceeSession = getIntroduceeSession(c2);
|
||||
|
||||
@@ -99,9 +99,9 @@ public class GroupInvitationIntegrationTest
|
||||
GroupInvitationRequest request =
|
||||
(GroupInvitationRequest) messages.iterator().next();
|
||||
assertEquals(msg, request.getMessage());
|
||||
assertEquals(author0, request.getObject().getCreator());
|
||||
assertEquals(author0, request.getNameable().getCreator());
|
||||
assertEquals(timestamp, request.getTimestamp());
|
||||
assertEquals(privateGroup0.getName(), request.getObject().getName());
|
||||
assertEquals(privateGroup0.getName(), request.getNameable().getName());
|
||||
assertFalse(request.isLocal());
|
||||
assertFalse(request.isRead());
|
||||
assertFalse(request.doesExist());
|
||||
@@ -127,7 +127,7 @@ public class GroupInvitationIntegrationTest
|
||||
if (m instanceof GroupInvitationResponse) {
|
||||
foundResponse = true;
|
||||
GroupInvitationResponse response = (GroupInvitationResponse) m;
|
||||
assertEquals(privateGroup0, response.getObject());
|
||||
assertEquals(privateGroup0, response.getNameable());
|
||||
assertTrue(response.isLocal());
|
||||
assertFalse(response.wasAccepted());
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class GroupInvitationIntegrationTest
|
||||
if (m instanceof GroupInvitationResponse) {
|
||||
foundResponse = true;
|
||||
GroupInvitationResponse response = (GroupInvitationResponse) m;
|
||||
assertEquals(privateGroup0, response.getObject());
|
||||
assertEquals(privateGroup0, response.getNameable());
|
||||
assertFalse(response.isLocal());
|
||||
assertFalse(response.wasAccepted());
|
||||
}
|
||||
@@ -177,11 +177,11 @@ public class GroupInvitationIntegrationTest
|
||||
if (m instanceof GroupInvitationResponse) {
|
||||
foundResponse = true;
|
||||
GroupInvitationResponse response = (GroupInvitationResponse) m;
|
||||
assertEquals(privateGroup0, response.getObject());
|
||||
assertEquals(privateGroup0, response.getNameable());
|
||||
assertTrue(response.wasAccepted());
|
||||
} else {
|
||||
GroupInvitationRequest request = (GroupInvitationRequest) m;
|
||||
assertEquals(privateGroup0, request.getObject());
|
||||
assertEquals(privateGroup0, request.getNameable());
|
||||
assertTrue(request.doesExist());
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class GroupInvitationIntegrationTest
|
||||
if (m instanceof GroupInvitationResponse) {
|
||||
foundResponse = true;
|
||||
GroupInvitationResponse response = (GroupInvitationResponse) m;
|
||||
assertEquals(privateGroup0, response.getObject());
|
||||
assertEquals(privateGroup0, response.getNameable());
|
||||
assertTrue(response.wasAccepted());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,11 +708,11 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
||||
if (m.getId().equals(message.getId())) {
|
||||
assertTrue(m instanceof GroupInvitationRequest);
|
||||
assertEquals(time1, m.getTimestamp());
|
||||
assertEquals(pg, ((GroupInvitationRequest) m).getObject());
|
||||
assertEquals(pg, ((GroupInvitationRequest) m).getNameable());
|
||||
} else if (m.getId().equals(messageId2)) {
|
||||
assertTrue(m instanceof GroupInvitationResponse);
|
||||
assertEquals(time2, m.getTimestamp());
|
||||
assertEquals(pg, ((GroupInvitationResponse) m).getObject());
|
||||
assertEquals(pg, ((GroupInvitationResponse) m).getNameable());
|
||||
} else {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@@ -152,15 +152,15 @@ public class BlogSharingIntegrationTest
|
||||
for (PrivateMessageHeader m : list) {
|
||||
if (m instanceof BlogInvitationRequest) {
|
||||
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||
assertEquals(blog2, invitation.getObject());
|
||||
assertEquals(blog2, invitation.getNameable());
|
||||
assertFalse(invitation.wasAnswered());
|
||||
assertEquals(blog2.getAuthor().getName(),
|
||||
invitation.getName());
|
||||
assertFalse(invitation.getObject().isRssFeed());
|
||||
assertFalse(invitation.getNameable().isRssFeed());
|
||||
assertEquals("Hi!", invitation.getMessage());
|
||||
} else {
|
||||
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||
assertEquals(blog2, response.getObject());
|
||||
assertEquals(blog2, response.getNameable());
|
||||
assertTrue(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
@@ -225,15 +225,15 @@ public class BlogSharingIntegrationTest
|
||||
for (PrivateMessageHeader m : list) {
|
||||
if (m instanceof BlogInvitationRequest) {
|
||||
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||
assertEquals(rssBlog, invitation.getObject());
|
||||
assertEquals(rssBlog, invitation.getNameable());
|
||||
assertFalse(invitation.wasAnswered());
|
||||
assertEquals(rssBlog.getAuthor().getName(),
|
||||
invitation.getName());
|
||||
assertTrue(invitation.getObject().isRssFeed());
|
||||
assertTrue(invitation.getNameable().isRssFeed());
|
||||
assertEquals("Hi!", invitation.getMessage());
|
||||
} else {
|
||||
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||
assertEquals(rssBlog, response.getObject());
|
||||
assertEquals(rssBlog, response.getNameable());
|
||||
assertTrue(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
@@ -287,14 +287,14 @@ public class BlogSharingIntegrationTest
|
||||
for (PrivateMessageHeader m : list) {
|
||||
if (m instanceof BlogInvitationRequest) {
|
||||
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||
assertEquals(blog2, invitation.getObject());
|
||||
assertEquals(blog2, invitation.getNameable());
|
||||
assertFalse(invitation.wasAnswered());
|
||||
assertEquals(blog2.getAuthor().getName(),
|
||||
invitation.getName());
|
||||
assertEquals(null, invitation.getMessage());
|
||||
} else {
|
||||
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||
assertEquals(blog2, response.getObject());
|
||||
assertEquals(blog2, response.getNameable());
|
||||
assertFalse(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
@@ -559,7 +559,7 @@ public class BlogSharingIntegrationTest
|
||||
BlogInvitationRequestReceivedEvent event =
|
||||
(BlogInvitationRequestReceivedEvent) e;
|
||||
eventWaiter.assertEquals(contactId1From0, event.getContactId());
|
||||
Blog b = event.getMessageHeader().getObject();
|
||||
Blog b = event.getMessageHeader().getNameable();
|
||||
try {
|
||||
Contact c = contactManager0.getContact(contactId1From0);
|
||||
blogSharingManager0.respondToInvitation(b, c, true);
|
||||
@@ -595,7 +595,7 @@ public class BlogSharingIntegrationTest
|
||||
(BlogInvitationRequestReceivedEvent) e;
|
||||
requestReceived = true;
|
||||
if (!answer) return;
|
||||
Blog b = event.getMessageHeader().getObject();
|
||||
Blog b = event.getMessageHeader().getNameable();
|
||||
try {
|
||||
eventWaiter.assertEquals(1,
|
||||
blogSharingManager1.getInvitations().size());
|
||||
|
||||
@@ -137,12 +137,12 @@ public class ForumSharingIntegrationTest
|
||||
ForumInvitationRequest invitation = (ForumInvitationRequest) m;
|
||||
assertFalse(invitation.wasAnswered());
|
||||
assertEquals(forum0.getName(), invitation.getName());
|
||||
assertEquals(forum0, invitation.getObject());
|
||||
assertEquals(forum0, invitation.getNameable());
|
||||
assertEquals("Hi!", invitation.getMessage());
|
||||
assertTrue(invitation.doesExist());
|
||||
} else {
|
||||
ForumInvitationResponse response = (ForumInvitationResponse) m;
|
||||
assertEquals(forum0, response.getObject());
|
||||
assertEquals(forum0, response.getNameable());
|
||||
assertTrue(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
@@ -191,14 +191,14 @@ public class ForumSharingIntegrationTest
|
||||
for (PrivateMessageHeader m : list) {
|
||||
if (m instanceof ForumInvitationRequest) {
|
||||
ForumInvitationRequest invitation = (ForumInvitationRequest) m;
|
||||
assertEquals(forum0, invitation.getObject());
|
||||
assertEquals(forum0, invitation.getNameable());
|
||||
assertFalse(invitation.wasAnswered());
|
||||
assertEquals(forum0.getName(), invitation.getName());
|
||||
assertEquals(null, invitation.getMessage());
|
||||
assertFalse(invitation.doesExist());
|
||||
} else {
|
||||
ForumInvitationResponse response = (ForumInvitationResponse) m;
|
||||
assertEquals(forum0, response.getObject());
|
||||
assertEquals(forum0, response.getNameable());
|
||||
assertFalse(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
@@ -805,7 +805,7 @@ public class ForumSharingIntegrationTest
|
||||
(ForumInvitationRequestReceivedEvent) e;
|
||||
eventWaiter.assertEquals(contactId1From0, event.getContactId());
|
||||
requestReceived = true;
|
||||
Forum f = event.getMessageHeader().getObject();
|
||||
Forum f = event.getMessageHeader().getNameable();
|
||||
try {
|
||||
if (respond) {
|
||||
Contact c = contactManager0.getContact(contactId1From0);
|
||||
@@ -843,7 +843,7 @@ public class ForumSharingIntegrationTest
|
||||
(ForumInvitationRequestReceivedEvent) e;
|
||||
requestReceived = true;
|
||||
if (!answer) return;
|
||||
Forum f = event.getMessageHeader().getObject();
|
||||
Forum f = event.getMessageHeader().getNameable();
|
||||
try {
|
||||
if (respond) {
|
||||
eventWaiter.assertEquals(1,
|
||||
|
||||
Reference in New Issue
Block a user