2018-08-02 13:33:06 +00:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This file is part of Safe email.
|
|
|
|
|
|
|
|
Safe email 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.
|
|
|
|
|
|
|
|
NetGuard 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 NetGuard. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Copyright 2018 by Marcel Bokhorst (M66B)
|
|
|
|
*/
|
|
|
|
|
|
|
|
import android.arch.persistence.room.Entity;
|
|
|
|
import android.arch.persistence.room.ForeignKey;
|
|
|
|
import android.arch.persistence.room.Index;
|
|
|
|
import android.arch.persistence.room.PrimaryKey;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
|
2018-08-07 16:25:57 +00:00
|
|
|
import javax.mail.Address;
|
|
|
|
|
2018-08-02 13:33:06 +00:00
|
|
|
import static android.arch.persistence.room.ForeignKey.CASCADE;
|
|
|
|
|
|
|
|
// https://developer.android.com/training/data-storage/room/defining-data
|
|
|
|
|
|
|
|
@Entity(
|
|
|
|
tableName = EntityMessage.TABLE_NAME,
|
|
|
|
foreignKeys = {
|
2018-08-07 15:20:51 +00:00
|
|
|
@ForeignKey(childColumns = "account" , entity = EntityAccount.class, parentColumns = "id" , onDelete = CASCADE),
|
|
|
|
@ForeignKey(childColumns = "folder" , entity = EntityFolder.class, parentColumns = "id" , onDelete = CASCADE),
|
|
|
|
@ForeignKey(childColumns = "identity" , entity = EntityIdentity.class, parentColumns = "id" , onDelete = CASCADE),
|
|
|
|
@ForeignKey(childColumns = "replying" , entity = EntityMessage.class, parentColumns = "id" , onDelete = CASCADE)
|
2018-08-02 13:33:06 +00:00
|
|
|
},
|
|
|
|
indices = {
|
|
|
|
@Index(value = {"account"}),
|
|
|
|
@Index(value = {"folder"}),
|
|
|
|
@Index(value = {"identity"}),
|
|
|
|
@Index(value = {"replying"}),
|
2018-08-07 15:20:51 +00:00
|
|
|
@Index(value = {"folder" , "uid"}, unique = true),
|
2018-08-02 13:33:06 +00:00
|
|
|
@Index(value = {"thread"}),
|
2018-08-05 11:44:46 +00:00
|
|
|
@Index(value = {"received"}),
|
|
|
|
@Index(value = {"ui_seen"}),
|
2018-08-07 08:00:17 +00:00
|
|
|
@Index(value = {"ui_hide"})
|
2018-08-02 13:33:06 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
public class EntityMessage {
|
|
|
|
static final String TABLE_NAME = "message";
|
|
|
|
|
|
|
|
@PrimaryKey(autoGenerate = true)
|
|
|
|
public Long id;
|
|
|
|
public Long account; // performance, compose = null
|
|
|
|
@NonNull
|
|
|
|
public Long folder;
|
|
|
|
public Long identity;
|
|
|
|
public Long replying;
|
|
|
|
public Long uid; // compose = null
|
|
|
|
public String msgid;
|
|
|
|
public String references;
|
|
|
|
public String inreplyto;
|
|
|
|
public String thread; // compose = null
|
2018-08-07 16:25:57 +00:00
|
|
|
public Address[] from;
|
|
|
|
public Address[] to;
|
|
|
|
public Address[] cc;
|
|
|
|
public Address[] bcc;
|
|
|
|
public Address[] reply;
|
2018-08-02 13:33:06 +00:00
|
|
|
public String subject;
|
|
|
|
public String body;
|
|
|
|
public Long sent; // compose = null
|
|
|
|
@NonNull
|
|
|
|
public Long received; // compose = stored
|
|
|
|
@NonNull
|
|
|
|
public Boolean seen;
|
|
|
|
@NonNull
|
|
|
|
public Boolean ui_seen;
|
|
|
|
@NonNull
|
|
|
|
public Boolean ui_hide;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (obj instanceof EntityMessage) {
|
|
|
|
EntityMessage other = (EntityMessage) obj;
|
2018-08-04 19:54:33 +00:00
|
|
|
return ((this.account == null ? other.account == null : this.account.equals(other.account)) &&
|
2018-08-02 13:33:06 +00:00
|
|
|
this.folder.equals(other.folder) &&
|
2018-08-04 19:54:33 +00:00
|
|
|
(this.identity == null ? other.identity == null : this.identity.equals(other.identity)) &&
|
|
|
|
(this.replying == null ? other.replying == null : this.replying.equals(other.replying)) &&
|
|
|
|
(this.uid == null ? other.uid == null : this.uid.equals(other.uid)) &&
|
|
|
|
(this.msgid == null ? other.msgid == null : this.msgid.equals(other.msgid)) &&
|
|
|
|
(this.references == null ? other.references == null : this.references.equals(other.references)) &&
|
|
|
|
(this.inreplyto == null ? other.inreplyto == null : this.inreplyto.equals(other.inreplyto)) &&
|
|
|
|
(this.thread == null ? other.thread == null : thread.equals(other.thread)) &&
|
|
|
|
(this.from == null ? other.from == null : this.from.equals(other.from)) &&
|
|
|
|
(this.to == null ? other.to == null : this.to.equals(other.to)) &&
|
|
|
|
(this.cc == null ? other.cc == null : this.cc.equals(other.cc)) &&
|
|
|
|
(this.bcc == null ? other.bcc == null : this.bcc.equals(other.bcc)) &&
|
|
|
|
(this.reply == null ? other.reply == null : this.reply.equals(other.reply)) &&
|
|
|
|
(this.subject == null ? other.subject == null : this.subject.equals(other.subject)) &&
|
|
|
|
(this.body == null ? other.body == null : this.body.equals(other.body)) &&
|
|
|
|
(this.sent == null ? other.sent == null : this.sent.equals(other.sent)) &&
|
2018-08-02 13:33:06 +00:00
|
|
|
this.received.equals(other.received) &&
|
|
|
|
this.seen.equals(other.seen) &&
|
|
|
|
this.ui_seen.equals(other.ui_seen) &&
|
|
|
|
this.ui_hide.equals(other.ui_hide));
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|