That fuck shit the fascists are using
1/**
2 * Copyright (C) 2011 Whisper Systems
3 *
4 * This program 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 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17package org.tm.archive.database;
18
19import android.content.Context;
20
21import org.tm.archive.dependencies.ApplicationDependencies;
22
23import java.util.HashSet;
24import java.util.Set;
25
26public abstract class DatabaseTable {
27
28 protected static final String ID_WHERE = "_id = ?";
29 protected static final String[] COUNT = new String[] { "COUNT(*)" };
30
31 protected SignalDatabase databaseHelper;
32 protected final Context context;
33
34 static final Set<RecipientIdDatabaseReference> recipientIdDatabaseTables = new HashSet<>();
35 static final Set<ThreadIdDatabaseReference> threadIdDatabaseTables = new HashSet<>();
36
37 public DatabaseTable(Context context, SignalDatabase databaseHelper) {
38 this.context = context;
39 this.databaseHelper = databaseHelper;
40
41 if (this instanceof RecipientIdDatabaseReference) {
42 recipientIdDatabaseTables.add((RecipientIdDatabaseReference) this);
43 }
44
45 if (this instanceof ThreadIdDatabaseReference) {
46 threadIdDatabaseTables.add((ThreadIdDatabaseReference) this);
47 }
48 }
49
50 protected void notifyConversationListeners(Set<Long> threadIds) {
51 ApplicationDependencies.getDatabaseObserver().notifyConversationListeners(threadIds);
52 }
53
54 protected void notifyConversationListeners(long threadId) {
55 ApplicationDependencies.getDatabaseObserver().notifyConversationListeners(threadId);
56 }
57
58 protected void notifyVerboseConversationListeners(Set<Long> threadIds) {
59 ApplicationDependencies.getDatabaseObserver().notifyVerboseConversationListeners(threadIds);
60 }
61
62 protected void notifyConversationListListeners() {
63 ApplicationDependencies.getDatabaseObserver().notifyConversationListListeners();
64 }
65
66 protected void notifyStickerPackListeners() {
67 ApplicationDependencies.getDatabaseObserver().notifyStickerPackObservers();
68 }
69
70 protected void notifyStickerListeners() {
71 ApplicationDependencies.getDatabaseObserver().notifyStickerObservers();
72 }
73
74 protected void notifyAttachmentListeners() {
75 ApplicationDependencies.getDatabaseObserver().notifyAttachmentObservers();
76 }
77
78 public void reset(SignalDatabase databaseHelper) {
79 this.databaseHelper = databaseHelper;
80 }
81
82 public SQLiteDatabase getReadableDatabase() {
83 return databaseHelper.getSignalReadableDatabase();
84 }
85
86 public SQLiteDatabase getWritableDatabase() {
87 return databaseHelper.getSignalWritableDatabase();
88 }
89}