/** * Returns true if this conversation belongs to a logged-in user. */ public boolean isAuthenticated() { return hasState(LOGGED_IN); }
/** * Returns true if conversation is in "active" state (after receiving server response) */ public boolean hasActiveState() { return hasState(ConversationState.LOGGED_IN, ANONYMOUS); }
/** * Attempts to migrate from the legacy clear text format. * * @return <code>false</code> if failed. */ boolean migrateConversationData() throws SerializerException { long start = System.currentTimeMillis(); File legacyConversationDataFile = Util.getUnencryptedFilename(conversationDataFile); if (legacyConversationDataFile.exists()) { try { ApptentiveLog.d(CONVERSATION, "Migrating %sconversation data...", hasState(LOGGED_IN) ? "encrypted " : ""); FileSerializer serializer = isAuthenticated() ? new EncryptedFileSerializer(legacyConversationDataFile, getEncryptionKey()) : new FileSerializer(legacyConversationDataFile); conversationData = (ConversationData) serializer.deserialize(); ApptentiveLog.d(CONVERSATION, "Conversation data migrated (took %d ms)", System.currentTimeMillis() - start); return true; } finally { boolean deleted = legacyConversationDataFile.delete(); ApptentiveLog.d(CONVERSATION, "Legacy conversation file deleted: %b", deleted); } } return false; }
if (conversation.hasState(LOGGED_IN)) { for (ConversationMetadataItem item : conversationMetadata) { if (LOGGED_IN.equals(item.getConversationState())) { conversationMetadata.addItem(item); } else { assertTrue(conversation.getConversationId() != null || conversation.hasState(ANONYMOUS_PENDING) || conversation.hasState(LEGACY_PENDING), "Missing conversation id for state: %s", conversation.getState()); item.setConversationId(conversation.getConversationId()); if (conversation.hasState(LOGGED_IN)) { item.setConversationEncryptionKey(notNull(conversation.getEncryptionKey())); item.setUserId(notNull(conversation.getUserId()));
if (conversation.hasState(ANONYMOUS)) { singleThreadExecutor.execute(new Runnable() { @Override
case LEGACY_PENDING: { final HttpRequest fetchRequest = activeConversation.hasState(ANONYMOUS_PENDING) ? fetchConversationToken(activeConversation) : fetchLegacyConversation(activeConversation);