mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Removed subject line, which won't be used in new conversation views.
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
package net.sf.briar.android.groups;
|
||||
|
||||
import static android.graphics.Typeface.BOLD;
|
||||
import static android.view.Gravity.CENTER_VERTICAL;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.text.DateFormat.SHORT;
|
||||
import static net.sf.briar.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.util.HorizontalSpace;
|
||||
import net.sf.briar.api.Author;
|
||||
import net.sf.briar.api.db.GroupMessageHeader;
|
||||
import android.content.Context;
|
||||
@@ -19,7 +15,6 @@ import android.text.format.DateUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -41,16 +36,6 @@ class GroupAdapter extends ArrayAdapter<GroupMessageHeader> {
|
||||
if(!item.isRead())
|
||||
layout.setBackgroundColor(res.getColor(R.color.unread_background));
|
||||
|
||||
LinearLayout innerLayout = new LinearLayout(ctx);
|
||||
// Give me all the unused width
|
||||
innerLayout.setLayoutParams(WRAP_WRAP_1);
|
||||
innerLayout.setOrientation(VERTICAL);
|
||||
|
||||
// FIXME: Can this layout be removed?
|
||||
LinearLayout authorLayout = new LinearLayout(ctx);
|
||||
authorLayout.setOrientation(HORIZONTAL);
|
||||
authorLayout.setGravity(CENTER_VERTICAL);
|
||||
|
||||
TextView name = new TextView(ctx);
|
||||
// Give me all the unused width
|
||||
name.setLayoutParams(WRAP_WRAP_1);
|
||||
@@ -64,33 +49,11 @@ class GroupAdapter extends ArrayAdapter<GroupMessageHeader> {
|
||||
} else {
|
||||
name.setText(author.getName());
|
||||
}
|
||||
authorLayout.addView(name);
|
||||
innerLayout.addView(authorLayout);
|
||||
|
||||
if(item.getContentType().equals("text/plain")) {
|
||||
TextView subject = new TextView(ctx);
|
||||
subject.setTextSize(14);
|
||||
subject.setMaxLines(2);
|
||||
subject.setPadding(10, 0, 10, 10);
|
||||
if(!item.isRead()) subject.setTypeface(null, BOLD);
|
||||
String s = item.getSubject();
|
||||
subject.setText(s == null ? "" : s);
|
||||
innerLayout.addView(subject);
|
||||
} else {
|
||||
LinearLayout attachmentLayout = new LinearLayout(ctx);
|
||||
attachmentLayout.setOrientation(HORIZONTAL);
|
||||
ImageView attachment = new ImageView(ctx);
|
||||
attachment.setPadding(5, 0, 5, 5);
|
||||
attachment.setImageResource(R.drawable.content_attachment);
|
||||
attachmentLayout.addView(attachment);
|
||||
attachmentLayout.addView(new HorizontalSpace(ctx));
|
||||
innerLayout.addView(attachmentLayout);
|
||||
}
|
||||
layout.addView(innerLayout);
|
||||
layout.addView(name);
|
||||
|
||||
TextView date = new TextView(ctx);
|
||||
date.setTextSize(14);
|
||||
date.setPadding(0, 10, 10, 10);
|
||||
date.setPadding(10, 10, 10, 10);
|
||||
long then = item.getTimestamp(), now = System.currentTimeMillis();
|
||||
date.setText(DateUtils.formatSameDayTime(then, now, SHORT, SHORT));
|
||||
layout.addView(date);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package net.sf.briar.android.groups;
|
||||
|
||||
import static android.graphics.Typeface.BOLD;
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.text.DateFormat.SHORT;
|
||||
import static net.sf.briar.android.groups.GroupListItem.MANAGE;
|
||||
import static net.sf.briar.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
@@ -14,14 +12,12 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.util.HorizontalSpace;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -79,12 +75,9 @@ class GroupListAdapter extends BaseAdapter {
|
||||
if(item.getUnreadCount() > 0)
|
||||
layout.setBackgroundColor(res.getColor(R.color.unread_background));
|
||||
|
||||
LinearLayout innerLayout = new LinearLayout(ctx);
|
||||
// Give me all the unused width
|
||||
innerLayout.setLayoutParams(WRAP_WRAP_1);
|
||||
innerLayout.setOrientation(VERTICAL);
|
||||
|
||||
TextView name = new TextView(ctx);
|
||||
// Give me all the unused width
|
||||
name.setLayoutParams(WRAP_WRAP_1);
|
||||
name.setTextSize(18);
|
||||
name.setMaxLines(1);
|
||||
name.setPadding(10, 10, 10, 10);
|
||||
@@ -92,7 +85,7 @@ class GroupListAdapter extends BaseAdapter {
|
||||
String groupName = item.getGroup().getName();
|
||||
if(unread > 0) name.setText(groupName + " (" + unread + ")");
|
||||
else name.setText(groupName);
|
||||
innerLayout.addView(name);
|
||||
layout.addView(name);
|
||||
|
||||
if(item.isEmpty()) {
|
||||
TextView noPosts = new TextView(ctx);
|
||||
@@ -100,33 +93,11 @@ class GroupListAdapter extends BaseAdapter {
|
||||
noPosts.setPadding(10, 0, 10, 10);
|
||||
noPosts.setTextColor(res.getColor(R.color.no_posts));
|
||||
noPosts.setText(R.string.no_posts);
|
||||
innerLayout.addView(noPosts);
|
||||
layout.addView(innerLayout);
|
||||
layout.addView(noPosts);
|
||||
} else {
|
||||
if(item.getContentType().equals("text/plain")) {
|
||||
TextView subject = new TextView(ctx);
|
||||
subject.setTextSize(14);
|
||||
subject.setMaxLines(2);
|
||||
subject.setPadding(10, 0, 10, 10);
|
||||
if(item.getUnreadCount() > 0) subject.setTypeface(null, BOLD);
|
||||
String s = item.getSubject();
|
||||
subject.setText(s == null ? "" : s);
|
||||
innerLayout.addView(subject);
|
||||
} else {
|
||||
LinearLayout attachmentLayout = new LinearLayout(ctx);
|
||||
attachmentLayout.setOrientation(HORIZONTAL);
|
||||
ImageView attachment = new ImageView(ctx);
|
||||
attachment.setPadding(5, 0, 5, 5);
|
||||
attachment.setImageResource(R.drawable.content_attachment);
|
||||
attachmentLayout.addView(attachment);
|
||||
attachmentLayout.addView(new HorizontalSpace(ctx));
|
||||
innerLayout.addView(attachmentLayout);
|
||||
}
|
||||
layout.addView(innerLayout);
|
||||
|
||||
TextView date = new TextView(ctx);
|
||||
date.setTextSize(14);
|
||||
date.setPadding(0, 10, 10, 10);
|
||||
date.setPadding(10, 0, 10, 10);
|
||||
long then = item.getTimestamp(), now = System.currentTimeMillis();
|
||||
date.setText(DateUtils.formatSameDayTime(then, now, SHORT, SHORT));
|
||||
layout.addView(date);
|
||||
|
||||
@@ -17,7 +17,7 @@ class GroupListItem {
|
||||
|
||||
private final Group group;
|
||||
private final boolean empty;
|
||||
private final String authorName, contentType, subject;
|
||||
private final String authorName, contentType;
|
||||
private final long timestamp;
|
||||
private final int unread;
|
||||
|
||||
@@ -27,7 +27,6 @@ class GroupListItem {
|
||||
if(empty) {
|
||||
authorName = null;
|
||||
contentType = null;
|
||||
subject = null;
|
||||
timestamp = 0;
|
||||
unread = 0;
|
||||
} else {
|
||||
@@ -39,7 +38,6 @@ class GroupListItem {
|
||||
if(a == null) authorName = null;
|
||||
else authorName = a.getName();
|
||||
contentType = newest.getContentType();
|
||||
subject = newest.getSubject();
|
||||
timestamp = newest.getTimestamp();
|
||||
int unread = 0;
|
||||
for(GroupMessageHeader h : list) if(!h.isRead()) unread++;
|
||||
@@ -63,10 +61,6 @@ class GroupListItem {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
package net.sf.briar.android.messages;
|
||||
|
||||
import static android.graphics.Typeface.BOLD;
|
||||
import static android.view.Gravity.CENTER_VERTICAL;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.text.DateFormat.SHORT;
|
||||
import static net.sf.briar.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.util.HorizontalSpace;
|
||||
import net.sf.briar.api.db.PrivateMessageHeader;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -18,7 +14,6 @@ import android.text.format.DateUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -41,16 +36,6 @@ class ConversationAdapter extends ArrayAdapter<PrivateMessageHeader> {
|
||||
layout.setBackgroundColor(res.getColor(R.color.unread_background));
|
||||
}
|
||||
|
||||
LinearLayout innerLayout = new LinearLayout(ctx);
|
||||
// Give me all the unused width
|
||||
innerLayout.setLayoutParams(WRAP_WRAP_1);
|
||||
innerLayout.setOrientation(VERTICAL);
|
||||
|
||||
// FIXME: Can this layout be removed?
|
||||
LinearLayout authorLayout = new LinearLayout(ctx);
|
||||
authorLayout.setOrientation(HORIZONTAL);
|
||||
authorLayout.setGravity(CENTER_VERTICAL);
|
||||
|
||||
TextView name = new TextView(ctx);
|
||||
// Give me all the unused width
|
||||
name.setLayoutParams(WRAP_WRAP_1);
|
||||
@@ -58,29 +43,7 @@ class ConversationAdapter extends ArrayAdapter<PrivateMessageHeader> {
|
||||
name.setMaxLines(1);
|
||||
name.setPadding(10, 10, 10, 10);
|
||||
name.setText(item.getAuthor().getName());
|
||||
authorLayout.addView(name);
|
||||
innerLayout.addView(authorLayout);
|
||||
|
||||
if(item.getContentType().equals("text/plain")) {
|
||||
TextView subject = new TextView(ctx);
|
||||
subject.setTextSize(14);
|
||||
subject.setMaxLines(2);
|
||||
subject.setPadding(10, 0, 10, 10);
|
||||
if(!item.isRead()) subject.setTypeface(null, BOLD);
|
||||
String s = item.getSubject();
|
||||
subject.setText(s == null ? "" : s);
|
||||
innerLayout.addView(subject);
|
||||
} else {
|
||||
LinearLayout attachmentLayout = new LinearLayout(ctx);
|
||||
attachmentLayout.setOrientation(HORIZONTAL);
|
||||
ImageView attachment = new ImageView(ctx);
|
||||
attachment.setPadding(5, 0, 5, 5);
|
||||
attachment.setImageResource(R.drawable.content_attachment);
|
||||
attachmentLayout.addView(attachment);
|
||||
attachmentLayout.addView(new HorizontalSpace(ctx));
|
||||
innerLayout.addView(attachmentLayout);
|
||||
}
|
||||
layout.addView(innerLayout);
|
||||
layout.addView(name);
|
||||
|
||||
TextView date = new TextView(ctx);
|
||||
date.setTextSize(14);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package net.sf.briar.android.messages;
|
||||
|
||||
import static android.graphics.Typeface.BOLD;
|
||||
import static android.view.Gravity.LEFT;
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static android.widget.LinearLayout.VERTICAL;
|
||||
import static java.text.DateFormat.SHORT;
|
||||
import static net.sf.briar.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
@@ -41,13 +38,9 @@ implements OnItemClickListener {
|
||||
if(item.getUnreadCount() > 0)
|
||||
layout.setBackgroundColor(res.getColor(R.color.unread_background));
|
||||
|
||||
LinearLayout innerLayout = new LinearLayout(ctx);
|
||||
// Give me all the unused width
|
||||
innerLayout.setLayoutParams(WRAP_WRAP_1);
|
||||
innerLayout.setOrientation(VERTICAL);
|
||||
innerLayout.setGravity(LEFT);
|
||||
|
||||
TextView name = new TextView(ctx);
|
||||
// Give me all the unused width
|
||||
name.setLayoutParams(WRAP_WRAP_1);
|
||||
name.setTextSize(18);
|
||||
name.setMaxLines(1);
|
||||
name.setPadding(10, 10, 10, 10);
|
||||
@@ -55,7 +48,7 @@ implements OnItemClickListener {
|
||||
String contactName = item.getContactName();
|
||||
if(unread > 0) name.setText(contactName + " (" + unread + ")");
|
||||
else name.setText(contactName);
|
||||
innerLayout.addView(name);
|
||||
layout.addView(name);
|
||||
|
||||
if(item.isEmpty()) {
|
||||
TextView noMessages = new TextView(ctx);
|
||||
@@ -63,19 +56,8 @@ implements OnItemClickListener {
|
||||
noMessages.setPadding(10, 0, 10, 10);
|
||||
noMessages.setTextColor(res.getColor(R.color.no_messages));
|
||||
noMessages.setText(R.string.no_messages);
|
||||
innerLayout.addView(noMessages);
|
||||
layout.addView(innerLayout);
|
||||
layout.addView(noMessages);
|
||||
} else {
|
||||
TextView subject = new TextView(ctx);
|
||||
subject.setTextSize(14);
|
||||
subject.setMaxLines(2);
|
||||
subject.setPadding(10, 0, 10, 10);
|
||||
if(unread > 0) subject.setTypeface(null, BOLD);
|
||||
String s = item.getSubject();
|
||||
subject.setText(s == null ? "" : s);
|
||||
innerLayout.addView(subject);
|
||||
layout.addView(innerLayout);
|
||||
|
||||
TextView date = new TextView(ctx);
|
||||
date.setTextSize(14);
|
||||
date.setPadding(0, 10, 10, 10);
|
||||
|
||||
@@ -15,7 +15,6 @@ class ConversationListItem {
|
||||
|
||||
private final Contact contact;
|
||||
private final boolean empty;
|
||||
private final String subject;
|
||||
private final long timestamp;
|
||||
private final int unread;
|
||||
|
||||
@@ -24,14 +23,12 @@ class ConversationListItem {
|
||||
this.contact = contact;
|
||||
empty = headers.isEmpty();
|
||||
if(empty) {
|
||||
subject = null;
|
||||
timestamp = 0;
|
||||
unread = 0;
|
||||
} else {
|
||||
List<PrivateMessageHeader> list =
|
||||
new ArrayList<PrivateMessageHeader>(headers);
|
||||
Collections.sort(list, DescendingHeaderComparator.INSTANCE);
|
||||
subject = list.get(0).getSubject();
|
||||
timestamp = list.get(0).getTimestamp();
|
||||
int unread = 0;
|
||||
for(PrivateMessageHeader h : list) if(!h.isRead()) unread++;
|
||||
@@ -55,10 +52,6 @@ class ConversationListItem {
|
||||
return empty;
|
||||
}
|
||||
|
||||
String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ public class GroupMessageHeader extends MessageHeader {
|
||||
private final GroupId groupId;
|
||||
|
||||
public GroupMessageHeader(MessageId id, MessageId parent, Author author,
|
||||
String contentType, String subject, long timestamp, boolean read,
|
||||
String contentType, long timestamp, boolean read,
|
||||
GroupId groupId) {
|
||||
super(id, parent, author, contentType, subject, timestamp, read);
|
||||
super(id, parent, author, contentType, timestamp, read);
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,17 +7,16 @@ public abstract class MessageHeader {
|
||||
|
||||
private final MessageId id, parent;
|
||||
private final Author author;
|
||||
private final String contentType, subject;
|
||||
private final String contentType;
|
||||
private final long timestamp;
|
||||
private final boolean read;
|
||||
|
||||
protected MessageHeader(MessageId id, MessageId parent, Author author,
|
||||
String contentType, String subject, long timestamp, boolean read) {
|
||||
String contentType, long timestamp, boolean read) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
this.author = author;
|
||||
this.contentType = contentType;
|
||||
this.subject = subject;
|
||||
this.timestamp = timestamp;
|
||||
this.read = read;
|
||||
}
|
||||
@@ -47,11 +46,6 @@ public abstract class MessageHeader {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
/** Returns the message's subject line. */
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
/** Returns the timestamp created by the message's author. */
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
|
||||
@@ -10,9 +10,9 @@ public class PrivateMessageHeader extends MessageHeader {
|
||||
private final boolean incoming;
|
||||
|
||||
public PrivateMessageHeader(MessageId id, MessageId parent, Author author,
|
||||
String contentType, String subject, long timestamp, boolean read,
|
||||
String contentType, long timestamp, boolean read,
|
||||
ContactId contactId, boolean incoming) {
|
||||
super(id, parent, author, contentType, subject, timestamp, read);
|
||||
super(id, parent, author, contentType, timestamp, read);
|
||||
this.contactId = contactId;
|
||||
this.incoming = incoming;
|
||||
}
|
||||
|
||||
@@ -28,13 +28,6 @@ public interface Message {
|
||||
/** Returns the message's content type. */
|
||||
String getContentType();
|
||||
|
||||
/**
|
||||
* Returns the message's subject line, which is created from the first 50
|
||||
* bytes of the message body if the content type is text/plain, or is the
|
||||
* empty string otherwise.
|
||||
*/
|
||||
String getSubject();
|
||||
|
||||
/** Returns the message's timestamp. */
|
||||
long getTimestamp();
|
||||
|
||||
|
||||
@@ -145,7 +145,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
+ " authorName VARCHAR," // Null for private/anon messages
|
||||
+ " authorKey VARCHAR," // Null for private/anon messages
|
||||
+ " contentType VARCHAR NOT NULL,"
|
||||
+ " subject VARCHAR NOT NULL,"
|
||||
+ " timestamp BIGINT NOT NULL,"
|
||||
+ " length INT NOT NULL,"
|
||||
+ " bodyStart INT NOT NULL,"
|
||||
@@ -659,10 +658,10 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "INSERT INTO messages (messageId, parentId, groupId,"
|
||||
+ " authorId, authorName, authorKey, contentType, subject,"
|
||||
+ " authorId, authorName, authorKey, contentType,"
|
||||
+ " timestamp, length, bodyStart, bodyLength, raw,"
|
||||
+ " incoming, read)"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
|
||||
+ " FALSE)";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setBytes(1, m.getId().getBytes());
|
||||
@@ -680,14 +679,13 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ps.setBytes(6, a.getPublicKey());
|
||||
}
|
||||
ps.setString(7, m.getContentType());
|
||||
ps.setString(8, m.getSubject());
|
||||
ps.setLong(9, m.getTimestamp());
|
||||
ps.setLong(8, m.getTimestamp());
|
||||
byte[] raw = m.getSerialised();
|
||||
ps.setInt(10, raw.length);
|
||||
ps.setInt(11, m.getBodyStart());
|
||||
ps.setInt(12, m.getBodyLength());
|
||||
ps.setBytes(13, raw);
|
||||
ps.setBoolean(14, incoming);
|
||||
ps.setInt(9, raw.length);
|
||||
ps.setInt(10, m.getBodyStart());
|
||||
ps.setInt(11, m.getBodyLength());
|
||||
ps.setBytes(12, raw);
|
||||
ps.setBoolean(13, incoming);
|
||||
int affected = ps.executeUpdate();
|
||||
if(affected != 1) throw new DbStateException();
|
||||
ps.close();
|
||||
@@ -758,23 +756,22 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "INSERT INTO messages (messageId, parentId,"
|
||||
+ " contentType, subject, timestamp, length, bodyStart,"
|
||||
+ " contentType, timestamp, length, bodyStart,"
|
||||
+ " bodyLength, raw, incoming, contactId, read)"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, FALSE)";
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, FALSE)";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setBytes(1, m.getId().getBytes());
|
||||
if(m.getParent() == null) ps.setNull(2, BINARY);
|
||||
else ps.setBytes(2, m.getParent().getBytes());
|
||||
ps.setString(3, m.getContentType());
|
||||
ps.setString(4, m.getSubject());
|
||||
ps.setLong(5, m.getTimestamp());
|
||||
ps.setLong(4, m.getTimestamp());
|
||||
byte[] raw = m.getSerialised();
|
||||
ps.setInt(6, raw.length);
|
||||
ps.setInt(7, m.getBodyStart());
|
||||
ps.setInt(8, m.getBodyLength());
|
||||
ps.setBytes(9, raw);
|
||||
ps.setBoolean(10, incoming);
|
||||
ps.setInt(11, c.getInt());
|
||||
ps.setInt(5, raw.length);
|
||||
ps.setInt(6, m.getBodyStart());
|
||||
ps.setInt(7, m.getBodyLength());
|
||||
ps.setBytes(8, raw);
|
||||
ps.setBoolean(9, incoming);
|
||||
ps.setInt(10, c.getInt());
|
||||
int affected = ps.executeUpdate();
|
||||
if(affected != 1) throw new DbStateException();
|
||||
ps.close();
|
||||
@@ -1288,7 +1285,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = "SELECT messageId, parentId, authorId, authorName,"
|
||||
+ " authorKey, contentType, subject, timestamp, read"
|
||||
+ " authorKey, contentType, timestamp, read"
|
||||
+ " FROM messages"
|
||||
+ " WHERE groupId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
@@ -1311,11 +1308,10 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
author = new Author(authorId, authorName, authorKey);
|
||||
}
|
||||
String contentType = rs.getString(6);
|
||||
String subject = rs.getString(7);
|
||||
long timestamp = rs.getLong(8);
|
||||
boolean read = rs.getBoolean(9);
|
||||
long timestamp = rs.getLong(7);
|
||||
boolean read = rs.getBoolean(8);
|
||||
headers.add(new GroupMessageHeader(id, parent, author,
|
||||
contentType, subject, timestamp, read, g));
|
||||
contentType, timestamp, read, g));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
@@ -1647,7 +1643,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
// Get the incoming message headers
|
||||
String sql = "SELECT m.messageId, parentId, contentType, subject,"
|
||||
String sql = "SELECT m.messageId, parentId, contentType,"
|
||||
+ " timestamp, read, c.authorId, name, publicKey"
|
||||
+ " FROM messages AS m"
|
||||
+ " JOIN contacts AS c"
|
||||
@@ -1665,22 +1661,20 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
byte[] b = rs.getBytes(2);
|
||||
MessageId parent = b == null ? null : new MessageId(b);
|
||||
String contentType = rs.getString(3);
|
||||
String subject = rs.getString(4);
|
||||
long timestamp = rs.getLong(5);
|
||||
boolean read = rs.getBoolean(6);
|
||||
AuthorId authorId = new AuthorId(rs.getBytes(7));
|
||||
String authorName = rs.getString(8);
|
||||
byte[] authorKey = rs.getBytes(9);
|
||||
long timestamp = rs.getLong(4);
|
||||
boolean read = rs.getBoolean(5);
|
||||
AuthorId authorId = new AuthorId(rs.getBytes(6));
|
||||
String authorName = rs.getString(7);
|
||||
byte[] authorKey = rs.getBytes(8);
|
||||
Author author = new Author(authorId, authorName, authorKey);
|
||||
headers.add(new PrivateMessageHeader(id, parent, author,
|
||||
contentType, subject, timestamp, read, c, true));
|
||||
contentType, timestamp, read, c, true));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
// Get the outgoing message headers
|
||||
sql = "SELECT m.messageId, parentId, contentType, subject,"
|
||||
+ " timestamp, read, a.authorId, a.name,"
|
||||
+ " a.publicKey"
|
||||
sql = "SELECT m.messageId, parentId, contentType, timestamp, read,"
|
||||
+ " a.authorId, a.name, a.publicKey"
|
||||
+ " FROM messages AS m"
|
||||
+ " JOIN contacts AS c"
|
||||
+ " ON m.contactId = c.contactId"
|
||||
@@ -1697,15 +1691,14 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
byte[] b = rs.getBytes(2);
|
||||
MessageId parent = b == null ? null : new MessageId(b);
|
||||
String contentType = rs.getString(3);
|
||||
String subject = rs.getString(4);
|
||||
long timestamp = rs.getLong(5);
|
||||
boolean read = rs.getBoolean(6);
|
||||
AuthorId authorId = new AuthorId(rs.getBytes(7));
|
||||
String authorName = rs.getString(8);
|
||||
byte[] authorKey = rs.getBytes(9);
|
||||
long timestamp = rs.getLong(4);
|
||||
boolean read = rs.getBoolean(5);
|
||||
AuthorId authorId = new AuthorId(rs.getBytes(6));
|
||||
String authorName = rs.getString(7);
|
||||
byte[] authorKey = rs.getBytes(8);
|
||||
Author author = new Author(authorId, authorName, authorKey);
|
||||
headers.add(new PrivateMessageHeader(id, parent, author,
|
||||
contentType, subject, timestamp, read, c, false));
|
||||
contentType, timestamp, read, c, false));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
|
||||
@@ -4,7 +4,6 @@ import static net.sf.briar.api.AuthorConstants.MAX_SIGNATURE_LENGTH;
|
||||
import static net.sf.briar.api.messaging.MessagingConstants.MAX_BODY_LENGTH;
|
||||
import static net.sf.briar.api.messaging.MessagingConstants.MAX_CONTENT_TYPE_LENGTH;
|
||||
import static net.sf.briar.api.messaging.MessagingConstants.MAX_PACKET_LENGTH;
|
||||
import static net.sf.briar.api.messaging.MessagingConstants.MAX_SUBJECT_LENGTH;
|
||||
import static net.sf.briar.api.messaging.MessagingConstants.MESSAGE_SALT_LENGTH;
|
||||
import static net.sf.briar.api.messaging.Types.AUTHOR;
|
||||
import static net.sf.briar.api.messaging.Types.GROUP;
|
||||
@@ -12,9 +11,6 @@ import static net.sf.briar.api.messaging.Types.MESSAGE;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
@@ -44,7 +40,6 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
private final MessageDigest messageDigest;
|
||||
private final WriterFactory writerFactory;
|
||||
private final Clock clock;
|
||||
private final CharsetDecoder decoder;
|
||||
|
||||
@Inject
|
||||
MessageFactoryImpl(CryptoComponent crypto, WriterFactory writerFactory,
|
||||
@@ -54,7 +49,6 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
messageDigest = crypto.getMessageDigest();
|
||||
this.writerFactory = writerFactory;
|
||||
this.clock = clock;
|
||||
decoder = Charset.forName("UTF-8").newDecoder();
|
||||
}
|
||||
|
||||
public Message createPrivateMessage(MessageId parent, String contentType,
|
||||
@@ -129,17 +123,7 @@ class MessageFactoryImpl implements MessageFactory {
|
||||
// Hash the message, including the signature, to get the message ID
|
||||
w.removeConsumer(digestingConsumer);
|
||||
MessageId id = new MessageId(messageDigest.digest());
|
||||
// If the content type is text/plain, extract a subject line
|
||||
String subject;
|
||||
if(contentType.equals("text/plain")) {
|
||||
byte[] start = new byte[Math.min(MAX_SUBJECT_LENGTH, body.length)];
|
||||
System.arraycopy(body, 0, start, 0, start.length);
|
||||
decoder.reset();
|
||||
subject = decoder.decode(ByteBuffer.wrap(start)).toString();
|
||||
} else {
|
||||
subject = "";
|
||||
}
|
||||
return new MessageImpl(id, parent, group, author, contentType, subject,
|
||||
return new MessageImpl(id, parent, group, author, contentType,
|
||||
timestamp, out.toByteArray(), bodyStart, body.length);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ class MessageImpl implements Message {
|
||||
private final MessageId id, parent;
|
||||
private final Group group;
|
||||
private final Author author;
|
||||
private final String contentType, subject;
|
||||
private final String contentType;
|
||||
private final long timestamp;
|
||||
private final byte[] raw;
|
||||
private final int bodyStart, bodyLength;
|
||||
|
||||
public MessageImpl(MessageId id, MessageId parent, Group group,
|
||||
Author author, String contentType, String subject, long timestamp,
|
||||
Author author, String contentType, long timestamp,
|
||||
byte[] raw, int bodyStart, int bodyLength) {
|
||||
if(bodyStart + bodyLength > raw.length)
|
||||
throw new IllegalArgumentException();
|
||||
@@ -29,7 +29,6 @@ class MessageImpl implements Message {
|
||||
this.group = group;
|
||||
this.author = author;
|
||||
this.contentType = contentType;
|
||||
this.subject = subject;
|
||||
this.timestamp = timestamp;
|
||||
this.raw = raw;
|
||||
this.bodyStart = bodyStart;
|
||||
@@ -56,10 +55,6 @@ class MessageImpl implements Message {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class MessageVerifierImpl implements MessageVerifier {
|
||||
throw new GeneralSecurityException();
|
||||
}
|
||||
return new MessageImpl(id, m.getParent(), m.getGroup(), author,
|
||||
m.getContentType(), m.getSubject(), m.getTimestamp(), raw,
|
||||
m.getBodyStart(), m.getBodyLength());
|
||||
m.getContentType(), m.getTimestamp(), raw, m.getBodyStart(),
|
||||
m.getBodyLength());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1239,7 +1239,6 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
if(m.getAuthor() == null) assertNull(h.getAuthor());
|
||||
else assertEquals(m.getAuthor(), h.getAuthor());
|
||||
assertEquals(m.getContentType(), h.getContentType());
|
||||
assertEquals(m.getSubject(), h.getSubject());
|
||||
assertEquals(m.getTimestamp(), h.getTimestamp());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user