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.

93 lines
3.0 KiB

6 years ago
  1. package eu.faircode.email;
  2. /*
  3. This file is part of FairEmail.
  4. FairEmail 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 androidx.annotation.NonNull;
  17. import androidx.room.Entity;
  18. import androidx.room.ForeignKey;
  19. import androidx.room.Index;
  20. import androidx.room.PrimaryKey;
  21. import static androidx.room.ForeignKey.CASCADE;
  22. @Entity(
  23. tableName = EntityIdentity.TABLE_NAME,
  24. foreignKeys = {
  25. @ForeignKey(childColumns = "account", entity = EntityAccount.class, parentColumns = "id", onDelete = CASCADE)
  26. },
  27. indices = {
  28. @Index(value = {"account"})
  29. }
  30. )
  31. public class EntityIdentity {
  32. static final String TABLE_NAME = "identity";
  33. @PrimaryKey(autoGenerate = true)
  34. public Long id;
  35. @NonNull
  36. public String name;
  37. @NonNull
  38. public String email;
  39. public String replyto;
  40. @NonNull
  41. public Long account;
  42. @NonNull
  43. public String host; // SMTP
  44. @NonNull
  45. public Integer port;
  46. @NonNull
  47. public Boolean starttls;
  48. @NonNull
  49. public String user;
  50. @NonNull
  51. public String password;
  52. @NonNull
  53. public Boolean primary;
  54. @NonNull
  55. public Boolean synchronize;
  56. public String state;
  57. public String error;
  58. @Override
  59. public boolean equals(Object obj) {
  60. if (obj instanceof EntityIdentity) {
  61. EntityIdentity other = (EntityIdentity) obj;
  62. return (this.name.equals(other.name) &&
  63. this.email.equals(other.email) &&
  64. (this.replyto == null ? other.replyto == null : this.replyto.equals(other.replyto)) &&
  65. this.account.equals(other.account) &&
  66. this.host.equals(other.host) &&
  67. this.port.equals(other.port) &&
  68. this.starttls.equals(other.starttls) &&
  69. this.user.equals(other.user) &&
  70. this.password.equals(other.password) &&
  71. this.primary.equals(other.primary) &&
  72. this.synchronize.equals(other.synchronize) &&
  73. (this.state == null ? other.state == null : this.state.equals(other.state)) &&
  74. (this.error == null ? other.error == null : this.error.equals(other.error)));
  75. } else
  76. return false;
  77. }
  78. @Override
  79. public String toString() {
  80. return name + (primary ? " ★" : "");
  81. }
  82. }