import 'dart:convert'; import 'dart:typed_data'; import 'package:immich_mobile/domain/services/store.service.dart'; import 'package:immich_mobile/entities/user.entity.dart'; // ignore: non_constant_identifier_names final Store = StoreService.I; class SSLClientCertStoreVal { final Uint8List data; final String? password; SSLClientCertStoreVal(this.data, this.password); void save() { final b64Str = base64Encode(data); Store.put(StoreKey.sslClientCertData, b64Str); if (password != null) { Store.put(StoreKey.sslClientPasswd, password!); } } static SSLClientCertStoreVal? load() { final b64Str = Store.tryGet(StoreKey.sslClientCertData); if (b64Str == null) { return null; } final Uint8List certData = base64Decode(b64Str); final passwd = Store.tryGet(StoreKey.sslClientPasswd); return SSLClientCertStoreVal(certData, passwd); } static void delete() { Store.delete(StoreKey.sslClientCertData); Store.delete(StoreKey.sslClientPasswd); } } /// Key for each possible value in the `Store`. /// Defines the data type for each value enum StoreKey { version._(0), assetETag._(1), currentUser._(2), deviceIdHash._(3), deviceId._(4), backupFailedSince._(5), backupRequireWifi._(6), backupRequireCharging._(7), backupTriggerDelay._(8), serverUrl._(10), accessToken._(11), serverEndpoint._(12), autoBackup._(13), backgroundBackup._(14), sslClientCertData._(15), sslClientPasswd._(16), // user settings from [AppSettingsEnum] below: loadPreview._(100), loadOriginal._(101), themeMode._(102), tilesPerRow._(103), dynamicLayout._(104), groupAssetsBy._(105), uploadErrorNotificationGracePeriod._(106), backgroundBackupTotalProgress._(107), backgroundBackupSingleProgress._(108), storageIndicator._(109), thumbnailCacheSize._(110), imageCacheSize._(111), albumThumbnailCacheSize._(112), selectedAlbumSortOrder._(113), advancedTroubleshooting._(114), logLevel._(115), preferRemoteImage._(116), loopVideo._(117), // map related settings mapShowFavoriteOnly._(118), mapRelativeDate._(119), selfSignedCert._(120), mapIncludeArchived._(121), ignoreIcloudAssets._(122), selectedAlbumSortReverse._(123), mapThemeMode._(124), mapwithPartners._(125), enableHapticFeedback._(126), customHeaders._(127), // theme settings primaryColor._(128), dynamicTheme._(129), colorfulInterface._(130), syncAlbums._(131), // Auto endpoint switching autoEndpointSwitching._(132), preferredWifiName._(133), localEndpoint._(134), externalEndpointList._(135), // Video settings loadOriginalVideo._(136), ; const StoreKey._(this.id); final int id; Type get type => T; } class StoreUpdateEvent { final StoreKey key; final T? value; const StoreUpdateEvent(this.key, this.value); }