Major reorganization of view/model interactions.
Mostly, the inheritance graph for MessageRecord/MmsMessageRecord was all messed up, and each class was overloaded for things it shouldn't have been. 1) Broke MessageRecord/MmsMessageRecord up into: DisplayRecord, ThreadRecord, MessageRecord, SmsMessageRecord, NotificationMmsMessageRecord, and MediaMmsMessageRecord. 2) Updated all the adapters/views to keep pace with that change.pull/1/head
parent
0b3e939ac8
commit
3a8d29e279
@ -1,181 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2011 Whisper Systems
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.thoughtcrime.securesms.database;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ConversationItem;
|
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
||||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
|
||||||
|
|
||||||
public class MessageRecord {
|
|
||||||
|
|
||||||
private long id;
|
|
||||||
private long threadId;
|
|
||||||
private Recipient messageRecipient;
|
|
||||||
private Recipients recipients;
|
|
||||||
private String body;
|
|
||||||
private long date;
|
|
||||||
private long count;
|
|
||||||
private boolean read;
|
|
||||||
private long type;
|
|
||||||
private boolean emphasis;
|
|
||||||
private boolean keyExchange;
|
|
||||||
private boolean processedKeyExchange;
|
|
||||||
private boolean staleKeyExchange;
|
|
||||||
|
|
||||||
public MessageRecord(MessageRecord copy) {
|
|
||||||
this.id = copy.id;
|
|
||||||
this.threadId = copy.threadId;
|
|
||||||
this.messageRecipient = copy.messageRecipient;
|
|
||||||
this.recipients = copy.recipients;
|
|
||||||
this.body = copy.body;
|
|
||||||
this.date = copy.date;
|
|
||||||
this.count = copy.count;
|
|
||||||
this.read = copy.read;
|
|
||||||
this.type = copy.type;
|
|
||||||
this.emphasis = copy.emphasis;
|
|
||||||
this.keyExchange = copy.keyExchange;
|
|
||||||
this.processedKeyExchange = copy.processedKeyExchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageRecord(long id, Recipients recipients, long date, long type, long threadId) {
|
|
||||||
this.id = id;
|
|
||||||
this.date = date;
|
|
||||||
this.type = type;
|
|
||||||
this.recipients = recipients;
|
|
||||||
this.threadId = threadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageRecord(long id, Recipients recipients, long date, long count, boolean read, long threadId) {
|
|
||||||
this.id = id;
|
|
||||||
this.threadId = threadId;
|
|
||||||
this.recipients = recipients;
|
|
||||||
this.date = date;
|
|
||||||
this.count = count;
|
|
||||||
this.read = read;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnConversationItem(ConversationItem item) {
|
|
||||||
item.setMessageRecord(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMms() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageRecipient(Recipient recipient) {
|
|
||||||
this.messageRecipient = recipient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Recipient getMessageRecipient() {
|
|
||||||
return this.messageRecipient;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmphasis(boolean emphasis) {
|
|
||||||
this.emphasis = emphasis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getEmphasis() {
|
|
||||||
return this.emphasis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBody(String body) {
|
|
||||||
this.body = body;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getThreadId() {
|
|
||||||
return threadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Recipients getRecipients() {
|
|
||||||
return recipients;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBody() {
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCount() {
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getRead() {
|
|
||||||
return read;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStaleKeyExchange() {
|
|
||||||
return this.staleKeyExchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStaleKeyExchange(boolean staleKeyExchange) {
|
|
||||||
this.staleKeyExchange = staleKeyExchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isProcessedKeyExchange() {
|
|
||||||
return processedKeyExchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProcessedKeyExchange(boolean processedKeyExchange) {
|
|
||||||
this.processedKeyExchange = processedKeyExchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isKeyExchange() {
|
|
||||||
return keyExchange || processedKeyExchange || staleKeyExchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKeyExchange(boolean keyExchange) {
|
|
||||||
this.keyExchange = keyExchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFailedDecryptType() {
|
|
||||||
return type == SmsDatabase.Types.FAILED_DECRYPT_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFailed() {
|
|
||||||
return SmsDatabase.Types.isFailedMessageType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOutgoing() {
|
|
||||||
return SmsDatabase.Types.isOutgoingMessageType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPending() {
|
|
||||||
return SmsDatabase.Types.isPendingMessageType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSecure() {
|
|
||||||
return SmsDatabase.Types.isSecureType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2012 Moxie Marlinspike
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.thoughtcrime.securesms.database.model;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.protocol.Prefix;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base class for all message record models. Encapsulates basic data
|
||||||
|
* shared between ThreadRecord and MessageRecord.
|
||||||
|
*
|
||||||
|
* @author Moxie Marlinspike
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public abstract class DisplayRecord {
|
||||||
|
|
||||||
|
private final Recipients recipients;
|
||||||
|
private final long date;
|
||||||
|
private final long threadId;
|
||||||
|
|
||||||
|
private String body;
|
||||||
|
protected boolean emphasis;
|
||||||
|
protected boolean keyExchange;
|
||||||
|
protected boolean processedKeyExchange;
|
||||||
|
protected boolean staleKeyExchange;
|
||||||
|
|
||||||
|
public DisplayRecord(Recipients recipients, long date, long threadId) {
|
||||||
|
this.threadId = threadId;
|
||||||
|
this.recipients = recipients;
|
||||||
|
this.date = date;
|
||||||
|
this.emphasis = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmphasis(boolean emphasis) {
|
||||||
|
this.emphasis = emphasis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getEmphasis() {
|
||||||
|
return emphasis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBody(String body) {
|
||||||
|
if (body.startsWith(Prefix.KEY_EXCHANGE)) {
|
||||||
|
this.keyExchange = true;
|
||||||
|
this.emphasis = true;
|
||||||
|
this.body = body;
|
||||||
|
} else if (body.startsWith(Prefix.PROCESSED_KEY_EXCHANGE)) {
|
||||||
|
this.processedKeyExchange = true;
|
||||||
|
this.emphasis = true;
|
||||||
|
this.body = body;
|
||||||
|
} else if (body.startsWith(Prefix.STALE_KEY_EXCHANGE)) {
|
||||||
|
this.staleKeyExchange = true;
|
||||||
|
this.emphasis = true;
|
||||||
|
this.body = body;
|
||||||
|
} else {
|
||||||
|
this.body = body;
|
||||||
|
this.emphasis = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Recipients getRecipients() {
|
||||||
|
return recipients;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getThreadId() {
|
||||||
|
return threadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isKeyExchange() {
|
||||||
|
return keyExchange || processedKeyExchange || staleKeyExchange;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2012 Moxie Marlinpsike
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.thoughtcrime.securesms.database.model;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base class for message record models that are displayed in
|
||||||
|
* conversations, as opposed to models that are displayed in a thread list.
|
||||||
|
* Encapsulates the shared data between both SMS and MMS messages.
|
||||||
|
*
|
||||||
|
* @author Moxie Marlinspike
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class MessageRecord extends DisplayRecord {
|
||||||
|
|
||||||
|
private final Recipient individualRecipient;
|
||||||
|
private final long id;
|
||||||
|
|
||||||
|
public MessageRecord(long id, Recipients recipients,
|
||||||
|
Recipient individualRecipient,
|
||||||
|
long date, long threadId)
|
||||||
|
{
|
||||||
|
super(recipients, date, threadId);
|
||||||
|
this.id = id;
|
||||||
|
this.individualRecipient = individualRecipient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean isOutgoing();
|
||||||
|
|
||||||
|
public abstract boolean isFailed();
|
||||||
|
|
||||||
|
public abstract boolean isSecure();
|
||||||
|
|
||||||
|
public abstract boolean isPending();
|
||||||
|
|
||||||
|
public abstract boolean isMms();
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStaleKeyExchange() {
|
||||||
|
return this.staleKeyExchange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isProcessedKeyExchange() {
|
||||||
|
return this.processedKeyExchange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Recipient getIndividualRecipient() {
|
||||||
|
return individualRecipient;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// public static class GroupData {
|
||||||
|
// public final int groupSize;
|
||||||
|
// public final int groupSentCount;
|
||||||
|
// public final int groupSendFailedCount;
|
||||||
|
//
|
||||||
|
// public GroupData(int groupSize, int groupSentCount, int groupSendFailedCount) {
|
||||||
|
// this.groupSize = groupSize;
|
||||||
|
// this.groupSentCount = groupSentCount;
|
||||||
|
// this.groupSendFailedCount = groupSendFailedCount;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2012 Moxie Marlinspike
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.thoughtcrime.securesms.database.model;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the message record model for MMS messages that are
|
||||||
|
* notifications (ie: they're pointers to undownloaded media).
|
||||||
|
*
|
||||||
|
* @author Moxie Marlinspike
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class NotificationMmsMessageRecord extends MessageRecord {
|
||||||
|
|
||||||
|
private final byte[] contentLocation;
|
||||||
|
private final long messageSize;
|
||||||
|
private final long expiry;
|
||||||
|
private final int status;
|
||||||
|
private final byte[] transactionId;
|
||||||
|
|
||||||
|
public NotificationMmsMessageRecord(long id, Recipients recipients, Recipient individualRecipient,
|
||||||
|
long date, long threadId, byte[] contentLocation,
|
||||||
|
long messageSize, long expiry,
|
||||||
|
int status, byte[] transactionId)
|
||||||
|
{
|
||||||
|
super(id, recipients, individualRecipient, date, threadId);
|
||||||
|
this.contentLocation = contentLocation;
|
||||||
|
this.messageSize = messageSize;
|
||||||
|
this.expiry = expiry;
|
||||||
|
this.status = status;
|
||||||
|
this.transactionId = transactionId;
|
||||||
|
|
||||||
|
setBody("Multimedia Message");
|
||||||
|
setEmphasis(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getTransactionId() {
|
||||||
|
return transactionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public byte[] getContentLocation() {
|
||||||
|
return contentLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMessageSize() {
|
||||||
|
return (messageSize + 1023) / 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpiration() {
|
||||||
|
return expiry * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOutgoing() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFailed() {
|
||||||
|
return MmsDatabase.Types.isHardError(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSecure() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPending() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMms() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2012 Moxie Marlinspike
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.thoughtcrime.securesms.database.model;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||||
|
import org.thoughtcrime.securesms.protocol.Prefix;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message record model which represents standard SMS messages.
|
||||||
|
*
|
||||||
|
* @author Moxie Marlinspike
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SmsMessageRecord extends MessageRecord {
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
private final long type;
|
||||||
|
|
||||||
|
public SmsMessageRecord(Context context, long id,
|
||||||
|
Recipients recipients,
|
||||||
|
Recipient individualRecipient,
|
||||||
|
long date, long type, long threadId)
|
||||||
|
{
|
||||||
|
super(id, recipients, individualRecipient, date, threadId);
|
||||||
|
this.context = context.getApplicationContext();
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBody(String body) {
|
||||||
|
if (this.type == SmsDatabase.Types.FAILED_DECRYPT_TYPE) {
|
||||||
|
super.setBody(context.getString(R.string.MessageDisplayHelper_bad_encrypted_message));
|
||||||
|
setEmphasis(true);
|
||||||
|
} else if (this.type == SmsDatabase.Types.DECRYPT_IN_PROGRESS_TYPE ||
|
||||||
|
(type == 0 && body.startsWith(Prefix.ASYMMETRIC_ENCRYPT)) ||
|
||||||
|
(type == 0 && body.startsWith(Prefix.ASYMMETRIC_LOCAL_ENCRYPT)))
|
||||||
|
{
|
||||||
|
super.setBody(context.getString(R.string.MessageDisplayHelper_decrypting_please_wait));
|
||||||
|
setEmphasis(true);
|
||||||
|
} else if (type == SmsDatabase.Types.NO_SESSION_TYPE) {
|
||||||
|
super.setBody(context.getString(R.string.MessageDisplayHelper_message_encrypted_for_non_existing_session));
|
||||||
|
setEmphasis(true);
|
||||||
|
} else {
|
||||||
|
super.setBody(body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFailed() {
|
||||||
|
return SmsDatabase.Types.isFailedMessageType(getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOutgoing() {
|
||||||
|
return SmsDatabase.Types.isOutgoingMessageType(getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPending() {
|
||||||
|
return SmsDatabase.Types.isPendingMessageType(getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSecure() {
|
||||||
|
return SmsDatabase.Types.isSecureType(getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMms() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class GroupData {
|
||||||
|
public final int groupSize;
|
||||||
|
public final int groupSentCount;
|
||||||
|
public final int groupSendFailedCount;
|
||||||
|
|
||||||
|
public GroupData(int groupSize, int groupSentCount, int groupSendFailedCount) {
|
||||||
|
this.groupSize = groupSize;
|
||||||
|
this.groupSentCount = groupSentCount;
|
||||||
|
this.groupSendFailedCount = groupSendFailedCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2012 Moxie Marlinspike
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.thoughtcrime.securesms.database.model;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.protocol.Prefix;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message record model which represents thread heading messages.
|
||||||
|
*
|
||||||
|
* @author Moxie Marlinspike
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ThreadRecord extends DisplayRecord {
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
private final long count;
|
||||||
|
private final boolean read;
|
||||||
|
|
||||||
|
public ThreadRecord(Context context, Recipients recipients,
|
||||||
|
long date, long count,
|
||||||
|
boolean read, long threadId)
|
||||||
|
{
|
||||||
|
super(recipients, date, threadId);
|
||||||
|
this.context = context.getApplicationContext();
|
||||||
|
this.count = count;
|
||||||
|
this.read = read;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBody(String body) {
|
||||||
|
if (body.startsWith(Prefix.SYMMETRIC_ENCRYPT) ||
|
||||||
|
body.startsWith(Prefix.ASYMMETRIC_ENCRYPT) ||
|
||||||
|
body.startsWith(Prefix.ASYMMETRIC_LOCAL_ENCRYPT))
|
||||||
|
{
|
||||||
|
super.setBody(context.getString(R.string.ConversationListAdapter_encrypted_message_enter_passphrase));
|
||||||
|
setEmphasis(true);
|
||||||
|
} else if (body.startsWith(Prefix.KEY_EXCHANGE)) {
|
||||||
|
super.setBody(context.getString(R.string.ConversationListAdapter_key_exchange_message));
|
||||||
|
setEmphasis(true);
|
||||||
|
} else {
|
||||||
|
super.setBody(body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRead() {
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,79 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2011 Whisper Systems
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.thoughtcrime.securesms.mms;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
||||||
import org.thoughtcrime.securesms.database.MessageRecord;
|
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
|
||||||
import org.thoughtcrime.securesms.database.MmsMessageRecord;
|
|
||||||
|
|
||||||
import ws.com.google.android.mms.MmsException;
|
|
||||||
import ws.com.google.android.mms.pdu.MultimediaMessagePdu;
|
|
||||||
import ws.com.google.android.mms.pdu.NotificationInd;
|
|
||||||
import ws.com.google.android.mms.pdu.PduHeaders;
|
|
||||||
|
|
||||||
public class MmsFactory {
|
|
||||||
|
|
||||||
public static MmsMessageRecord getMms(Context context, MasterSecret masterSecret, MessageRecord record, long mmsType, long box) throws MmsException {
|
|
||||||
Log.w("MmsFactory", "MMS Type: " + mmsType);
|
|
||||||
if (mmsType == PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND) {
|
|
||||||
return getNotificationMmsRecord(context, record);
|
|
||||||
} else {
|
|
||||||
return getMediaMmsRecord(context, masterSecret, record, box);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MmsMessageRecord getNotificationMmsRecord(Context context, MessageRecord record) throws MmsException {
|
|
||||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
|
||||||
NotificationInd notification = database.getNotificationMessage(record.getId());
|
|
||||||
return new MmsMessageRecord(record, notification.getContentLocation(), notification.getMessageSize(),
|
|
||||||
notification.getExpiry(), notification.getStatus(), notification.getTransactionId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MmsMessageRecord getMediaMmsRecord(Context context, MasterSecret masterSecret, MessageRecord record, long box) throws MmsException {
|
|
||||||
MmsDatabase database = DatabaseFactory.getEncryptingMmsDatabase(context, masterSecret);
|
|
||||||
MultimediaMessagePdu msg = database.getMediaMessage(record.getId());
|
|
||||||
SlideDeck slideDeck = new SlideDeck(context, masterSecret, msg.getBody());
|
|
||||||
|
|
||||||
return new MmsMessageRecord(context, record, slideDeck, box);
|
|
||||||
}
|
|
||||||
|
|
||||||
// private static void setBodyIfText(SlideModel slide, MessageRecord record) {
|
|
||||||
// if ((slide != null) && slide.hasText()) {
|
|
||||||
// TextModel tm = slide.getText();
|
|
||||||
//
|
|
||||||
// if (tm.isDrmProtected()) {
|
|
||||||
// record.setBody("DRM protected");
|
|
||||||
// } else {
|
|
||||||
// record.setBody(tm.getText());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static SlideshowModel getSlideshowModel(Context context, long messageId) throws MmsException {
|
|
||||||
// LayoutManager.init(context);
|
|
||||||
// MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
|
||||||
// MultimediaMessagePdu msg = database.getMediaMessage(messageId);
|
|
||||||
// return SlideshowModel.createFromPduBody(context, msg.getBody());
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue