Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.6 KiB

  1. package eu.faircode.email;
  2. /*
  3. This file is part of Safe email.
  4. Safe email is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. NetGuard is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with NetGuard. If not, see <http://www.gnu.org/licenses/>.
  14. Copyright 2018 by Marcel Bokhorst (M66B)
  15. */
  16. import android.arch.persistence.room.Entity;
  17. import android.arch.persistence.room.ForeignKey;
  18. import android.arch.persistence.room.Ignore;
  19. import android.arch.persistence.room.Index;
  20. import android.arch.persistence.room.PrimaryKey;
  21. import android.support.annotation.NonNull;
  22. import javax.mail.BodyPart;
  23. import static android.arch.persistence.room.ForeignKey.CASCADE;
  24. @Entity(
  25. tableName = EntityAttachment.TABLE_NAME,
  26. foreignKeys = {
  27. @ForeignKey(childColumns = "message", entity = EntityMessage.class, parentColumns = "id", onDelete = CASCADE)
  28. },
  29. indices = {
  30. @Index(value = {"message"}),
  31. @Index(value = {"message", "sequence"}, unique = true)
  32. }
  33. )
  34. public class EntityAttachment {
  35. static final String TABLE_NAME = "attachment";
  36. @PrimaryKey(autoGenerate = true)
  37. public Long id;
  38. @NonNull
  39. public Long message;
  40. @NonNull
  41. public Integer sequence;
  42. public String name;
  43. @NonNull
  44. public String type;
  45. public Integer size;
  46. public Integer progress;
  47. public byte[] content;
  48. @Ignore
  49. BodyPart part;
  50. @Override
  51. public boolean equals(Object obj) {
  52. if (obj instanceof EntityAttachment) {
  53. EntityAttachment other = (EntityAttachment) obj;
  54. return (this.message.equals(other.message) &&
  55. this.sequence.equals(other.sequence) &&
  56. (this.name == null ? other.name == null : this.name.equals(other.name)) &&
  57. this.type.equals(other.type) &&
  58. (this.size == null ? other.size == null : this.size.equals(other.size)) &&
  59. (this.progress == null ? other.progress == null : this.progress.equals(other.progress)) &&
  60. (this.content == null ? other.content == null : other.content != null));
  61. } else
  62. return false;
  63. }
  64. }