/** * Returns <code>true</code> if conversation is in the given state */ public boolean hasState(ConversationState s) { return state.equals(s); }
/** * Returns <code>true</code> if conversation is in one of the given states */ public boolean hasState(ConversationState... states) { for (ConversationState s : states) { if (s.equals(state)) { return true; } } return false; }
@Override public boolean accept(ConversationMetadataItem item) { return state.equals(item.getConversationState()); } });
private Conversation loadConversation(ConversationMetadataItem item) throws SerializerException, ConversationLoadException { checkConversationQueue(); // logged-in conversations should use an encryption key which was received from the backend. EncryptionKey conversationEncryptionKey = encryptionKey; if (LOGGED_IN.equals(item.getConversationState())) { conversationEncryptionKey = item.getConversationEncryptionKey(); if (conversationEncryptionKey == null) { throw new ConversationLoadException("Missing conversation encryption key"); } } // TODO: use same serialization logic across the project final Conversation conversation = new Conversation(item.getDataFile(), item.getMessagesFile(), conversationEncryptionKey); conversation.setState(item.getConversationState()); // set the state same as the item's state conversation.setUserId(item.getUserId()); conversation.setConversationToken(item.getConversationToken()); // TODO: this would be overwritten by the next call // try to migrate legacy conversation first boolean migrated = conversation.migrateConversationData(); // if failed - load from encrypted data if (!migrated) { conversation.loadConversationData(); } // check inconsistency conversation.checkInternalConsistency(); return conversation; }
final String conversationToken = notNull(conversation.getConversationToken()); final String conversationLocalIdentifier = notNull(conversation.getLocalIdentifier()); final boolean legacyPayloads = ConversationState.LEGACY_PENDING.equals(conversation.getPrevState());
if (LOGGED_IN.equals(item.getConversationState())) { item.setConversationState(LOGGED_OUT);