Removed extraneous information from DB events.

This commit is contained in:
akwizgran
2013-03-18 22:10:16 +00:00
parent 935b82a8f4
commit b280e4cbcd
3 changed files with 15 additions and 20 deletions

View File

@@ -1,20 +1,20 @@
package net.sf.briar.api.db.event;
import net.sf.briar.api.messaging.Message;
import net.sf.briar.api.messaging.GroupId;
/** An event that is broadcast when a group message is added to the database. */
public class GroupMessageAddedEvent extends DatabaseEvent {
private final Message message;
private final GroupId groupId;
private final boolean incoming;
public GroupMessageAddedEvent(Message message, boolean incoming) {
this.message = message;
public GroupMessageAddedEvent(GroupId groupId, boolean incoming) {
this.groupId = groupId;
this.incoming = incoming;
}
public Message getMessage() {
return message;
public GroupId getGroupId() {
return groupId;
}
public boolean isIncoming() {

View File

@@ -1,28 +1,20 @@
package net.sf.briar.api.db.event;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.messaging.Message;
/**
* An event that is broadcast when a private message is added to the database.
*/
public class PrivateMessageAddedEvent extends DatabaseEvent {
private final Message message;
private final ContactId contactId;
private final boolean incoming;
public PrivateMessageAddedEvent(Message message, ContactId contactId,
boolean incoming) {
this.message = message;
public PrivateMessageAddedEvent(ContactId contactId, boolean incoming) {
this.contactId = contactId;
this.incoming = incoming;
}
public Message getMessage() {
return message;
}
public ContactId getContactId() {
return contactId;
}

View File

@@ -287,7 +287,10 @@ DatabaseCleaner.Callback {
} finally {
contactLock.readLock().unlock();
}
if(added) callListeners(new GroupMessageAddedEvent(m, false));
if(added) {
GroupId g = m.getGroup().getId();
callListeners(new GroupMessageAddedEvent(g, false));
}
}
/**
@@ -400,7 +403,7 @@ DatabaseCleaner.Callback {
} finally {
contactLock.readLock().unlock();
}
if(added) callListeners(new PrivateMessageAddedEvent(m, c, false));
if(added) callListeners(new PrivateMessageAddedEvent(c, false));
}
public void addSecrets(Collection<TemporarySecret> secrets)
@@ -1352,9 +1355,9 @@ DatabaseCleaner.Callback {
}
callListeners(new MessageReceivedEvent(c));
if(added) {
if(m.getGroup() == null)
callListeners(new PrivateMessageAddedEvent(m, c, true));
else callListeners(new GroupMessageAddedEvent(m, true));
Group g = m.getGroup();
if(g == null) callListeners(new PrivateMessageAddedEvent(c, true));
else callListeners(new GroupMessageAddedEvent(g.getId(), true));
}
}