diff --git a/qml/pages/InitializationPage.qml b/qml/pages/InitializationPage.qml
index a1d050b..ccdcc4a 100644
--- a/qml/pages/InitializationPage.qml
+++ b/qml/pages/InitializationPage.qml
@@ -18,11 +18,48 @@
*/
import QtQuick 2.2
import Sailfish.Silica 1.0
+import WerkWolf.Fernschreiber 1.0
Page {
id: initializationPage
allowedOrientations: Orientation.All
+ property bool loading: true
+ property int authorizationState: TelegramAPI.Closed
+
+ BusyLabel {
+ text: qsTr("Loading...")
+ running: initializationPage.loading
+ }
+
+ Component.onCompleted: {
+ initializationPage.authorizationState = tdLibWrapper.getAuthorizationState();
+ initializationPage.loading = false;
+ if (initializationPage.authorizationState === TelegramAPI.WaitCode) {
+ welcomeFlickable.visible = false;
+ enterPinColumn.visible = true;
+ }
+ }
+
+ Connections {
+ target: tdLibWrapper
+ onAuthorizationStateChanged: {
+ switch (authorizationState) {
+ case TelegramAPI.WaitCode:
+ initializationPage.loading = false;
+ enterPinColumn.visible = true;
+ break;
+ case TelegramAPI.AuthorizationReady:
+ overviewPage.loading = false;
+ pageStack.clear();
+ pageStack.push(Qt.resolvedUrl("../pages/OverviewPage.qml"));
+ break;
+ default:
+ // Nothing ;)
+ }
+ }
+ }
+
Column {
y: ( parent.height - ( errorInfoLabel.height + fernschreiberErrorImage.height + errorOkButton.height + ( 3 * Theme.paddingSmall ) ) ) / 2
width: parent.width
@@ -87,7 +124,7 @@ Page {
InfoLabel {
id: enterPinLabel
font.pixelSize: Theme.fontSizeLarge
- text: qsTr("Please enter the PIN that you received:")
+ text: qsTr("Please enter the code that you received:")
}
TextField {
@@ -108,8 +145,9 @@ Page {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
- //accountModel.enterPin(enterPinField.text)
+ initializationPage.loading = true;
enterPinColumn.visible = false;
+ tdLibWrapper.setAuthenticationCode(enterPinField.text);
}
}
}
@@ -138,12 +176,12 @@ Page {
InfoLabel {
id: linkingErrorInfoLabel
font.pixelSize: Theme.fontSizeLarge
- text: qsTr("Unable to authenticate you with the entered PIN.")
+ text: qsTr("Unable to authenticate you with the entered code.")
}
Button {
id: enterPinAgainButton
- text: qsTr("Enter PIN again")
+ text: qsTr("Enter code again")
anchors {
horizontalCenter: parent.horizontalCenter
}
@@ -169,38 +207,12 @@ Page {
SilicaFlickable {
id: welcomeFlickable
anchors.fill: parent
- contentHeight: column.height
+ contentHeight: welcomeColumn.height
Behavior on opacity { NumberAnimation {} }
opacity: visible ? 1 : 0
-// Connections {
-// target: accountModel
-// onPinRequestSuccessful: {
-// console.log("URL: " + url)
-// Qt.openUrlExternally(url)
-// welcomeFlickable.visible = false
-// enterPinColumn.visible = true
-// }
-// onPinRequestError: {
-// errorInfoLabel.text = errorMessage
-// welcomeFlickable.visible = false
-// pinErrorColumn.visible = true
-// console.log("Error Message: " + errorMessage)
-// }
-// onLinkingSuccessful: {
-// console.log("Linking successful, moving on to my tweets...")
-// pageStack.clear()
-// pageStack.push(overviewPage)
-// }
-// onLinkingFailed: {
-// enterPinColumn.visible = false
-// linkingErrorColumn.visible = true
-// console.log("Linking error, proceeding to error page!")
-// }
-// }
-
Column {
- id: column
+ id: welcomeColumn
width: parent.width
spacing: Theme.paddingLarge
@@ -246,6 +258,8 @@ Page {
}
enabled: phoneNumberTextField.text.match(/\+[1-9][0-9]{4,}/g)
onClicked: {
+ initializationPage.loading = true;
+ welcomeFlickable.visible = false;
tdLibWrapper.setAuthenticationPhoneNumber(phoneNumberTextField.text);
}
}
diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml
index bd82927..1bb9b6a 100644
--- a/qml/pages/OverviewPage.qml
+++ b/qml/pages/OverviewPage.qml
@@ -29,6 +29,8 @@ Page {
allowedOrientations: Orientation.All
property bool loading: true;
+ property int authorizationState: TelegramAPI.Closed
+ property int connectionState: TelegramAPI.WaitingForNetwork
BusyLabel {
text: qsTr("Loading...")
@@ -44,10 +46,31 @@ Page {
pageStack.clear();
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
break;
+ case TelegramAPI.WaitCode:
+ overviewPage.loading = false;
+ pageStack.clear();
+ pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
+ break;
+ case TelegramAPI.AuthorizationReady:
+ overviewPage.loading = false;
+ break;
default:
// Nothing ;)
}
+ overviewPage.authorizationState = authorizationState;
}
+ onConnectionStateChanged: {
+ overviewPage.connectionState = connectionState;
+ }
+ }
+
+ Component.onCompleted: {
+ overviewPage.authorizationState = tdLibWrapper.getAuthorizationState();
+ if (overviewPage.authorizationState === TelegramAPI.AuthorizationReady) {
+ overviewPage.loading = false;
+ }
+
+ overviewPage.connectionState = tdLibWrapper.getConnectionState();
}
SilicaFlickable {
diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp
index bdaa85a..8b13f30 100644
--- a/src/tdlibwrapper.cpp
+++ b/src/tdlibwrapper.cpp
@@ -89,6 +89,15 @@ void TDLibWrapper::setAuthenticationPhoneNumber(const QString &phoneNumber)
this->sendRequest(requestObject);
}
+void TDLibWrapper::setAuthenticationCode(const QString &authenticationCode)
+{
+ qDebug() << "[TDLibWrapper] Set authentication code " << authenticationCode;
+ QVariantMap requestObject;
+ requestObject.insert("@type", "checkAuthenticationCode");
+ requestObject.insert("code", authenticationCode);
+ this->sendRequest(requestObject);
+}
+
void TDLibWrapper::handleVersionDetected(const QString &version)
{
this->version = version;
diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h
index e32cf4d..6540719 100644
--- a/src/tdlibwrapper.h
+++ b/src/tdlibwrapper.h
@@ -63,6 +63,7 @@ public:
Q_INVOKABLE TDLibWrapper::AuthorizationState getAuthorizationState();
Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState();
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
+ Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode);
signals:
void versionDetected(const QString &version);
diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts
index f9fe1fe..599ee3d 100644
--- a/translations/harbour-fernschreiber-de.ts
+++ b/translations/harbour-fernschreiber-de.ts
@@ -66,22 +66,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -94,6 +78,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
OverviewPage
diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts
index f9fe1fe..599ee3d 100644
--- a/translations/harbour-fernschreiber.ts
+++ b/translations/harbour-fernschreiber.ts
@@ -66,22 +66,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -94,6 +78,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
OverviewPage