1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 19:52:17 -05:00

factor out a "destroy" method for local messages

This commit is contained in:
Jesse Vincent 2010-11-12 21:38:02 +00:00
parent 1292a10ac2
commit 2d8a8998b0
3 changed files with 17 additions and 7 deletions

View File

@ -1183,7 +1183,7 @@ public class MessagingController implements Runnable
{ {
if (remoteUidMap.get(localMessage.getUid()) == null) if (remoteUidMap.get(localMessage.getUid()) == null)
{ {
localMessage.setFlag(Flag.X_DESTROYED, true); localMessage.destroy();
for (MessagingListener l : getListeners(listener)) for (MessagingListener l : getListeners(listener))
{ {
@ -2316,7 +2316,7 @@ public class MessagingController implements Runnable
* delete ours and move on. A sync will get the server message * delete ours and move on. A sync will get the server message
* if we need to be able to see it. * if we need to be able to see it.
*/ */
localMessage.setFlag(Flag.X_DESTROYED, true); localMessage.destroy();
} }
else else
{ {
@ -3507,7 +3507,7 @@ public class MessagingController implements Runnable
{ {
if (message.isSet(Flag.DELETED)) if (message.isSet(Flag.DELETED))
{ {
message.setFlag(Flag.X_DESTROYED, true); message.destroy();
continue; continue;
} }
if (message.isSet(Flag.FLAGGED)) if (message.isSet(Flag.FLAGGED))

View File

@ -199,6 +199,9 @@ public abstract class Message implements Part, Body
return mFlags.contains(flag); return mFlags.contains(flag);
} }
public void destroy() throws MessagingException {}
public abstract void saveChanges() throws MessagingException; public abstract void saveChanges() throws MessagingException;
public abstract void setEncoding(String encoding); public abstract void setEncoding(String encoding);

View File

@ -1158,7 +1158,7 @@ public class LocalStore extends Store implements Serializable
{ {
listener.messageRemoved(messages[i]); listener.messageRemoved(messages[i]);
} }
messages[i].setFlag(Flag.X_DESTROYED, true); messages[i].destroy();
} }
} }
@ -4879,8 +4879,6 @@ public class LocalStore extends Store implements Serializable
} }
else if (flag == Flag.X_DESTROYED && set) else if (flag == Flag.X_DESTROYED && set)
{ {
((LocalFolder) mFolder).deleteAttachments(mId);
mDb.execSQL("DELETE FROM messages WHERE id = ?", new Object[] { mId });
} }
/* /*
@ -4978,7 +4976,16 @@ public class LocalStore extends Store implements Serializable
} }
/*
* Completely remove a message from the local database
*/
@Override
public void destroy() throws MessagingException
{
((LocalFolder) mFolder).deleteAttachments(mId);
mDb.execSQL("DELETE FROM messages WHERE id = ?", new Object[] { mId });
setFlag(Flag.X_DESTROYED, true);
}
private void loadHeaders() private void loadHeaders()