/** * Cancel any pending pagination requests */ @Override public void cancelPaginationRequests() { mDataHandler.getDataRetriever().cancelHistoryRequests(mRoomId); mIsBackPaginating = false; mIsForwardPaginating = false; }
/** * cancel any remote request */ public void cancelRemoteHistoryRequest() { mDataHandler.getDataRetriever().cancelRemoteHistoryRequest(getRoomId()); }
/** * Update the user enabled room url preview * * @param status the new status * @param callback the asynchronous callback */ public void setIsURLPreviewAllowedByUser(boolean status, ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().updateURLPreviewStatus(getRoomId(), status, callback); }
/** * Update the room's main alias. * * @param aCanonicalAlias the canonical alias * @param callback the async callback */ public void updateCanonicalAlias(final String aCanonicalAlias, final ApiCallback<Void> callback) { final String fCanonicalAlias = TextUtils.isEmpty(aCanonicalAlias) ? null : aCanonicalAlias; mDataHandler.getDataRetriever().getRoomsRestClient().updateCanonicalAlias(getRoomId(), fCanonicalAlias, new RoomInfoUpdateCallback<Void>(callback) { @Override public void onSuccess(Void info) { getState().setCanonicalAlias(aCanonicalAlias); super.onSuccess(info); } }); }
/** * Redact an event from the room. * * @param eventId the event's id * @param score the score * @param reason the redaction reason * @param callback the callback with the created event */ public void report(String eventId, int score, String reason, ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().reportEvent(getRoomId(), eventId, score, reason, callback); }
/** * Kick a user from the room. * * @param userId the user id * @param reason the reason * @param callback the async callback */ public void kick(String userId, @Nullable String reason, ApiCallback<Void> callback) { UserIdAndReason userIdAndReason = new UserIdAndReason(); userIdAndReason.userId = userId; if (!TextUtils.isEmpty(reason)) { userIdAndReason.reason = reason; } mDataHandler.getDataRetriever().getRoomsRestClient().kickFromRoom(getRoomId(), userIdAndReason, callback); }
/** * Ban a user from the room. * * @param userId the user id * @param reason ban reason * @param callback the async callback */ public void ban(String userId, String reason, ApiCallback<Void> callback) { UserIdAndReason userIdAndReason = new UserIdAndReason(); userIdAndReason.userId = userId; if (!TextUtils.isEmpty(reason)) { userIdAndReason.reason = reason; } mDataHandler.getDataRetriever().getRoomsRestClient().banFromRoom(getRoomId(), userIdAndReason, callback); }
/** * Update the room avatar URL. * * @param avatarUrl the new avatar URL * @param callback the async callback */ public void updateAvatarUrl(final String avatarUrl, final ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().updateAvatarUrl(getRoomId(), avatarUrl, new RoomInfoUpdateCallback<Void>(callback) { @Override public void onSuccess(Void info) { getState().url = avatarUrl; super.onSuccess(info); } }); }
/** * Update the room's name. * * @param aRoomName the new name * @param callback the async callback */ public void updateName(final String aRoomName, final ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().updateRoomName(getRoomId(), aRoomName, new RoomInfoUpdateCallback<Void>(callback) { @Override public void onSuccess(Void info) { getState().name = aRoomName; super.onSuccess(info); } }); }
/** * Update the room's topic. * * @param aTopic the new topic * @param callback the async callback */ public void updateTopic(final String aTopic, final ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().updateTopic(getRoomId(), aTopic, new RoomInfoUpdateCallback<Void>(callback) { @Override public void onSuccess(Void info) { getState().topic = aTopic; super.onSuccess(info); } }); }
/** * Update the guest access rule of the room. * To deny guest access to the room, aGuestAccessRule must be set to {@link RoomState#GUEST_ACCESS_FORBIDDEN}. * * @param aGuestAccessRule the guest access rule: {@link RoomState#GUEST_ACCESS_CAN_JOIN} or {@link RoomState#GUEST_ACCESS_FORBIDDEN} * @param callback the async callback */ public void updateGuestAccess(final String aGuestAccessRule, final ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().updateGuestAccess(getRoomId(), aGuestAccessRule, new RoomInfoUpdateCallback<Void>(callback) { @Override public void onSuccess(Void info) { getState().guest_access = aGuestAccessRule; super.onSuccess(info); } }); }
/** * Update the directory's visibility * * @param visibility the visibility (should be one of RoomState.HISTORY_VISIBILITY_XX values) * @param callback the async callback */ public void updateDirectoryVisibility(final String visibility, final ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient().updateDirectoryVisibility(getRoomId(), visibility, new RoomInfoUpdateCallback<Void>(callback) { @Override public void onSuccess(Void info) { getState().visibility = visibility; super.onSuccess(info); } }); }
/** * Update the join rule of the room. * * @param aRule the join rule: {@link RoomState#JOIN_RULE_PUBLIC} or {@link RoomState#JOIN_RULE_INVITE} * @param aCallBackResp the async callback */ public void updateJoinRules(final String aRule, final ApiCallback<Void> aCallBackResp) { mDataHandler.getDataRetriever().getRoomsRestClient().updateJoinRules(getRoomId(), aRule, new RoomInfoUpdateCallback<Void>(aCallBackResp) { @Override public void onSuccess(Void info) { getState().join_rule = aRule; super.onSuccess(info); } }); }
/** * Update the room's history visibility * * @param historyVisibility the visibility (should be one of RoomState.HISTORY_VISIBILITY_XX values) * @param callback the async callback */ public void updateHistoryVisibility(final String historyVisibility, final ApiCallback<Void> callback) { mDataHandler.getDataRetriever().getRoomsRestClient() .updateHistoryVisibility(getRoomId(), historyVisibility, new RoomInfoUpdateCallback<Void>(callback) { @Override public void onSuccess(Void info) { getState().history_visibility = historyVisibility; super.onSuccess(info); } }); }
@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); }
/** * Unban a user. * * @param userId the user id * @param callback the async callback */ public void unban(String userId, ApiCallback<Void> callback) { UserIdAndReason userIdAndReason = new UserIdAndReason(); userIdAndReason.userId = userId; // No reason for unbanning user mDataHandler.getDataRetriever().getRoomsRestClient().unbanFromRoom(getRoomId(), userIdAndReason, callback); }
/** * Send a typing notification * * @param isTyping typing status * @param timeout the typing timeout * @param callback asynchronous callback */ public void sendTypingNotification(boolean isTyping, int timeout, ApiCallback<Void> callback) { // send the event only if the user has joined the room. if (isJoined()) { mDataHandler.getDataRetriever().getRoomsRestClient().sendTypingNotification(getRoomId(), mMyUserId, isTyping, timeout, callback); } }
/** * Remove a tag to a room. * * @param tag the new tag to add to the room. * @param callback the operation callback. */ private void removeTag(String tag, final ApiCallback<Void> callback) { // sanity check if (null != tag) { mDataHandler.getDataRetriever().getRoomsRestClient().removeTag(getRoomId(), tag, callback); } else { if (null != callback) { callback.onSuccess(null); } } }
/** * Update the power level of the user userId * * @param userId the user id * @param powerLevel the new power level * @param callback the callback with the created event */ public void updateUserPowerLevels(String userId, int powerLevel, ApiCallback<Void> callback) { PowerLevels powerLevels = getState().getPowerLevels().deepCopy(); powerLevels.setUserPowerLevel(userId, powerLevel); mDataHandler.getDataRetriever().getRoomsRestClient().updatePowerLevels(getRoomId(), powerLevels, callback); }
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); }