@Override public void onRetry() { add3PID(pid, bind, callback); } }));
@Override public void onRetry() { avatarUrl(userId, callback); } }) {
@Override public void onRetry() { deactivateAccount(userId, userPassword, eraseUserData, callback); } }));
@Override public void success(TokenRefreshResponse tokenResponse, Response response) { onEventSent(); getCredentials().refreshToken = tokenResponse.refreshToken; getCredentials().accessToken = tokenResponse.accessToken; if (null != callback) { callback.onSuccess(getCredentials()); } } });
@Override public void onRetry() { requestEmailValidationToken(address, clientSecret, attempt, nextLink, isDuringRegistration, callback); } }
@Override public void onRetry() { delete3PID(pid, callback); } })
@Override public void onRetry() { displayname(userId, callback); } }) {
@Override public void onRetry() { forgetPassword(email, callback); } }) {
/** * Refresh the access token */ public void refreshToken() { checkIfAlive(); mProfileRestClient.refreshTokens(new ApiCallback<Credentials>() { @Override public void onSuccess(Credentials info) { Log.d(LOG_TAG, "refreshToken : succeeds."); } @Override public void onNetworkError(Exception e) { Log.e(LOG_TAG, "refreshToken : onNetworkError " + e.getMessage(), e); } @Override public void onMatrixError(MatrixError e) { Log.e(LOG_TAG, "refreshToken : onMatrixError " + e.getMessage()); } @Override public void onUnexpectedError(Exception e) { Log.e(LOG_TAG, "refreshToken : onMatrixError " + e.getMessage(), e); } }); }
mProfileRestClient = new ProfileRestClient(hsConfig); mPresenceRestClient = new PresenceRestClient(hsConfig); mRoomsRestClient = new RoomsRestClient(hsConfig);
/** * Refresh access/refresh tokens, using the current refresh token. * * @param callback the callback success and failure callback */ public void refreshTokens(final ApiCallback<Credentials> callback) { final String description = "refreshTokens"; TokenRefreshParams params = new TokenRefreshParams(); params.refresh_token = getCredentials().refreshToken; mApi.tokenRefresh(params) .enqueue(new RestAdapterCallback<TokenRefreshResponse>(description, mUnsentEventsManager, callback, null) { @Override public void success(TokenRefreshResponse tokenResponse, Response response) { onEventSent(); getCredentials().refreshToken = tokenResponse.refreshToken; getCredentials().accessToken = tokenResponse.accessToken; if (null != callback) { callback.onSuccess(getCredentials()); } } }); }
restClient.requestEmailValidationToken(emailAddress, clientSecret, sendAttempt, nextLink, isDuringRegistration, new ApiCallback<RequestEmailValidationResponse>() {
/** * Delete a 3pid from an account * * @param pid the pid to delete * @param callback the async callback */ public void delete3Pid(final ThirdPartyIdentifier pid, final ApiCallback<Void> callback) { if (null != pid) { mDataHandler.getProfileRestClient().delete3PID(pid, new SimpleApiCallback<Void>(callback) { @Override public void onSuccess(Void info) { // refresh the third party identifiers lists refreshThirdPartyIdentifiers(callback); } }); } }
mDataHandler.getProfileRestClient().displayname(user_id, new SimpleApiCallback<String>() { @Override public void onSuccess(String aDisplayname) {
/** * Update this user's own display name. * * @param newName the new name * @param callback the callback if the call succeeds */ public void updateDisplayname(final String newName, final ApiCallback<Void> callback) { // privacy //final String description = "updateDisplayname newName : " + newName; final String description = "update display name"; // TODO Do not create a User for this User user = new User(); user.displayname = newName; // don't retry if the network comes back // let the user chooses what he want to do mApi.displayname(getCredentials().userId, user) .enqueue(new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() { @Override public void onRetry() { updateDisplayname(newName, callback); } })); }
mDataHandler.getProfileRestClient().avatarUrl(user_id, new SimpleApiCallback<String>() { @Override public void onSuccess(String anAvatarUrl) {
final boolean eraseUserData, final ApiCallback<Void> callback) { mProfileRestClient.deactivateAccount(getMyUserId(), userPassword, eraseUserData, new SimpleApiCallback<Void>(callback) {
/** * Add a new pid to the account. * * @param pid the pid to add. * @param bind true to add it. * @param callback the async callback */ public void add3Pid(final ThreePid pid, final boolean bind, final ApiCallback<Void> callback) { if (null != pid) { mDataHandler.getProfileRestClient().add3PID(pid, bind, new SimpleApiCallback<Void>(callback) { @Override public void onSuccess(Void info) { // refresh the third party identifiers lists refreshThirdPartyIdentifiers(callback); } }); } }
/** * Update this user's own avatar URL. * * @param newUrl the new name * @param callback the callback if the call succeeds */ public void updateAvatarUrl(final String newUrl, final ApiCallback<Void> callback) { // privacy //final String description = "updateAvatarUrl newUrl : " + newUrl; final String description = "updateAvatarUrl"; // TODO Do not create a User for this User user = new User(); user.setAvatarUrl(newUrl); mApi.avatarUrl(getCredentials().userId, user) .enqueue(new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() { @Override public void onRetry() { updateAvatarUrl(newUrl, callback); } })); }