+ preKeyStore = new PreKeyStore(getPreKeysPath(dataPath, username));
+ signedPreKeyStore = new SignedPreKeyStore(getSignedPreKeysPath(dataPath, username));
+ sessionStore = new SessionStore(getSessionsPath(dataPath, username), recipientStore::resolveRecipient);
+ identityKeyStore = new IdentityKeyStore(getIdentitiesPath(dataPath, username),
+ recipientStore::resolveRecipient,
+ identityKeyPair,
+ registrationId);
+
+ loadLegacyStores(rootNode, legacySignalProtocolStore);
+
+ signalProtocolStore = new SignalProtocolStore(preKeyStore, signedPreKeyStore, sessionStore, identityKeyStore);
+
+ var groupStoreNode = rootNode.get("groupStore");
+ if (groupStoreNode != null) {
+ groupStore = jsonProcessor.convertValue(groupStoreNode, JsonGroupStore.class);
+ groupStore.groupCachePath = getGroupCachePath(dataPath, username);
+ }
+ if (groupStore == null) {
+ groupStore = new JsonGroupStore(getGroupCachePath(dataPath, username));
+ }
+
+ var stickerStoreNode = rootNode.get("stickerStore");
+ if (stickerStoreNode != null) {
+ stickerStore = jsonProcessor.convertValue(stickerStoreNode, StickerStore.class);
+ }
+ if (stickerStore == null) {
+ stickerStore = new StickerStore();
+ }
+
+ messageCache = new MessageCache(getMessageCachePath(dataPath, username));
+
+ loadLegacyThreadStore(rootNode);
+ }
+
+ private void loadLegacyStores(
+ final JsonNode rootNode, final LegacyJsonSignalProtocolStore legacySignalProtocolStore
+ ) {