handle user registration

This commit is contained in:
John Gibbon 2020-10-01 00:55:26 +02:00
parent 9eb396c9ca
commit 6c1fc77f0c
13 changed files with 488 additions and 223 deletions

View file

@ -65,7 +65,7 @@ CoverBackground {
Component.onCompleted: { Component.onCompleted: {
coverPage.authenticated = (tdLibWrapper.getAuthorizationState() === TelegramAPI.AuthorizationReady); coverPage.authenticated = (tdLibWrapper.getAuthorizationState() === TelegramAPI.AuthorizationReady);
coverPage.connectionState = tdLibWrapper.getConnectionState(); coverPage.connectionState = tdLibWrapper.getConnectionState();
coverPage.unreadMessages = tdLibWrapper.getUnreadMessageInformation().unread_count; coverPage.unreadMessages = tdLibWrapper.getUnreadMessageInformation().unread_count || 0;
coverPage.unreadChats = tdLibWrapper.getUnreadChatInformation().unread_count; coverPage.unreadChats = tdLibWrapper.getUnreadChatInformation().unread_count;
setUnreadInfoText(); setUnreadInfoText();
} }

View file

@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>. along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.2 import QtQuick 2.6
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import WerkWolf.Fernschreiber 1.0 import WerkWolf.Fernschreiber 1.0
@ -27,6 +27,7 @@ Page {
property bool loading: true property bool loading: true
property int authorizationState: TelegramAPI.Closed property int authorizationState: TelegramAPI.Closed
property var authorizationStateData: null
BusyLabel { BusyLabel {
text: qsTr("Loading...") text: qsTr("Loading...")
@ -35,16 +36,33 @@ Page {
Component.onCompleted: { Component.onCompleted: {
initializationPage.authorizationState = tdLibWrapper.getAuthorizationState(); initializationPage.authorizationState = tdLibWrapper.getAuthorizationState();
initializationPage.authorizationStateData = tdLibWrapper.getAuthorizationStateData();
initializationPage.loading = false; initializationPage.loading = false;
if (initializationPage.authorizationState === TelegramAPI.WaitCode) {
welcomeFlickable.visible = false; switch (authorizationState) {
case TelegramAPI.WaitCode:
initializationPage.loading = false;
welcomeColumn.visible = false;
enterPinColumn.visible = true; enterPinColumn.visible = true;
enterPasswordColumn.visible = false; enterPasswordColumn.visible = false;
} waitRegistrationColumn.visible = false;
if (initializationPage.authorizationState === TelegramAPI.WaitPassword) { break;
welcomeFlickable.visible = false; case TelegramAPI.WaitPassword:
initializationPage.loading = false;
welcomeColumn.visible = false;
enterPinColumn.visible = false; enterPinColumn.visible = false;
enterPasswordColumn.visible = true; enterPasswordColumn.visible = true;
waitRegistrationColumn.visible = false;
break;
case TelegramAPI.WaitRegistration:
initializationPage.loading = false;
welcomeColumn.visible = false;
enterPinColumn.visible = false;
enterPasswordColumn.visible = false;
waitRegistrationColumn.visible = true;
break;
default:
// Nothing ;)
} }
} }
@ -56,11 +74,19 @@ Page {
initializationPage.loading = false; initializationPage.loading = false;
enterPinColumn.visible = true; enterPinColumn.visible = true;
enterPasswordColumn.visible = false; enterPasswordColumn.visible = false;
waitRegistrationColumn.visible = false;
break; break;
case TelegramAPI.WaitPassword: case TelegramAPI.WaitPassword:
initializationPage.loading = false; initializationPage.loading = false;
enterPinColumn.visible = false; enterPinColumn.visible = false;
enterPasswordColumn.visible = true; enterPasswordColumn.visible = true;
waitRegistrationColumn.visible = false;
break;
case TelegramAPI.WaitRegistration:
initializationPage.loading = false;
enterPinColumn.visible = false;
enterPasswordColumn.visible = false;
waitRegistrationColumn.visible = true;
break; break;
case TelegramAPI.AuthorizationReady: case TelegramAPI.AuthorizationReady:
initializationPage.loading = false; initializationPage.loading = false;
@ -70,214 +96,16 @@ Page {
default: default:
// Nothing ;) // Nothing ;)
} }
initializationPage.authorizationStateData = authorizationStateData;
} }
} }
Column {
y: ( parent.height - ( errorInfoLabel.height + fernschreiberErrorImage.height + errorOkButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
width: parent.width
id: pinErrorColumn
spacing: Theme.paddingSmall
Behavior on opacity { NumberAnimation {} }
opacity: visible ? 1 : 0
visible: false
Image {
id: fernschreiberErrorImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * parent.width
}
InfoLabel {
id: errorInfoLabel
font.pixelSize: Theme.fontSizeLarge
text: ""
}
Button {
id: errorOkButton
text: qsTr("OK")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
pinErrorColumn.visible = false;
welcomeFlickable.visible = true;
}
}
}
Column {
y: ( parent.height - ( fernschreiberPasswordImage.height + enterPasswordLabel.height + enterPasswordField.height + enterPasswordButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
width: parent.width
id: enterPasswordColumn
spacing: Theme.paddingSmall
Behavior on opacity { NumberAnimation {} }
opacity: visible ? true : false
visible: false
Image {
id: fernschreiberPasswordImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * parent.width
}
InfoLabel {
id: enterPasswordLabel
font.pixelSize: Theme.fontSizeLarge
text: qsTr("Please enter your password:")
}
PasswordField {
id: enterPasswordField
anchors {
horizontalCenter: parent.horizontalCenter
}
font.pixelSize: Theme.fontSizeLarge
width: parent.width - 2 * Theme.horizontalPageMargin
horizontalAlignment: TextInput.AlignHCenter
}
Button {
id: enterPasswordButton
text: qsTr("OK")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
initializationPage.loading = true;
enterPasswordColumn.visible = false;
tdLibWrapper.setAuthenticationPassword(enterPasswordField.text);
}
}
}
Column {
y: ( parent.height - ( fernschreiberPinImage.height + enterPinLabel.height + enterPinField.height + enterPinButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
width: parent.width
id: enterPinColumn
spacing: Theme.paddingSmall
Behavior on opacity { NumberAnimation {} }
opacity: visible ? true : false
visible: false
Image {
id: fernschreiberPinImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * parent.width
}
InfoLabel {
id: enterPinLabel
font.pixelSize: Theme.fontSizeLarge
text: qsTr("Please enter the code that you received:")
}
TextField {
id: enterPinField
anchors {
horizontalCenter: parent.horizontalCenter
}
inputMethodHints: Qt.ImhDigitsOnly
font.pixelSize: Theme.fontSizeExtraLarge
width: parent.width - 4 * Theme.paddingLarge
horizontalAlignment: TextInput.AlignHCenter
}
Button {
id: enterPinButton
text: qsTr("OK")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
initializationPage.loading = true;
enterPinColumn.visible = false;
tdLibWrapper.setAuthenticationCode(enterPinField.text);
}
}
}
Column {
y: ( parent.height - ( fernschreiberLinkingErrorImage.height + linkingErrorInfoLabel.height + errorOkButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
width: parent.width
id: linkingErrorColumn
spacing: Theme.paddingSmall
Behavior on opacity { NumberAnimation {} }
opacity: visible ? true : false
visible: false
Image {
id: fernschreiberLinkingErrorImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * parent.width
}
InfoLabel {
id: linkingErrorInfoLabel
font.pixelSize: Theme.fontSizeLarge
text: qsTr("Unable to authenticate you with the entered code.")
}
Button {
id: enterPinAgainButton
text: qsTr("Enter code again")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
linkingErrorColumn.visible = false;
enterPinColumn.visible = true;
}
}
Button {
id: restartAuthenticationButton
text: qsTr("Restart authentication")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
linkingErrorColumn.visible = false;
welcomeFlickable.visible = true;
}
}
}
SilicaFlickable { SilicaFlickable {
id: welcomeFlickable id: welcomeFlickable
contentHeight: welcomeColumn.height contentHeight: contentItem.childrenRect.height
Behavior on opacity { NumberAnimation {} } Behavior on contentHeight { NumberAnimation {} }
anchors.fill: parent anchors.fill: parent
opacity: visible ? 1 : 0
Column { Column {
id: welcomeColumn id: welcomeColumn
@ -330,12 +158,340 @@ Page {
enabled: phoneNumberTextField.text.match(/\+[1-9][0-9]{4,}/g) enabled: phoneNumberTextField.text.match(/\+[1-9][0-9]{4,}/g)
onClicked: { onClicked: {
initializationPage.loading = true; initializationPage.loading = true;
welcomeFlickable.visible = false; welcomeColumn.visible = false;
tdLibWrapper.setAuthenticationPhoneNumber(phoneNumberTextField.text); tdLibWrapper.setAuthenticationPhoneNumber(phoneNumberTextField.text);
} }
} }
} }
Column {
id: pinErrorColumn
// y: ( parent.height - ( errorInfoLabel.height + fernschreiberErrorImage.height + errorOkButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
width: parent.width
spacing: Theme.paddingSmall
Behavior on opacity { NumberAnimation {} }
opacity: visible ? 1 : 0
visible: false
Image {
id: fernschreiberErrorImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * parent.width
}
InfoLabel {
id: errorInfoLabel
font.pixelSize: Theme.fontSizeLarge
text: ""
}
Button {
id: errorOkButton
text: qsTr("OK")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
pinErrorColumn.visible = false;
welcomeColumn.visible = true;
}
}
}
Column {
id: enterPasswordColumn
// y: ( parent.height - ( fernschreiberPasswordImage.height + enterPasswordLabel.height + enterPasswordField.height + enterPasswordButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
width: parent.width
spacing: Theme.paddingSmall
Behavior on opacity { NumberAnimation {} }
opacity: visible ? 1.0 : 0.0
visible: false
Image {
id: fernschreiberPasswordImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * parent.width
}
InfoLabel {
id: enterPasswordLabel
font.pixelSize: Theme.fontSizeLarge
text: qsTr("Please enter your password:")
}
PasswordField {
id: enterPasswordField
anchors {
horizontalCenter: parent.horizontalCenter
}
font.pixelSize: Theme.fontSizeLarge
width: parent.width - 2 * Theme.horizontalPageMargin
horizontalAlignment: TextInput.AlignHCenter
}
Button {
id: enterPasswordButton
text: qsTr("OK")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
initializationPage.loading = true;
enterPasswordColumn.visible = false;
tdLibWrapper.setAuthenticationPassword(enterPasswordField.text);
}
}
}
Column {
id: enterPinColumn
topPadding: Theme.paddingLarge
bottomPadding: Theme.paddingLarge
width: parent.width
spacing: Theme.paddingSmall
Behavior on opacity { NumberAnimation {} }
opacity: visible ? 1.0 : 0.0
visible: false
Image {
id: fernschreiberPinImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * parent.width
}
InfoLabel {
id: enterPinLabel
font.pixelSize: Theme.fontSizeLarge
text: qsTr("Please enter the code that you received:")
}
TextField {
id: enterPinField
anchors {
horizontalCenter: parent.horizontalCenter
}
inputMethodHints: Qt.ImhDigitsOnly
font.pixelSize: Theme.fontSizeExtraLarge
width: parent.width - 4 * Theme.paddingLarge
horizontalAlignment: TextInput.AlignHCenter
}
Button {
id: enterPinButton
text: qsTr("OK")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
initializationPage.loading = true;
enterPinColumn.visible = false;
tdLibWrapper.setAuthenticationCode(enterPinField.text);
}
}
}
Column {
id: linkingErrorColumn
topPadding: Theme.paddingLarge
bottomPadding: Theme.paddingLarge
width: parent.width
spacing: Theme.paddingSmall
Behavior on opacity { NumberAnimation {} }
opacity: visible ? 1.0 : 0.0
visible: false
Image {
id: fernschreiberLinkingErrorImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * parent.width
}
InfoLabel {
id: linkingErrorInfoLabel
font.pixelSize: Theme.fontSizeLarge
text: qsTr("Unable to authenticate you with the entered code.")
}
Button {
id: enterPinAgainButton
text: qsTr("Enter code again")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
linkingErrorColumn.visible = false;
enterPinColumn.visible = true;
}
}
Button {
id: restartAuthenticationButton
text: qsTr("Restart authentication")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
linkingErrorColumn.visible = false;
welcomeColumn.visible = true;
}
}
}
Column {
id: waitRegistrationColumn
topPadding: Theme.paddingLarge
bottomPadding: Theme.paddingLarge
width: parent.width
spacing: Theme.paddingLarge
Behavior on opacity { NumberAnimation {} }
opacity: visible ? 1.0 : 0.0
visible: false
PageHeader {
title: qsTr("User Registration")
}
Image {
id: waitRegistrationImage
source: "../../images/fernschreiber.png"
anchors {
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
asynchronous: true
width: 1/2 * Screen.width
}
InfoLabel {
id: waitRegistrationInfoLabel
property bool acknowledged
font.pixelSize: Theme.fontSizeExtraSmall
textFormat: Text.StyledText
horizontalAlignment: Text.AlignLeft
linkColor: Theme.primaryColor
property var stateText: initializationPage.authorizationStateData.authorization_state && initializationPage.authorizationStateData.authorization_state.terms_of_service ?
initializationPage.authorizationStateData.authorization_state.terms_of_service.text :
null
visible: !!stateText && !acknowledged
text: {
if(!stateText) {
return '';
}
var entities = stateText.entities;
if(entities && entities.length > 0 && entities[0]["type"]["@type"] === "textEntityTypeTextUrl") { //we just use the first entity for now.
var offset = entities[0].offset;
var length = entities[0].length;
return (stateText.text.slice(0,entities[0].offset)
+ "<a href=\""+entities[0]["type"]["url"]+"\">"
+ stateText.text.slice(entities[0].offset, entities[0].offset + entities[0].length)
+ '</a>'
+ stateText.text.slice(entities[0].offset + entities[0].length)).replace(/\n/gm, "<br>");
}
return stateText.text.replace(/\n/gm, "<br>");
}
//JSON.stringify(initializationPage.authorizationStateData, null, 2)//qsTr("Unable to authenticate you with the entered code.")
}
Button {
id: acknowledgeTOCButton
visible: waitRegistrationInfoLabel.visible
text: qsTr("OK")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
waitRegistrationInfoLabel.acknowledged = true;
userFirstNameTextField.focus = true
}
}
RegExpValidator {
id: filledValidator
regExp: /.+/
}
TextField {
id: userFirstNameTextField
visible: !waitRegistrationInfoLabel.visible
opacity: visible ? 1.0 : 0.0
Behavior on opacity { NumberAnimation {} }
placeholderText: qsTr("Enter your First Name")
labelVisible: false
width: parent.width
EnterKey.iconSource: !!text ? "image://theme/icon-m-enter-next" : "image://theme/icon-m-text-input"
EnterKey.onClicked: {
validator = filledValidator
if(acceptableInput) userLastNameTextField.focus = true;
}
}
TextField {
id: userLastNameTextField
visible: !waitRegistrationInfoLabel.visible
opacity: visible ? 1.0 : 0.0
Behavior on opacity { NumberAnimation {} }
placeholderText: qsTr("Enter your Last Name")
labelVisible: false
width: parent.width
EnterKey.iconSource: !!text ? "image://theme/icon-m-enter-accept" : "image://theme/icon-m-text-input"
EnterKey.onClicked: {
validator = filledValidator
if(acceptableInput) registerUserButton.onClicked(null);
}
}
Button {
id: registerUserButton
visible: !waitRegistrationInfoLabel.visible
opacity: visible ? 1.0 : 0.0
Behavior on opacity { NumberAnimation {} }
text: qsTr("Register User")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
userFirstNameTextField.validator = filledValidator
userLastNameTextField.validator = filledValidator
if(userFirstNameTextField.acceptableInput && userLastNameTextField.acceptableInput) {
tdLibWrapper.registerUser(userFirstNameTextField.text, userLastNameTextField.text);
} else if(!userFirstNameTextField.acceptableInput) {
userFirstNameTextField.focus = true;
} else {
userLastNameTextField.focus = true;
}
}
}
}
} }
} }

View file

@ -106,14 +106,9 @@ Page {
function handleAuthorizationState() { function handleAuthorizationState() {
switch (overviewPage.authorizationState) { switch (overviewPage.authorizationState) {
case TelegramAPI.WaitPhoneNumber: case TelegramAPI.WaitPhoneNumber:
overviewPage.loading = false;
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
break;
case TelegramAPI.WaitCode: case TelegramAPI.WaitCode:
overviewPage.loading = false;
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
break;
case TelegramAPI.WaitPassword: case TelegramAPI.WaitPassword:
case TelegramAPI.WaitRegistration:
overviewPage.loading = false; overviewPage.loading = false;
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml")); pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
break; break;

View file

@ -148,7 +148,7 @@ void TDLibReceiver::processUpdateAuthorizationState(const QVariantMap &receivedI
{ {
QString authorizationState = receivedInformation.value("authorization_state").toMap().value("@type").toString(); QString authorizationState = receivedInformation.value("authorization_state").toMap().value("@type").toString();
LOG("Authorization state changed: " << authorizationState); LOG("Authorization state changed: " << authorizationState);
emit authorizationStateChanged(authorizationState); emit authorizationStateChanged(authorizationState, receivedInformation);
} }
void TDLibReceiver::processUpdateConnectionState(const QVariantMap &receivedInformation) void TDLibReceiver::processUpdateConnectionState(const QVariantMap &receivedInformation)

View file

@ -37,7 +37,7 @@ public:
signals: signals:
void versionDetected(const QString &version); void versionDetected(const QString &version);
void authorizationStateChanged(const QString &authorizationState); void authorizationStateChanged(const QString &authorizationState, const QVariantMap &authorizationStateData);
void optionUpdated(const QString &optionName, const QVariant &optionValue); void optionUpdated(const QString &optionName, const QVariant &optionValue);
void connectionStateChanged(const QString &connectionState); void connectionStateChanged(const QString &connectionState);
void userUpdated(const QVariantMap &userInformation); void userUpdated(const QVariantMap &userInformation);

View file

@ -46,7 +46,7 @@ TDLibWrapper::TDLibWrapper(QObject *parent) : QObject(parent), settings("harbour
this->initializeOpenWith(); this->initializeOpenWith();
connect(this->tdLibReceiver, SIGNAL(versionDetected(QString)), this, SLOT(handleVersionDetected(QString))); connect(this->tdLibReceiver, SIGNAL(versionDetected(QString)), this, SLOT(handleVersionDetected(QString)));
connect(this->tdLibReceiver, SIGNAL(authorizationStateChanged(QString)), this, SLOT(handleAuthorizationStateChanged(QString))); connect(this->tdLibReceiver, SIGNAL(authorizationStateChanged(QString, QVariantMap)), this, SLOT(handleAuthorizationStateChanged(QString, QVariantMap)));
connect(this->tdLibReceiver, SIGNAL(optionUpdated(QString, QVariant)), this, SLOT(handleOptionUpdated(QString, QVariant))); connect(this->tdLibReceiver, SIGNAL(optionUpdated(QString, QVariant)), this, SLOT(handleOptionUpdated(QString, QVariant)));
connect(this->tdLibReceiver, SIGNAL(connectionStateChanged(QString)), this, SLOT(handleConnectionStateChanged(QString))); connect(this->tdLibReceiver, SIGNAL(connectionStateChanged(QString)), this, SLOT(handleConnectionStateChanged(QString)));
connect(this->tdLibReceiver, SIGNAL(userUpdated(QVariantMap)), this, SLOT(handleUserUpdated(QVariantMap))); connect(this->tdLibReceiver, SIGNAL(userUpdated(QVariantMap)), this, SLOT(handleUserUpdated(QVariantMap)));
@ -107,6 +107,11 @@ TDLibWrapper::AuthorizationState TDLibWrapper::getAuthorizationState()
return this->authorizationState; return this->authorizationState;
} }
QVariantMap TDLibWrapper::getAuthorizationStateData()
{
return this->authorizationStateData;
}
TDLibWrapper::ConnectionState TDLibWrapper::getConnectionState() TDLibWrapper::ConnectionState TDLibWrapper::getConnectionState()
{ {
return this->connectionState; return this->connectionState;
@ -143,6 +148,16 @@ void TDLibWrapper::setAuthenticationPassword(const QString &authenticationPasswo
this->sendRequest(requestObject); this->sendRequest(requestObject);
} }
void TDLibWrapper::registerUser(const QString &firstName, const QString &lastName)
{
qDebug() << "[TDLibWrapper] Register User " << firstName << lastName;
QVariantMap requestObject;
requestObject.insert("@type", "registerUser");
requestObject.insert("first_name", firstName);
requestObject.insert("last_name", lastName);
this->sendRequest(requestObject);
}
void TDLibWrapper::getChats() void TDLibWrapper::getChats()
{ {
qDebug() << "[TDLibWrapper] Getting chats"; qDebug() << "[TDLibWrapper] Getting chats";
@ -487,7 +502,7 @@ void TDLibWrapper::handleVersionDetected(const QString &version)
emit versionDetected(version); emit versionDetected(version);
} }
void TDLibWrapper::handleAuthorizationStateChanged(const QString &authorizationState) void TDLibWrapper::handleAuthorizationStateChanged(const QString &authorizationState, const QVariantMap authorizationStateData)
{ {
if (authorizationState == "authorizationStateClosed") { if (authorizationState == "authorizationStateClosed") {
this->authorizationState = AuthorizationState::Closed; this->authorizationState = AuthorizationState::Closed;
@ -534,8 +549,8 @@ void TDLibWrapper::handleAuthorizationStateChanged(const QString &authorizationS
this->setInitialParameters(); this->setInitialParameters();
this->authorizationState = AuthorizationState::WaitTdlibParameters; this->authorizationState = AuthorizationState::WaitTdlibParameters;
} }
this->authorizationStateData = authorizationStateData;
emit authorizationStateChanged(this->authorizationState); emit authorizationStateChanged(this->authorizationState, this->authorizationStateData);
} }

View file

@ -63,6 +63,7 @@ public:
Q_INVOKABLE QString getVersion(); Q_INVOKABLE QString getVersion();
Q_INVOKABLE TDLibWrapper::AuthorizationState getAuthorizationState(); Q_INVOKABLE TDLibWrapper::AuthorizationState getAuthorizationState();
Q_INVOKABLE QVariantMap getAuthorizationStateData();
Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState(); Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState();
Q_INVOKABLE QVariantMap getUserInformation(); Q_INVOKABLE QVariantMap getUserInformation();
Q_INVOKABLE QVariantMap getUserInformation(const QString &userId); Q_INVOKABLE QVariantMap getUserInformation(const QString &userId);
@ -84,6 +85,7 @@ public:
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber); Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode); Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode);
Q_INVOKABLE void setAuthenticationPassword(const QString &authenticationPassword); Q_INVOKABLE void setAuthenticationPassword(const QString &authenticationPassword);
Q_INVOKABLE void registerUser(const QString &firstName, const QString &lastName);
Q_INVOKABLE void getChats(); Q_INVOKABLE void getChats();
Q_INVOKABLE void downloadFile(const QString &fileId); Q_INVOKABLE void downloadFile(const QString &fileId);
Q_INVOKABLE void openChat(const QString &chatId); Q_INVOKABLE void openChat(const QString &chatId);
@ -104,7 +106,7 @@ public:
signals: signals:
void versionDetected(const QString &version); void versionDetected(const QString &version);
void ownUserIdFound(const QString &ownUserId); void ownUserIdFound(const QString &ownUserId);
void authorizationStateChanged(const TDLibWrapper::AuthorizationState &authorizationState); void authorizationStateChanged(const TDLibWrapper::AuthorizationState &authorizationState, const QVariantMap &authorizationStateData);
void optionUpdated(const QString &optionName, const QVariant &optionValue); void optionUpdated(const QString &optionName, const QVariant &optionValue);
void connectionStateChanged(const TDLibWrapper::ConnectionState &connectionState); void connectionStateChanged(const TDLibWrapper::ConnectionState &connectionState);
void fileUpdated(const int fileId, const QVariantMap &fileInformation); void fileUpdated(const int fileId, const QVariantMap &fileInformation);
@ -134,7 +136,7 @@ signals:
public slots: public slots:
void handleVersionDetected(const QString &version); void handleVersionDetected(const QString &version);
void handleAuthorizationStateChanged(const QString &authorizationState); void handleAuthorizationStateChanged(const QString &authorizationState, const QVariantMap authorizationStateData);
void handleOptionUpdated(const QString &optionName, const QVariant &optionValue); void handleOptionUpdated(const QString &optionName, const QVariant &optionValue);
void handleConnectionStateChanged(const QString &connectionState); void handleConnectionStateChanged(const QString &connectionState);
void handleUserUpdated(const QVariantMap &userInformation); void handleUserUpdated(const QVariantMap &userInformation);
@ -167,6 +169,7 @@ private:
DBusInterface *dbusInterface; DBusInterface *dbusInterface;
QString version; QString version;
TDLibWrapper::AuthorizationState authorizationState; TDLibWrapper::AuthorizationState authorizationState;
QVariantMap authorizationStateData;
TDLibWrapper::ConnectionState connectionState; TDLibWrapper::ConnectionState connectionState;
QVariantMap options; QVariantMap options;
QVariantMap userInformation; QVariantMap userInformation;

View file

@ -292,6 +292,22 @@
<source>Please enter your password:</source> <source>Please enter your password:</source>
<translation>Bitte geben Sie Ihr Passwort ein:</translation> <translation>Bitte geben Sie Ihr Passwort ein:</translation>
</message> </message>
<message>
<source>Register User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your First Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your Last Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Registration</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>

View file

@ -292,6 +292,22 @@
<source>Please enter your password:</source> <source>Please enter your password:</source>
<translation>Por favor, introducir el código:</translation> <translation>Por favor, introducir el código:</translation>
</message> </message>
<message>
<source>Register User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your First Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your Last Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Registration</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>

View file

@ -292,6 +292,22 @@
<source>Please enter your password:</source> <source>Please enter your password:</source>
<translation>Kérlek add meg a jelszavad:</translation> <translation>Kérlek add meg a jelszavad:</translation>
</message> </message>
<message>
<source>Register User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your First Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your Last Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Registration</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>

View file

@ -292,6 +292,22 @@
<source>Please enter your password:</source> <source>Please enter your password:</source>
<translation>Wprowadź hasło:</translation> <translation>Wprowadź hasło:</translation>
</message> </message>
<message>
<source>Register User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your First Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your Last Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Registration</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>

View file

@ -292,6 +292,22 @@
<source>Please enter your password:</source> <source>Please enter your password:</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Register User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your First Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your Last Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Registration</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>

View file

@ -292,6 +292,22 @@
<source>Please enter your password:</source> <source>Please enter your password:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Register User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your First Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter your Last Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User Registration</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>LocationPreview</name> <name>LocationPreview</name>