/** * Tells if an user is in the ignored user ids list * * @param userId the user id to test * @return true if the user is ignored */ public boolean isUserIgnored(String userId) { if (null != userId) { return getDataHandler().getIgnoredUserIds().indexOf(userId) >= 0; } return false; }
@Override public void onStoreCorrupted(String accountId, String description) { Log.d(LOG_TAG, "## onStoreCorrupted() : token " + getDataHandler().getStore().getEventStreamToken()); // nothing was saved if (null == getDataHandler().getStore().getEventStreamToken()) { getDataHandler().onStoreReady(); } }
@Override public void onStoreReady(String s) { session.getDataHandler().checkPermanentStorageData(); session.startEventStream(store.getEventStreamToken()); session.getDataHandler().addListener(evLis); }
@Override public void onStoreReady(String accountId) { Log.d(LOG_TAG, "## onStoreReady()"); getDataHandler().onStoreReady(); }
@Override public void run() { fEvent.setClearData(fResut); mSession.getDataHandler().onEventDecrypted(fEvent); } });
/** * Tells if the global URL preview settings is enabled * * @return true if it is enabled. */ public boolean isURLPreviewEnabled() { return getDataHandler().getStore().isURLPreviewEnabled(); }
/** * Get user widget from user AccountData * * @return */ public Map<String, Object> getUserWidgets() { return getDataHandler().getStore().getUserWidgets(); }
/** * 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 onSuccess(FilterResponse filter) { // Store the couple filter/filterId getDataHandler().getStore().addFilter(wantedJsonFilter, filter.filterId); // Ensure the filter is still corresponding to the current filter if (TextUtils.equals(wantedJsonFilter, mCurrentFilter.toJSONString())) { // Tell the event thread to use the id now mEventsThread.setFilterOrFilterId(filter.filterId); } } });
@Override public void onSuccess(Void info) { Room room = getDataHandler().getRoom(fRoomId); if (null != room) { room.markAllAsRead(null); } if (null != callback) { callback.onSuccess(fRoomId); } } });
@Override public void onSuccess(String roomId) { Log.d(LOG_TAG, "getConferenceUserRoom : the room creation succeeds"); Room room = mSession.getDataHandler().getRoom(roomId); if (null != room) { room.setIsConferenceUserRoom(true); mSession.getDataHandler().getStore().commit(); callback.onSuccess(room); } }
@Override public void onSuccess(Void info) { Log.d(LOG_TAG, "## setURLPreviewStatus() : succeeds"); getDataHandler().getStore().setURLPreviewEnabled(status); if (null != callback) { callback.onSuccess(null); } }
@Override public void onSuccess(Void info) { Log.d(LOG_TAG, "## addUserWidget() : succeeds"); getDataHandler().getStore().setUserWidgets(params); if (null != callback) { callback.onSuccess(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(); } } };
private void checkAllName(RoomNameScenarioData roomNameScenarioData, String expectedName) { for (MXSession session : roomNameScenarioData.userSessions) { Assert.assertEquals(expectedName, session.getDataHandler().getRoom(roomNameScenarioData.roomId).getState().name); } } }
private void RoomSummary_CheckMembership(boolean withLazyLoading) throws Exception { final LazyLoadingScenarioData data = mLazyLoadingTestHelper.createScenario(withLazyLoading); mTestHelper.syncSession(data.aliceSession, false); final Room aliceRoom = data.aliceSession.getDataHandler().getRoom(data.roomId); final RoomSummary aliceRoomSummary = aliceRoom.getRoomSummary(); Assert.assertNotNull(aliceRoomSummary); Assert.assertTrue(aliceRoomSummary.isJoined()); mTestHelper.syncSession(data.samSession, false); final Room samRoom = data.samSession.getDataHandler().getRoom(data.roomId); final RoomSummary samRoomSummary = samRoom.getRoomSummary(); Assert.assertNotNull(samRoomSummary); Assert.assertTrue(samRoomSummary.isJoined()); mLazyLoadingTestHelper.clearAllSessions(data); }
private void RoomSummary_CheckRoomSummaryIsNullAfterLeavingFromAnotherDevice(boolean withLazyLoading) throws Exception { final LazyLoadingScenarioData data = mLazyLoadingTestHelper.createScenario(withLazyLoading); final CountDownLatch lock = new CountDownLatch(1); data.aliceSession.getDataHandler().getDataRetriever().getRoomsRestClient().leaveRoom(data.roomId, new TestApiCallback<Void>(lock)); mTestHelper.await(lock); mTestHelper.syncSession(data.bobSession, false); final Room bobRoom = data.bobSession.getDataHandler().getRoom(data.roomId); mTestHelper.sendTextMessage(bobRoom, "New bob message", 50); mTestHelper.syncSession(data.aliceSession, false); final RoomSummary roomSummary = data.aliceSession.getDataHandler().getStore().getSummary(data.roomId); Assert.assertNull(roomSummary); mLazyLoadingTestHelper.clearAllSessions(data); }
private void RoomMembers_CheckAlreadyLoadedCount(final boolean withLazyLoading) throws Exception { final LazyLoadingScenarioData data = mLazyLoadingTestHelper.createScenario(withLazyLoading); mTestHelper.syncSession(data.aliceSession, false); final Room aliceRoom = data.aliceSession.getDataHandler().getRoom(data.roomId); final List<RoomMember> members = aliceRoom.getState().getLoadedMembers(); if (withLazyLoading) { Assert.assertEquals(1, members.size()); } else { Assert.assertEquals(4, members.size()); } mLazyLoadingTestHelper.clearAllSessions(data); }
private void RoomMembers_CheckActiveCountAsync(final boolean withLazyLoading) throws Exception { final LazyLoadingScenarioData data = mLazyLoadingTestHelper.createScenario(withLazyLoading); mTestHelper.syncSession(data.aliceSession, false); final Room aliceRoom = data.aliceSession.getDataHandler().getRoom(data.roomId); final CountDownLatch lock = new CountDownLatch(1); aliceRoom.getActiveMembersAsync(new TestApiCallback<List<RoomMember>>(lock) { @Override public void onSuccess(List<RoomMember> roomMembers) { Assert.assertEquals(4, roomMembers.size()); super.onSuccess(roomMembers); } }); mTestHelper.await(lock); mLazyLoadingTestHelper.clearAllSessions(data); }
private void RoomState_InitialSync(final boolean withLazyLoading) throws Exception { final LazyLoadingScenarioData data = mLazyLoadingTestHelper.createScenario(withLazyLoading); mTestHelper.syncSession(data.aliceSession, false); final Room aliceRoom = data.aliceSession.getDataHandler().getRoom(data.roomId); if (withLazyLoading) { Assert.assertEquals(1, aliceRoom.getState().getLoadedMembers().size()); } else { Assert.assertEquals(4, aliceRoom.getState().getLoadedMembers().size()); } Assert.assertEquals(1, aliceRoom.getNumberOfInvitedMembers()); Assert.assertEquals(3, aliceRoom.getNumberOfJoinedMembers()); mLazyLoadingTestHelper.clearAllSessions(data); }