Files
FairEmail/app/src/main/java/eu/faircode/email/DaoIdentity.java

82 lines
2.8 KiB
Java
Raw Normal View History

2018-08-02 13:33:06 +00:00
package eu.faircode.email;
/*
2018-08-14 05:53:24 +00:00
This file is part of FairEmail.
2018-08-02 13:33:06 +00:00
2018-08-14 05:53:24 +00:00
FairEmail is free software: you can redistribute it and/or modify
2018-08-02 13:33:06 +00:00
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.
2018-10-29 10:46:49 +00:00
FairEmail is distributed in the hope that it will be useful,
2018-08-02 13:33:06 +00:00
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
2018-10-29 10:46:49 +00:00
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
2018-08-02 13:33:06 +00:00
2018-12-31 08:04:33 +00:00
Copyright 2018-2019 by Marcel Bokhorst (M66B)
2018-08-02 13:33:06 +00:00
*/
import java.util.List;
2018-08-08 06:55:47 +00:00
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
2018-08-02 13:33:06 +00:00
@Dao
public interface DaoIdentity {
2018-08-08 10:22:12 +00:00
@Query("SELECT identity.*, account.name AS accountName FROM identity" +
" JOIN account ON account.id = identity.account")
LiveData<List<TupleIdentityEx>> liveIdentities();
2018-08-02 13:33:06 +00:00
@Query("SELECT identity.* FROM identity" +
" JOIN account ON account.id = identity.account" +
2018-11-09 12:21:12 +00:00
" WHERE (:account IS NULL OR account.id = :account)" +
" AND account.synchronize = :synchronize" +
" AND identity.synchronize = :synchronize")
2018-11-09 12:21:12 +00:00
LiveData<List<EntityIdentity>> liveIdentities(Long account, boolean synchronize);
2018-08-02 13:33:06 +00:00
2018-08-14 17:41:21 +00:00
@Query("SELECT * FROM identity")
List<EntityIdentity> getIdentities();
2018-09-14 11:33:22 +00:00
@Query("SELECT * FROM identity WHERE account = :account")
List<EntityIdentity> getIdentities(long account);
2018-08-02 13:33:06 +00:00
@Query("SELECT * FROM identity WHERE id = :id")
EntityIdentity getIdentity(long id);
2018-11-10 16:47:11 +00:00
@Query("SELECT * FROM identity WHERE account = :account AND email = :email")
EntityIdentity getIdentity(long account, String email);
@Query("SELECT COUNT(*) FROM identity WHERE synchronize")
int getSynchronizingIdentityCount();
2018-08-12 08:16:41 +00:00
@Insert
2018-08-02 13:33:06 +00:00
long insertIdentity(EntityIdentity identity);
@Update
void updateIdentity(EntityIdentity identity);
2018-08-15 11:26:59 +00:00
@Query("UPDATE identity SET state = :state WHERE id = :id")
int setIdentityState(long id, String state);
2018-08-27 16:19:56 +00:00
@Query("UPDATE identity SET password = :password WHERE id = :id")
int setIdentityPassword(long id, String password);
2018-08-15 11:26:59 +00:00
@Query("UPDATE identity SET error = :error WHERE id = :id")
int setIdentityError(long id, String error);
2018-12-27 17:01:07 +00:00
@Query("UPDATE identity SET `primary` = 0 WHERE account = :account")
void resetPrimary(long account);
2018-08-07 19:35:21 +00:00
@Query("UPDATE identity SET tbd = 1 WHERE id = :id")
int setIdentityTbd(long id);
@Query("DELETE FROM identity WHERE tbd = 1")
int deleteIdentitiesTbd();
2018-08-02 13:33:06 +00:00
}