Java Code Examples for org.telegram.tgnet.TLRPC#TL_account_getPassword

The following examples show how to use org.telegram.tgnet.TLRPC#TL_account_getPassword . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrivacySettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void loadPasswordSettings() {
    if (UserConfig.getInstance(currentAccount).hasSecureData) {
        return;
    }
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (response != null) {
            TLRPC.TL_account_password password = (TLRPC.TL_account_password) response;
            if (password.has_secure_values) {
                AndroidUtilities.runOnUIThread(() -> {
                    UserConfig.getInstance(currentAccount).hasSecureData = true;
                    UserConfig.getInstance(currentAccount).saveConfig(false);
                    updateRows();
                });
            }
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 2
Source File: PrivacySettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void loadPasswordSettings() {
    if (UserConfig.getInstance(currentAccount).hasSecureData) {
        return;
    }
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (response != null) {
            TLRPC.TL_account_password password = (TLRPC.TL_account_password) response;
            if (password.has_secure_values) {
                AndroidUtilities.runOnUIThread(() -> {
                    UserConfig.getInstance(currentAccount).hasSecureData = true;
                    UserConfig.getInstance(currentAccount).saveConfig(false);
                    updateRows();
                });
            }
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 3
Source File: TwoStepVerificationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void loadPasswordInfo(final boolean silent) {
    if (!silent) {
        loading = true;
        if (listAdapter != null) {
            listAdapter.notifyDataSetChanged();
        }
    }
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            loading = false;
            currentPassword = (TLRPC.TL_account_password) response;
            if (!canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            if (!silent) {
                passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password;
            }
            initPasswordNewAlgo(currentPassword);
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword);
        }
        updateRows();
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 4
Source File: PrivacySettingsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void loadPasswordSettings() {
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    getConnectionsManager().sendRequest(req, (response, error) -> {
        if (response != null) {
            TLRPC.TL_account_password password = (TLRPC.TL_account_password) response;
            AndroidUtilities.runOnUIThread(() -> {
                currentPassword = password;
                TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
                if (!getUserConfig().hasSecureData && password.has_secure_values) {
                    getUserConfig().hasSecureData = true;
                    getUserConfig().saveConfig(false);
                    updateRows();
                } else {
                    if (listAdapter != null) {
                        listAdapter.notifyItemChanged(passwordRow);
                    }
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 5
Source File: TwoStepVerificationActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void loadPasswordInfo(final boolean silent) {
    if (!silent) {
        loading = true;
        if (listAdapter != null) {
            listAdapter.notifyDataSetChanged();
        }
    }
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            loading = false;
            currentPassword = (TLRPC.TL_account_password) response;
            if (!canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            if (!silent) {
                passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password;
            }
            initPasswordNewAlgo(currentPassword);
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword);
        }
        updateRows();
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 6
Source File: PrivacySettingsActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void loadPasswordSettings() {
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    getConnectionsManager().sendRequest(req, (response, error) -> {
        if (response != null) {
            TLRPC.TL_account_password password = (TLRPC.TL_account_password) response;
            AndroidUtilities.runOnUIThread(() -> {
                currentPassword = password;
                TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
                if (!getUserConfig().hasSecureData && password.has_secure_values) {
                    getUserConfig().hasSecureData = true;
                    getUserConfig().saveConfig(false);
                    updateRows();
                } else {
                    if (listAdapter != null) {
                        listAdapter.notifyItemChanged(passwordRow);
                    }
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 7
Source File: PaymentFormActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void loadPasswordInfo() {
    if (loadingPasswordInfo) {
        return;
    }
    loadingPasswordInfo = true;
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        loadingPasswordInfo = false;
        if (error == null) {
            currentPassword = (TLRPC.TL_account_password) response;
            if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            if (paymentForm != null && currentPassword.has_password) {
                paymentForm.password_missing = false;
                paymentForm.can_save_credentials = true;
                updateSavePaymentField();
            }
            TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
            if (passwordFragment != null) {
                passwordFragment.setCurrentPassword(currentPassword);
            }
            if (!currentPassword.has_password && shortPollRunnable == null) {
                shortPollRunnable = () -> {
                    if (shortPollRunnable == null) {
                        return;
                    }
                    loadPasswordInfo();
                    shortPollRunnable = null;
                };
                AndroidUtilities.runOnUIThread(shortPollRunnable, 5000);
            }
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 8
Source File: PaymentFormActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void loadPasswordInfo() {
    if (loadingPasswordInfo) {
        return;
    }
    loadingPasswordInfo = true;
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        loadingPasswordInfo = false;
        if (error == null) {
            currentPassword = (TLRPC.TL_account_password) response;
            if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            if (paymentForm != null && currentPassword.has_password) {
                paymentForm.password_missing = false;
                paymentForm.can_save_credentials = true;
                updateSavePaymentField();
            }
            TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
            if (passwordFragment != null) {
                passwordFragment.setCurrentPassword(currentPassword);
            }
            if (!currentPassword.has_password && shortPollRunnable == null) {
                shortPollRunnable = () -> {
                    if (shortPollRunnable == null) {
                        return;
                    }
                    loadPasswordInfo();
                    shortPollRunnable = null;
                };
                AndroidUtilities.runOnUIThread(shortPollRunnable, 5000);
            }
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 9
Source File: PaymentFormActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void loadPasswordInfo() {
    if (loadingPasswordInfo) {
        return;
    }
    loadingPasswordInfo = true;
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        loadingPasswordInfo = false;
        if (error == null) {
            currentPassword = (TLRPC.TL_account_password) response;
            if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            if (paymentForm != null && currentPassword.has_password) {
                paymentForm.password_missing = false;
                paymentForm.can_save_credentials = true;
                updateSavePaymentField();
            }
            TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
            if (passwordFragment != null) {
                passwordFragment.setCurrentPassword(currentPassword);
            }
            if (!currentPassword.has_password && shortPollRunnable == null) {
                shortPollRunnable = () -> {
                    if (shortPollRunnable == null) {
                        return;
                    }
                    loadPasswordInfo();
                    shortPollRunnable = null;
                };
                AndroidUtilities.runOnUIThread(shortPollRunnable, 5000);
            }
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 10
Source File: TwoStepVerificationSetupActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void loadPasswordInfo() {
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            currentPassword = (TLRPC.TL_account_password) response;
            if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            waitingForEmail = !TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern);
            TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
            if (!paused && closeAfterSet && currentPassword.has_password) {
                TLRPC.PasswordKdfAlgo pendingCurrentAlgo = currentPassword.current_algo;
                TLRPC.SecurePasswordKdfAlgo pendingNewSecureAlgo = currentPassword.new_secure_algo;
                byte[] pendingSecureRandom = currentPassword.secure_random;
                String pendingEmail = currentPassword.has_recovery ? "1" : null;
                String pendingHint = currentPassword.hint != null ? currentPassword.hint : "";

                if (!waitingForEmail && pendingCurrentAlgo != null) {
                    NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.twoStepPasswordChanged, null, pendingCurrentAlgo, pendingNewSecureAlgo, pendingSecureRandom, pendingEmail, pendingHint, null, null);
                    finishFragment();
                }
            }
            if (doneAfterPasswordLoad) {
                needHideProgress();
                buttonTextView.callOnClick();
            }
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword);
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 11
Source File: PaymentFormActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void loadPasswordInfo() {
    if (loadingPasswordInfo) {
        return;
    }
    loadingPasswordInfo = true;
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        loadingPasswordInfo = false;
        if (error == null) {
            currentPassword = (TLRPC.TL_account_password) response;
            if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            if (paymentForm != null && currentPassword.has_password) {
                paymentForm.password_missing = false;
                paymentForm.can_save_credentials = true;
                updateSavePaymentField();
            }
            TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
            if (passwordFragment != null) {
                passwordFragment.setCurrentPassword(currentPassword);
            }
            if (!currentPassword.has_password && shortPollRunnable == null) {
                shortPollRunnable = () -> {
                    if (shortPollRunnable == null) {
                        return;
                    }
                    loadPasswordInfo();
                    shortPollRunnable = null;
                };
                AndroidUtilities.runOnUIThread(shortPollRunnable, 5000);
            }
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 12
Source File: TwoStepVerificationSetupActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void loadPasswordInfo() {
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            currentPassword = (TLRPC.TL_account_password) response;
            if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            waitingForEmail = !TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern);
            TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
            if (!paused && closeAfterSet && currentPassword.has_password) {
                TLRPC.PasswordKdfAlgo pendingCurrentAlgo = currentPassword.current_algo;
                TLRPC.SecurePasswordKdfAlgo pendingNewSecureAlgo = currentPassword.new_secure_algo;
                byte[] pendingSecureRandom = currentPassword.secure_random;
                String pendingEmail = currentPassword.has_recovery ? "1" : null;
                String pendingHint = currentPassword.hint != null ? currentPassword.hint : "";

                if (!waitingForEmail && pendingCurrentAlgo != null) {
                    NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.twoStepPasswordChanged, null, pendingCurrentAlgo, pendingNewSecureAlgo, pendingSecureRandom, pendingEmail, pendingHint, null, null);
                    finishFragment();
                }
            }
            if (doneAfterPasswordLoad) {
                needHideProgress();
                buttonTextView.callOnClick();
            }
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword);
        }
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 13
Source File: TwoStepVerificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void loadPasswordInfo(final boolean silent) {
    if (!silent) {
        loading = true;
        if (listAdapter != null) {
            listAdapter.notifyDataSetChanged();
        }
    }
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            loading = false;
            currentPassword = (TLRPC.TL_account_password) response;
            if (!canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            if (!silent) {
                passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password;
            }
            waitingForEmail = !TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern);
            initPasswordNewAlgo(currentPassword);
            if (!paused && closeAfterSet && currentPassword.has_password) {
                TLRPC.PasswordKdfAlgo pendingCurrentAlgo = currentPassword.current_algo;
                TLRPC.SecurePasswordKdfAlgo pendingNewSecureAlgo = currentPassword.new_secure_algo;
                byte[] pendingSecureRandom = currentPassword.secure_random;
                String pendingEmail = currentPassword.has_recovery ? "1" : null;
                String pendingHint = currentPassword.hint != null ? currentPassword.hint : "";

                if (!waitingForEmail && pendingCurrentAlgo != null) {
                    NotificationCenter.getInstance(currentAccount).removeObserver(TwoStepVerificationActivity.this, NotificationCenter.didSetTwoStepPassword);
                    NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetTwoStepPassword, null, pendingCurrentAlgo, pendingNewSecureAlgo, pendingSecureRandom, pendingEmail, pendingHint, null, null);
                    finishFragment();
                }
            }
        }
        if (type == 0 && !destroyed && shortPollRunnable == null && !TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern)) {
            startShortpoll();
        }
        updateRows();
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 14
Source File: TwoStepVerificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void loadPasswordInfo(final boolean silent) {
    if (!silent) {
        loading = true;
        if (listAdapter != null) {
            listAdapter.notifyDataSetChanged();
        }
    }
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        if (error == null) {
            loading = false;
            currentPassword = (TLRPC.TL_account_password) response;
            if (!canHandleCurrentPassword(currentPassword, false)) {
                AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
                return;
            }
            if (!silent) {
                passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password;
            }
            waitingForEmail = !TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern);
            initPasswordNewAlgo(currentPassword);
            if (!paused && closeAfterSet && currentPassword.has_password) {
                TLRPC.PasswordKdfAlgo pendingCurrentAlgo = currentPassword.current_algo;
                TLRPC.SecurePasswordKdfAlgo pendingNewSecureAlgo = currentPassword.new_secure_algo;
                byte[] pendingSecureRandom = currentPassword.secure_random;
                String pendingEmail = currentPassword.has_recovery ? "1" : null;
                String pendingHint = currentPassword.hint != null ? currentPassword.hint : "";

                if (!waitingForEmail && pendingCurrentAlgo != null) {
                    NotificationCenter.getInstance(currentAccount).removeObserver(TwoStepVerificationActivity.this, NotificationCenter.didSetTwoStepPassword);
                    NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetTwoStepPassword, null, pendingCurrentAlgo, pendingNewSecureAlgo, pendingSecureRandom, pendingEmail, pendingHint, null, null);
                    finishFragment();
                }
            }
        }
        if (type == 0 && !destroyed && shortPollRunnable == null && !TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern)) {
            startShortpoll();
        }
        updateRows();
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}