LCOV - code coverage report
Current view: top level - lib/src/database - database_api.dart (source / functions) Hit Total Coverage
Test: merged.info Lines: 1 2 50.0 %
Date: 2024-05-13 12:56:47 Functions: 0 0 -

          Line data    Source code
       1             : /*
       2             :  *   Famedly Matrix SDK
       3             :  *   Copyright (C) 2021 Famedly GmbH
       4             :  *
       5             :  *   This program is free software: you can redistribute it and/or modify
       6             :  *   it under the terms of the GNU Affero General Public License as
       7             :  *   published by the Free Software Foundation, either version 3 of the
       8             :  *   License, or (at your option) any later version.
       9             :  *
      10             :  *   This program is distributed in the hope that it will be useful,
      11             :  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      13             :  *   GNU Affero General Public License for more details.
      14             :  *
      15             :  *   You should have received a copy of the GNU Affero General Public License
      16             :  *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
      17             :  */
      18             : 
      19             : import 'dart:typed_data';
      20             : 
      21             : import 'package:matrix/encryption/utils/olm_session.dart';
      22             : import 'package:matrix/encryption/utils/outbound_group_session.dart';
      23             : import 'package:matrix/encryption/utils/ssss_cache.dart';
      24             : import 'package:matrix/encryption/utils/stored_inbound_group_session.dart';
      25             : import 'package:matrix/matrix.dart';
      26             : import 'package:matrix/src/utils/queued_to_device_event.dart';
      27             : 
      28             : abstract class DatabaseApi {
      29           0 :   int get maxFileSize => 1 * 1024 * 1024;
      30           1 :   bool get supportsFileStoring => false;
      31             :   Future<Map<String, dynamic>?> getClient(String name);
      32             : 
      33             :   Future updateClient(
      34             :     String homeserverUrl,
      35             :     String token,
      36             :     DateTime? tokenExpiresAt,
      37             :     String? refreshToken,
      38             :     String userId,
      39             :     String? deviceId,
      40             :     String? deviceName,
      41             :     String? prevBatch,
      42             :     String? olmAccount,
      43             :   );
      44             : 
      45             :   Future insertClient(
      46             :     String name,
      47             :     String homeserverUrl,
      48             :     String token,
      49             :     DateTime? tokenExpiresAt,
      50             :     String? refreshToken,
      51             :     String userId,
      52             :     String? deviceId,
      53             :     String? deviceName,
      54             :     String? prevBatch,
      55             :     String? olmAccount,
      56             :   );
      57             : 
      58             :   Future<List<Room>> getRoomList(Client client);
      59             : 
      60             :   Future<Room?> getSingleRoom(Client client, String roomId,
      61             :       {bool loadImportantStates = true});
      62             : 
      63             :   Future<Map<String, BasicEvent>> getAccountData();
      64             : 
      65             :   /// Stores a RoomUpdate object in the database. Must be called inside of
      66             :   /// [transaction].
      67             :   Future<void> storeRoomUpdate(
      68             :     String roomId,
      69             :     SyncRoomUpdate roomUpdate,
      70             :     Event? lastEvent,
      71             :     Client client,
      72             :   );
      73             : 
      74             :   Future<void> deleteTimelineForRoom(String roomId);
      75             : 
      76             :   /// Stores an EventUpdate object in the database. Must be called inside of
      77             :   /// [transaction].
      78             :   Future<void> storeEventUpdate(EventUpdate eventUpdate, Client client);
      79             : 
      80             :   Future<Event?> getEventById(String eventId, Room room);
      81             : 
      82             :   Future<void> forgetRoom(String roomId);
      83             : 
      84             :   Future<void> clearCache();
      85             : 
      86             :   Future<void> clear();
      87             : 
      88             :   Future<User?> getUser(String userId, Room room);
      89             : 
      90             :   Future<List<User>> getUsers(Room room);
      91             : 
      92             :   Future<List<Event>> getEventList(
      93             :     Room room, {
      94             :     int start = 0,
      95             :     bool onlySending = false,
      96             :     int? limit,
      97             :   });
      98             : 
      99             :   Future<List<String>> getEventIdList(
     100             :     Room room, {
     101             :     int start = 0,
     102             :     bool includeSending = false,
     103             :     int? limit,
     104             :   });
     105             : 
     106             :   Future<Uint8List?> getFile(Uri mxcUri);
     107             : 
     108             :   Future storeFile(Uri mxcUri, Uint8List bytes, int time);
     109             : 
     110             :   Future storeSyncFilterId(
     111             :     String syncFilterId,
     112             :   );
     113             : 
     114             :   Future storeAccountData(String type, String content);
     115             : 
     116             :   Future<Map<String, DeviceKeysList>> getUserDeviceKeys(Client client);
     117             : 
     118             :   Future<SSSSCache?> getSSSSCache(String type);
     119             : 
     120             :   Future<OutboundGroupSession?> getOutboundGroupSession(
     121             :     String roomId,
     122             :     String userId,
     123             :   );
     124             : 
     125             :   Future<List<StoredInboundGroupSession>> getAllInboundGroupSessions();
     126             : 
     127             :   Future<StoredInboundGroupSession?> getInboundGroupSession(
     128             :     String roomId,
     129             :     String sessionId,
     130             :   );
     131             : 
     132             :   Future updateInboundGroupSessionIndexes(
     133             :     String indexes,
     134             :     String roomId,
     135             :     String sessionId,
     136             :   );
     137             : 
     138             :   Future storeInboundGroupSession(
     139             :     String roomId,
     140             :     String sessionId,
     141             :     String pickle,
     142             :     String content,
     143             :     String indexes,
     144             :     String allowedAtIndex,
     145             :     String senderKey,
     146             :     String senderClaimedKey,
     147             :   );
     148             : 
     149             :   Future markInboundGroupSessionAsUploaded(
     150             :     String roomId,
     151             :     String sessionId,
     152             :   );
     153             : 
     154             :   Future updateInboundGroupSessionAllowedAtIndex(
     155             :     String allowedAtIndex,
     156             :     String roomId,
     157             :     String sessionId,
     158             :   );
     159             : 
     160             :   Future removeOutboundGroupSession(String roomId);
     161             : 
     162             :   Future storeOutboundGroupSession(
     163             :     String roomId,
     164             :     String pickle,
     165             :     String deviceIds,
     166             :     int creationTime,
     167             :   );
     168             : 
     169             :   Future updateClientKeys(
     170             :     String olmAccount,
     171             :   );
     172             : 
     173             :   Future storeOlmSession(
     174             :     String identityKey,
     175             :     String sessionId,
     176             :     String pickle,
     177             :     int lastReceived,
     178             :   );
     179             : 
     180             :   Future setLastActiveUserDeviceKey(
     181             :     int lastActive,
     182             :     String userId,
     183             :     String deviceId,
     184             :   );
     185             : 
     186             :   Future setLastSentMessageUserDeviceKey(
     187             :     String lastSentMessage,
     188             :     String userId,
     189             :     String deviceId,
     190             :   );
     191             : 
     192             :   Future clearSSSSCache();
     193             : 
     194             :   Future storeSSSSCache(
     195             :     String type,
     196             :     String keyId,
     197             :     String ciphertext,
     198             :     String content,
     199             :   );
     200             : 
     201             :   Future markInboundGroupSessionsAsNeedingUpload();
     202             : 
     203             :   Future storePrevBatch(
     204             :     String prevBatch,
     205             :   );
     206             : 
     207             :   Future deleteOldFiles(int savedAt);
     208             : 
     209             :   Future storeUserDeviceKeysInfo(
     210             :     String userId,
     211             :     bool outdated,
     212             :   );
     213             : 
     214             :   Future storeUserDeviceKey(
     215             :     String userId,
     216             :     String deviceId,
     217             :     String content,
     218             :     bool verified,
     219             :     bool blocked,
     220             :     int lastActive,
     221             :   );
     222             : 
     223             :   Future removeUserDeviceKey(
     224             :     String userId,
     225             :     String deviceId,
     226             :   );
     227             : 
     228             :   Future removeUserCrossSigningKey(
     229             :     String userId,
     230             :     String publicKey,
     231             :   );
     232             : 
     233             :   Future storeUserCrossSigningKey(
     234             :     String userId,
     235             :     String publicKey,
     236             :     String content,
     237             :     bool verified,
     238             :     bool blocked,
     239             :   );
     240             : 
     241             :   Future deleteFromToDeviceQueue(int id);
     242             : 
     243             :   Future removeEvent(String eventId, String roomId);
     244             : 
     245             :   Future setRoomPrevBatch(
     246             :     String? prevBatch,
     247             :     String roomId,
     248             :     Client client,
     249             :   );
     250             : 
     251             :   Future setVerifiedUserCrossSigningKey(
     252             :     bool verified,
     253             :     String userId,
     254             :     String publicKey,
     255             :   );
     256             : 
     257             :   Future setBlockedUserCrossSigningKey(
     258             :     bool blocked,
     259             :     String userId,
     260             :     String publicKey,
     261             :   );
     262             : 
     263             :   Future setVerifiedUserDeviceKey(
     264             :     bool verified,
     265             :     String userId,
     266             :     String deviceId,
     267             :   );
     268             : 
     269             :   Future setBlockedUserDeviceKey(
     270             :     bool blocked,
     271             :     String userId,
     272             :     String deviceId,
     273             :   );
     274             : 
     275             :   Future<List<Event>> getUnimportantRoomEventStatesForRoom(
     276             :     List<String> events,
     277             :     Room room,
     278             :   );
     279             : 
     280             :   Future<List<OlmSession>> getOlmSessions(
     281             :     String identityKey,
     282             :     String userId,
     283             :   );
     284             : 
     285             :   Future<Map<String, Map>> getAllOlmSessions();
     286             : 
     287             :   Future<List<OlmSession>> getOlmSessionsForDevices(
     288             :     List<String> identityKeys,
     289             :     String userId,
     290             :   );
     291             : 
     292             :   Future<List<QueuedToDeviceEvent>> getToDeviceEventQueue();
     293             : 
     294             :   /// Please do `jsonEncode(content)` in your code to stay compatible with
     295             :   /// auto generated methods here.
     296             :   Future insertIntoToDeviceQueue(
     297             :     String type,
     298             :     String txnId,
     299             :     String content,
     300             :   );
     301             : 
     302             :   Future<List<String>> getLastSentMessageUserDeviceKey(
     303             :     String userId,
     304             :     String deviceId,
     305             :   );
     306             : 
     307             :   Future<List<StoredInboundGroupSession>> getInboundGroupSessionsToUpload();
     308             : 
     309             :   Future<void> addSeenDeviceId(
     310             :       String userId, String deviceId, String publicKeys);
     311             : 
     312             :   Future<void> addSeenPublicKey(String publicKey, String deviceId);
     313             : 
     314             :   Future<String?> deviceIdSeen(userId, deviceId);
     315             : 
     316             :   Future<String?> publicKeySeen(String publicKey);
     317             : 
     318             :   Future<dynamic> close();
     319             : 
     320             :   Future<void> transaction(Future<void> Function() action);
     321             : 
     322             :   Future<String> exportDump();
     323             : 
     324             :   Future<bool> importDump(String export);
     325             : 
     326             :   Future<void> storePresence(String userId, CachedPresence presence);
     327             : 
     328             :   Future<CachedPresence?> getPresence(String userId);
     329             : 
     330             :   /// Deletes the whole database. The database needs to be created again after
     331             :   /// this. Used for migration only.
     332             :   Future<void> delete();
     333             : }

Generated by: LCOV version 1.14