2019-10-02 11:33:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Christian Pauly <krille@famedly.com>
|
|
|
|
* Marcel Radzio <mtrnord@famedly.com>
|
|
|
|
*
|
|
|
|
* This file is part of famedlysdk.
|
|
|
|
*
|
|
|
|
* famedlysdk 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.
|
|
|
|
*
|
|
|
|
* famedlysdk 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 famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:core';
|
Update lib/src/client.dart, lib/src/user.dart, lib/src/timeline.dart, lib/src/room.dart, lib/src/presence.dart, lib/src/event.dart, lib/src/utils/profile.dart, lib/src/utils/receipt.dart, test/client_test.dart, test/event_test.dart, test/presence_test.dart, test/room_test.dart, test/timeline_test.dart, test/user_test.dart files
2020-01-04 17:56:17 +00:00
|
|
|
import 'package:famedlysdk/src/account_data.dart';
|
|
|
|
import 'package:famedlysdk/src/presence.dart';
|
2020-02-04 13:41:13 +00:00
|
|
|
import 'package:famedlysdk/src/utils/device_keys_list.dart';
|
Update lib/src/client.dart, lib/src/user.dart, lib/src/timeline.dart, lib/src/room.dart, lib/src/presence.dart, lib/src/event.dart, lib/src/utils/profile.dart, lib/src/utils/receipt.dart, test/client_test.dart, test/event_test.dart, test/presence_test.dart, test/room_test.dart, test/timeline_test.dart, test/user_test.dart files
2020-01-04 17:56:17 +00:00
|
|
|
import 'client.dart';
|
|
|
|
import 'event.dart';
|
|
|
|
import 'room.dart';
|
|
|
|
import 'user.dart';
|
|
|
|
import 'sync/event_update.dart';
|
|
|
|
import 'sync/room_update.dart';
|
|
|
|
import 'sync/user_update.dart';
|
2019-10-02 11:33:01 +00:00
|
|
|
|
|
|
|
abstract class StoreAPI {
|
2020-01-24 16:42:51 +00:00
|
|
|
/// Whether this is a simple store which only stores the client credentials and
|
|
|
|
/// end to end encryption stuff or the whole sync payloads.
|
|
|
|
final bool extended = false;
|
|
|
|
|
|
|
|
/// Link back to the client.
|
2019-10-02 11:33:01 +00:00
|
|
|
Client client;
|
|
|
|
|
|
|
|
/// Will be automatically called when the client is logged in successfully.
|
|
|
|
Future<void> storeClient();
|
|
|
|
|
|
|
|
/// Clears all tables from the database.
|
|
|
|
Future<void> clear();
|
2020-02-04 13:41:13 +00:00
|
|
|
|
|
|
|
Future<void> storeUserDeviceKeys(Map<String, DeviceKeysList> userDeviceKeys);
|
|
|
|
|
|
|
|
Future<Map<String, DeviceKeysList>> getUserDeviceKeys();
|
2020-01-24 16:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Responsible to store all data persistent and to query objects from the
|
|
|
|
/// database.
|
|
|
|
abstract class ExtendedStoreAPI extends StoreAPI {
|
|
|
|
/// Whether this is a simple store which only stores the client credentials and
|
|
|
|
/// end to end encryption stuff or the whole sync payloads.
|
|
|
|
final bool extended = true;
|
2019-10-02 11:33:01 +00:00
|
|
|
|
2020-01-24 09:34:38 +00:00
|
|
|
/// The current trans
|
|
|
|
Future<void> setRoomPrevBatch(String roomId, String prevBatch);
|
2019-10-02 11:33:01 +00:00
|
|
|
|
2020-01-24 09:34:38 +00:00
|
|
|
/// Performs these query or queries inside of an transaction.
|
2020-01-06 20:21:25 +00:00
|
|
|
Future<void> transaction(void queries());
|
2019-10-02 11:33:01 +00:00
|
|
|
|
|
|
|
/// Will be automatically called on every synchronisation. Must be called inside of
|
|
|
|
// /// [transaction].
|
2020-01-06 20:21:25 +00:00
|
|
|
void storePrevBatch(String prevBatch);
|
2019-10-02 11:33:01 +00:00
|
|
|
|
|
|
|
Future<void> storeRoomPrevBatch(Room room);
|
|
|
|
|
|
|
|
/// Stores a RoomUpdate object in the database. Must be called inside of
|
|
|
|
/// [transaction].
|
|
|
|
Future<void> storeRoomUpdate(RoomUpdate roomUpdate);
|
|
|
|
|
|
|
|
/// Stores an UserUpdate object in the database. Must be called inside of
|
|
|
|
/// [transaction].
|
|
|
|
Future<void> storeUserEventUpdate(UserUpdate userUpdate);
|
|
|
|
|
|
|
|
/// Stores an EventUpdate object in the database. Must be called inside of
|
|
|
|
/// [transaction].
|
|
|
|
Future<void> storeEventUpdate(EventUpdate eventUpdate);
|
|
|
|
|
|
|
|
/// Returns a User object by a given Matrix ID and a Room.
|
|
|
|
Future<User> getUser({String matrixID, Room room});
|
|
|
|
|
|
|
|
/// Returns a list of events for the given room and sets all participants.
|
|
|
|
Future<List<Event>> getEventList(Room room);
|
|
|
|
|
|
|
|
/// Returns all rooms, the client is participating. Excludes left rooms.
|
|
|
|
Future<List<Room>> getRoomList({bool onlyLeft = false});
|
|
|
|
|
2020-01-24 09:34:38 +00:00
|
|
|
/// Deletes this room from the database.
|
2019-10-02 11:33:01 +00:00
|
|
|
Future<void> forgetRoom(String roomID);
|
|
|
|
|
2020-01-24 09:34:38 +00:00
|
|
|
/// Sets notification and highlight count to 0 for this room.
|
2019-12-17 11:07:25 +00:00
|
|
|
Future<void> resetNotificationCount(String roomID);
|
|
|
|
|
2019-10-02 11:33:01 +00:00
|
|
|
/// Searches for the event in the store.
|
|
|
|
Future<Event> getEventById(String eventID, Room room);
|
|
|
|
|
2020-01-24 09:34:38 +00:00
|
|
|
/// Returns all account data for this client.
|
2019-10-02 11:33:01 +00:00
|
|
|
Future<Map<String, AccountData>> getAccountData();
|
|
|
|
|
2020-01-24 09:34:38 +00:00
|
|
|
/// Returns all stored presences for this client.
|
2019-10-02 11:33:01 +00:00
|
|
|
Future<Map<String, Presence>> getPresences();
|
|
|
|
|
2020-01-24 09:34:38 +00:00
|
|
|
/// Removes this event from the store.
|
2019-10-02 11:33:01 +00:00
|
|
|
Future removeEvent(String eventId);
|
|
|
|
}
|