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-09-28 12:47:43 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             : 
      31           1 :   bool get supportsFileStoring => false;
      32             : 
      33             :   Future<Map<String, dynamic>?> getClient(String name);
      34             : 
      35             :   Future updateClient(
      36             :     String homeserverUrl,
      37             :     String token,
      38             :     DateTime? tokenExpiresAt,
      39             :     String? refreshToken,
      40             :     String userId,
      41             :     String? deviceId,
      42             :     String? deviceName,
      43             :     String? prevBatch,
      44             :     String? olmAccount,
      45             :   );
      46             : 
      47             :   Future insertClient(
      48             :     String name,
      49             :     String homeserverUrl,
      50             :     String token,
      51             :     DateTime? tokenExpiresAt,
      52             :     String? refreshToken,
      53             :     String userId,
      54             :     String? deviceId,
      55             :     String? deviceName,
      56             :     String? prevBatch,
      57             :     String? olmAccount,
      58             :   );
      59             : 
      60             :   Future<List<Room>> getRoomList(Client client);
      61             : 
      62             :   Future<Room?> getSingleRoom(Client client, String roomId,
      63             :       {bool loadImportantStates = true});
      64             : 
      65             :   Future<Map<String, BasicEvent>> getAccountData();
      66             : 
      67             :   /// Stores a RoomUpdate object in the database. Must be called inside of
      68             :   /// [transaction].
      69             :   Future<void> storeRoomUpdate(
      70             :     String roomId,
      71             :     SyncRoomUpdate roomUpdate,
      72             :     Event? lastEvent,
      73             :     Client client,
      74             :   );
      75             : 
      76             :   Future<void> deleteTimelineForRoom(String roomId);
      77             : 
      78             :   /// Stores an EventUpdate object in the database. Must be called inside of
      79             :   /// [transaction].
      80             :   Future<void> storeEventUpdate(EventUpdate eventUpdate, Client client);
      81             : 
      82             :   Future<Event?> getEventById(String eventId, Room room);
      83             : 
      84             :   Future<void> forgetRoom(String roomId);
      85             : 
      86             :   Future<CachedProfileInformation?> getUserProfile(String userId);
      87             : 
      88             :   Future<void> storeUserProfile(
      89             :       String userId, CachedProfileInformation profile);
      90             : 
      91             :   Future<void> markUserProfileAsOutdated(String userId);
      92             : 
      93             :   Future<void> clearCache();
      94             : 
      95             :   Future<void> clear();
      96             : 
      97             :   Future<User?> getUser(String userId, Room room);
      98             : 
      99             :   Future<List<User>> getUsers(Room room);
     100             : 
     101             :   Future<List<Event>> getEventList(
     102             :     Room room, {
     103             :     int start = 0,
     104             :     bool onlySending = false,
     105             :     int? limit,
     106             :   });
     107             : 
     108             :   Future<List<String>> getEventIdList(
     109             :     Room room, {
     110             :     int start = 0,
     111             :     bool includeSending = false,
     112             :     int? limit,
     113             :   });
     114             : 
     115             :   Future<Uint8List?> getFile(Uri mxcUri);
     116             : 
     117             :   Future storeFile(Uri mxcUri, Uint8List bytes, int time);
     118             : 
     119             :   Future storeSyncFilterId(
     120             :     String syncFilterId,
     121             :   );
     122             : 
     123             :   Future storeAccountData(String type, String content);
     124             : 
     125             :   Future<Map<String, DeviceKeysList>> getUserDeviceKeys(Client client);
     126             : 
     127             :   Future<SSSSCache?> getSSSSCache(String type);
     128             : 
     129             :   Future<OutboundGroupSession?> getOutboundGroupSession(
     130             :     String roomId,
     131             :     String userId,
     132             :   );
     133             : 
     134             :   Future<List<StoredInboundGroupSession>> getAllInboundGroupSessions();
     135             : 
     136             :   Future<StoredInboundGroupSession?> getInboundGroupSession(
     137             :     String roomId,
     138             :     String sessionId,
     139             :   );
     140             : 
     141             :   Future updateInboundGroupSessionIndexes(
     142             :     String indexes,
     143             :     String roomId,
     144             :     String sessionId,
     145             :   );
     146             : 
     147             :   Future storeInboundGroupSession(
     148             :     String roomId,
     149             :     String sessionId,
     150             :     String pickle,
     151             :     String content,
     152             :     String indexes,
     153             :     String allowedAtIndex,
     154             :     String senderKey,
     155             :     String senderClaimedKey,
     156             :   );
     157             : 
     158             :   Future markInboundGroupSessionAsUploaded(
     159             :     String roomId,
     160             :     String sessionId,
     161             :   );
     162             : 
     163             :   Future updateInboundGroupSessionAllowedAtIndex(
     164             :     String allowedAtIndex,
     165             :     String roomId,
     166             :     String sessionId,
     167             :   );
     168             : 
     169             :   Future removeOutboundGroupSession(String roomId);
     170             : 
     171             :   Future storeOutboundGroupSession(
     172             :     String roomId,
     173             :     String pickle,
     174             :     String deviceIds,
     175             :     int creationTime,
     176             :   );
     177             : 
     178             :   Future updateClientKeys(
     179             :     String olmAccount,
     180             :   );
     181             : 
     182             :   Future storeOlmSession(
     183             :     String identityKey,
     184             :     String sessionId,
     185             :     String pickle,
     186             :     int lastReceived,
     187             :   );
     188             : 
     189             :   Future setLastActiveUserDeviceKey(
     190             :     int lastActive,
     191             :     String userId,
     192             :     String deviceId,
     193             :   );
     194             : 
     195             :   Future setLastSentMessageUserDeviceKey(
     196             :     String lastSentMessage,
     197             :     String userId,
     198             :     String deviceId,
     199             :   );
     200             : 
     201             :   Future clearSSSSCache();
     202             : 
     203             :   Future storeSSSSCache(
     204             :     String type,
     205             :     String keyId,
     206             :     String ciphertext,
     207             :     String content,
     208             :   );
     209             : 
     210             :   Future markInboundGroupSessionsAsNeedingUpload();
     211             : 
     212             :   Future storePrevBatch(
     213             :     String prevBatch,
     214             :   );
     215             : 
     216             :   Future deleteOldFiles(int savedAt);
     217             : 
     218             :   Future storeUserDeviceKeysInfo(
     219             :     String userId,
     220             :     bool outdated,
     221             :   );
     222             : 
     223             :   Future storeUserDeviceKey(
     224             :     String userId,
     225             :     String deviceId,
     226             :     String content,
     227             :     bool verified,
     228             :     bool blocked,
     229             :     int lastActive,
     230             :   );
     231             : 
     232             :   Future removeUserDeviceKey(
     233             :     String userId,
     234             :     String deviceId,
     235             :   );
     236             : 
     237             :   Future removeUserCrossSigningKey(
     238             :     String userId,
     239             :     String publicKey,
     240             :   );
     241             : 
     242             :   Future storeUserCrossSigningKey(
     243             :     String userId,
     244             :     String publicKey,
     245             :     String content,
     246             :     bool verified,
     247             :     bool blocked,
     248             :   );
     249             : 
     250             :   Future deleteFromToDeviceQueue(int id);
     251             : 
     252             :   Future removeEvent(String eventId, String roomId);
     253             : 
     254             :   Future setRoomPrevBatch(
     255             :     String? prevBatch,
     256             :     String roomId,
     257             :     Client client,
     258             :   );
     259             : 
     260             :   Future setVerifiedUserCrossSigningKey(
     261             :     bool verified,
     262             :     String userId,
     263             :     String publicKey,
     264             :   );
     265             : 
     266             :   Future setBlockedUserCrossSigningKey(
     267             :     bool blocked,
     268             :     String userId,
     269             :     String publicKey,
     270             :   );
     271             : 
     272             :   Future setVerifiedUserDeviceKey(
     273             :     bool verified,
     274             :     String userId,
     275             :     String deviceId,
     276             :   );
     277             : 
     278             :   Future setBlockedUserDeviceKey(
     279             :     bool blocked,
     280             :     String userId,
     281             :     String deviceId,
     282             :   );
     283             : 
     284             :   Future<List<Event>> getUnimportantRoomEventStatesForRoom(
     285             :     List<String> events,
     286             :     Room room,
     287             :   );
     288             : 
     289             :   Future<List<OlmSession>> getOlmSessions(
     290             :     String identityKey,
     291             :     String userId,
     292             :   );
     293             : 
     294             :   Future<Map<String, Map>> getAllOlmSessions();
     295             : 
     296             :   Future<List<OlmSession>> getOlmSessionsForDevices(
     297             :     List<String> identityKeys,
     298             :     String userId,
     299             :   );
     300             : 
     301             :   Future<List<QueuedToDeviceEvent>> getToDeviceEventQueue();
     302             : 
     303             :   /// Please do `jsonEncode(content)` in your code to stay compatible with
     304             :   /// auto generated methods here.
     305             :   Future insertIntoToDeviceQueue(
     306             :     String type,
     307             :     String txnId,
     308             :     String content,
     309             :   );
     310             : 
     311             :   Future<List<String>> getLastSentMessageUserDeviceKey(
     312             :     String userId,
     313             :     String deviceId,
     314             :   );
     315             : 
     316             :   Future<List<StoredInboundGroupSession>> getInboundGroupSessionsToUpload();
     317             : 
     318             :   Future<void> addSeenDeviceId(
     319             :       String userId, String deviceId, String publicKeys);
     320             : 
     321             :   Future<void> addSeenPublicKey(String publicKey, String deviceId);
     322             : 
     323             :   Future<String?> deviceIdSeen(userId, deviceId);
     324             : 
     325             :   Future<String?> publicKeySeen(String publicKey);
     326             : 
     327             :   Future<dynamic> close();
     328             : 
     329             :   Future<void> transaction(Future<void> Function() action);
     330             : 
     331             :   Future<String> exportDump();
     332             : 
     333             :   Future<bool> importDump(String export);
     334             : 
     335             :   Future<void> storePresence(String userId, CachedPresence presence);
     336             : 
     337             :   Future<CachedPresence?> getPresence(String userId);
     338             : 
     339             :   Future<void> storeWellKnown(DiscoveryInformation? discoveryInformation);
     340             : 
     341             :   Future<DiscoveryInformation?> getWellKnown();
     342             : 
     343             :   /// Deletes the whole database. The database needs to be created again after
     344             :   /// this.
     345             :   Future<void> delete();
     346             : }

Generated by: LCOV version 1.14