@Override public void onSuccess(MXEncryptEventContentResult encryptEventContentResult) { // update the event content with the encrypted data event.type = encryptEventContentResult.mEventType; // Add the "m.relates_to" data to the encrypted event here JsonObject encryptedContent = encryptEventContentResult.mEventContent.getAsJsonObject(); if (relatesTo != null) { encryptedContent.add("m.relates_to", relatesTo); } event.updateContent(encryptedContent); mDataHandler.decryptEvent(event, null); // sending in progress mDataHandler.updateEventState(event, Event.SentState.SENDING); mDataHandler.getDataRetriever().getRoomsRestClient().sendEventToRoom(event.eventId, getRoomId(), encryptEventContentResult.mEventType, encryptEventContentResult.mEventContent.getAsJsonObject(), localCB); }
private void handleToDeviceEvent(Event event) { // Decrypt event if necessary decryptEvent(event, null); if (TextUtils.equals(event.getType(), Event.EVENT_TYPE_MESSAGE) && (null != event.getContent()) && TextUtils.equals(JsonUtils.getMessageMsgType(event.getContent()), "m.bad.encrypted")) { Log.e(LOG_TAG, "## handleToDeviceEvent() : Warning: Unable to decrypt to-device event : " + event.getContent()); } else { onToDeviceEvent(event); } }
/** * When the encryption is toogled, the room summaries must be updated * to display the right messages. */ private void decryptRoomSummaries() { if (null != getDataHandler().getStore()) { Collection<RoomSummary> summaries = getDataHandler().getStore().getSummaries(); for (RoomSummary summary : summaries) { mDataHandler.decryptEvent(summary.getLatestReceivedEvent(), null); } } }
@Override public void onLiveEvent(Event event, RoomState roomState) { if (TextUtils.equals(event.getType(), Event.EVENT_TYPE_MESSAGE) && !TextUtils.equals(event.getSender(), bobSession.getMyUserId())) { results.put("bobEcho", event); event.setClearData(null); bobSession.getDataHandler().decryptEvent(event, roomFromBobPOV.getTimeline().getTimelineId()); results.put("decrypted", event); lock1.countDown(); } } };
dataHandler.decryptEvent(indexedEvent, mEventTimeline.getTimelineId());
mDataHandler.decryptEvent(event, getTimelineId());
dataHandler.decryptEvent(event, timelineId);
bobSession.getDataHandler().decryptEvent(event, null); mCryptoTestHelper.checkEncryptedEvent(event, aliceRoomId, messageFromAlice, aliceSession);
Assert.assertFalse(bobSession.getDataHandler().decryptEvent(event, null));
bobSession.getDataHandler().decryptEvent(decryptedEvent, null); mCryptoTestHelper.checkEncryptedEvent(decryptedEvent, aliceRoomId, messageFromAlice, aliceSession);