handle user registration
This commit is contained in:
parent
9eb396c9ca
commit
6c1fc77f0c
13 changed files with 488 additions and 223 deletions
|
@ -65,7 +65,7 @@ CoverBackground {
|
|||
Component.onCompleted: {
|
||||
coverPage.authenticated = (tdLibWrapper.getAuthorizationState() === TelegramAPI.AuthorizationReady);
|
||||
coverPage.connectionState = tdLibWrapper.getConnectionState();
|
||||
coverPage.unreadMessages = tdLibWrapper.getUnreadMessageInformation().unread_count;
|
||||
coverPage.unreadMessages = tdLibWrapper.getUnreadMessageInformation().unread_count || 0;
|
||||
coverPage.unreadChats = tdLibWrapper.getUnreadChatInformation().unread_count;
|
||||
setUnreadInfoText();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
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 WerkWolf.Fernschreiber 1.0
|
||||
|
||||
|
@ -27,6 +27,7 @@ Page {
|
|||
|
||||
property bool loading: true
|
||||
property int authorizationState: TelegramAPI.Closed
|
||||
property var authorizationStateData: null
|
||||
|
||||
BusyLabel {
|
||||
text: qsTr("Loading...")
|
||||
|
@ -35,16 +36,33 @@ Page {
|
|||
|
||||
Component.onCompleted: {
|
||||
initializationPage.authorizationState = tdLibWrapper.getAuthorizationState();
|
||||
initializationPage.authorizationStateData = tdLibWrapper.getAuthorizationStateData();
|
||||
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;
|
||||
enterPasswordColumn.visible = false;
|
||||
}
|
||||
if (initializationPage.authorizationState === TelegramAPI.WaitPassword) {
|
||||
welcomeFlickable.visible = false;
|
||||
waitRegistrationColumn.visible = false;
|
||||
break;
|
||||
case TelegramAPI.WaitPassword:
|
||||
initializationPage.loading = false;
|
||||
welcomeColumn.visible = false;
|
||||
enterPinColumn.visible = false;
|
||||
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;
|
||||
enterPinColumn.visible = true;
|
||||
enterPasswordColumn.visible = false;
|
||||
waitRegistrationColumn.visible = false;
|
||||
break;
|
||||
case TelegramAPI.WaitPassword:
|
||||
initializationPage.loading = false;
|
||||
enterPinColumn.visible = false;
|
||||
enterPasswordColumn.visible = true;
|
||||
waitRegistrationColumn.visible = false;
|
||||
break;
|
||||
case TelegramAPI.WaitRegistration:
|
||||
initializationPage.loading = false;
|
||||
enterPinColumn.visible = false;
|
||||
enterPasswordColumn.visible = false;
|
||||
waitRegistrationColumn.visible = true;
|
||||
break;
|
||||
case TelegramAPI.AuthorizationReady:
|
||||
initializationPage.loading = false;
|
||||
|
@ -70,214 +96,16 @@ Page {
|
|||
default:
|
||||
// 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 {
|
||||
id: welcomeFlickable
|
||||
contentHeight: welcomeColumn.height
|
||||
Behavior on opacity { NumberAnimation {} }
|
||||
contentHeight: contentItem.childrenRect.height
|
||||
Behavior on contentHeight { NumberAnimation {} }
|
||||
anchors.fill: parent
|
||||
opacity: visible ? 1 : 0
|
||||
|
||||
Column {
|
||||
id: welcomeColumn
|
||||
|
@ -330,12 +158,340 @@ Page {
|
|||
enabled: phoneNumberTextField.text.match(/\+[1-9][0-9]{4,}/g)
|
||||
onClicked: {
|
||||
initializationPage.loading = true;
|
||||
welcomeFlickable.visible = false;
|
||||
welcomeColumn.visible = false;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -106,14 +106,9 @@ Page {
|
|||
function handleAuthorizationState() {
|
||||
switch (overviewPage.authorizationState) {
|
||||
case TelegramAPI.WaitPhoneNumber:
|
||||
overviewPage.loading = false;
|
||||
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
|
||||
break;
|
||||
case TelegramAPI.WaitCode:
|
||||
overviewPage.loading = false;
|
||||
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
|
||||
break;
|
||||
case TelegramAPI.WaitPassword:
|
||||
case TelegramAPI.WaitRegistration:
|
||||
overviewPage.loading = false;
|
||||
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
|
||||
break;
|
||||
|
|
|
@ -148,7 +148,7 @@ void TDLibReceiver::processUpdateAuthorizationState(const QVariantMap &receivedI
|
|||
{
|
||||
QString authorizationState = receivedInformation.value("authorization_state").toMap().value("@type").toString();
|
||||
LOG("Authorization state changed: " << authorizationState);
|
||||
emit authorizationStateChanged(authorizationState);
|
||||
emit authorizationStateChanged(authorizationState, receivedInformation);
|
||||
}
|
||||
|
||||
void TDLibReceiver::processUpdateConnectionState(const QVariantMap &receivedInformation)
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
signals:
|
||||
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 connectionStateChanged(const QString &connectionState);
|
||||
void userUpdated(const QVariantMap &userInformation);
|
||||
|
|
|
@ -46,7 +46,7 @@ TDLibWrapper::TDLibWrapper(QObject *parent) : QObject(parent), settings("harbour
|
|||
this->initializeOpenWith();
|
||||
|
||||
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(connectionStateChanged(QString)), this, SLOT(handleConnectionStateChanged(QString)));
|
||||
connect(this->tdLibReceiver, SIGNAL(userUpdated(QVariantMap)), this, SLOT(handleUserUpdated(QVariantMap)));
|
||||
|
@ -107,6 +107,11 @@ TDLibWrapper::AuthorizationState TDLibWrapper::getAuthorizationState()
|
|||
return this->authorizationState;
|
||||
}
|
||||
|
||||
QVariantMap TDLibWrapper::getAuthorizationStateData()
|
||||
{
|
||||
return this->authorizationStateData;
|
||||
}
|
||||
|
||||
TDLibWrapper::ConnectionState TDLibWrapper::getConnectionState()
|
||||
{
|
||||
return this->connectionState;
|
||||
|
@ -143,6 +148,16 @@ void TDLibWrapper::setAuthenticationPassword(const QString &authenticationPasswo
|
|||
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()
|
||||
{
|
||||
qDebug() << "[TDLibWrapper] Getting chats";
|
||||
|
@ -487,7 +502,7 @@ void TDLibWrapper::handleVersionDetected(const QString &version)
|
|||
emit versionDetected(version);
|
||||
}
|
||||
|
||||
void TDLibWrapper::handleAuthorizationStateChanged(const QString &authorizationState)
|
||||
void TDLibWrapper::handleAuthorizationStateChanged(const QString &authorizationState, const QVariantMap authorizationStateData)
|
||||
{
|
||||
if (authorizationState == "authorizationStateClosed") {
|
||||
this->authorizationState = AuthorizationState::Closed;
|
||||
|
@ -534,8 +549,8 @@ void TDLibWrapper::handleAuthorizationStateChanged(const QString &authorizationS
|
|||
this->setInitialParameters();
|
||||
this->authorizationState = AuthorizationState::WaitTdlibParameters;
|
||||
}
|
||||
|
||||
emit authorizationStateChanged(this->authorizationState);
|
||||
this->authorizationStateData = authorizationStateData;
|
||||
emit authorizationStateChanged(this->authorizationState, this->authorizationStateData);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
|
||||
Q_INVOKABLE QString getVersion();
|
||||
Q_INVOKABLE TDLibWrapper::AuthorizationState getAuthorizationState();
|
||||
Q_INVOKABLE QVariantMap getAuthorizationStateData();
|
||||
Q_INVOKABLE TDLibWrapper::ConnectionState getConnectionState();
|
||||
Q_INVOKABLE QVariantMap getUserInformation();
|
||||
Q_INVOKABLE QVariantMap getUserInformation(const QString &userId);
|
||||
|
@ -84,6 +85,7 @@ public:
|
|||
Q_INVOKABLE void setAuthenticationPhoneNumber(const QString &phoneNumber);
|
||||
Q_INVOKABLE void setAuthenticationCode(const QString &authenticationCode);
|
||||
Q_INVOKABLE void setAuthenticationPassword(const QString &authenticationPassword);
|
||||
Q_INVOKABLE void registerUser(const QString &firstName, const QString &lastName);
|
||||
Q_INVOKABLE void getChats();
|
||||
Q_INVOKABLE void downloadFile(const QString &fileId);
|
||||
Q_INVOKABLE void openChat(const QString &chatId);
|
||||
|
@ -104,7 +106,7 @@ public:
|
|||
signals:
|
||||
void versionDetected(const QString &version);
|
||||
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 connectionStateChanged(const TDLibWrapper::ConnectionState &connectionState);
|
||||
void fileUpdated(const int fileId, const QVariantMap &fileInformation);
|
||||
|
@ -134,7 +136,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
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 handleConnectionStateChanged(const QString &connectionState);
|
||||
void handleUserUpdated(const QVariantMap &userInformation);
|
||||
|
@ -167,6 +169,7 @@ private:
|
|||
DBusInterface *dbusInterface;
|
||||
QString version;
|
||||
TDLibWrapper::AuthorizationState authorizationState;
|
||||
QVariantMap authorizationStateData;
|
||||
TDLibWrapper::ConnectionState connectionState;
|
||||
QVariantMap options;
|
||||
QVariantMap userInformation;
|
||||
|
|
|
@ -292,6 +292,22 @@
|
|||
<source>Please enter your password:</source>
|
||||
<translation>Bitte geben Sie Ihr Passwort ein:</translation>
|
||||
</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>
|
||||
<name>LocationPreview</name>
|
||||
|
|
|
@ -292,6 +292,22 @@
|
|||
<source>Please enter your password:</source>
|
||||
<translation>Por favor, introducir el código:</translation>
|
||||
</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>
|
||||
<name>LocationPreview</name>
|
||||
|
|
|
@ -292,6 +292,22 @@
|
|||
<source>Please enter your password:</source>
|
||||
<translation>Kérlek add meg a jelszavad:</translation>
|
||||
</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>
|
||||
<name>LocationPreview</name>
|
||||
|
|
|
@ -292,6 +292,22 @@
|
|||
<source>Please enter your password:</source>
|
||||
<translation>Wprowadź hasło:</translation>
|
||||
</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>
|
||||
<name>LocationPreview</name>
|
||||
|
|
|
@ -292,6 +292,22 @@
|
|||
<source>Please enter your password:</source>
|
||||
<translation>请输入你的密码:</translation>
|
||||
</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>
|
||||
<name>LocationPreview</name>
|
||||
|
|
|
@ -292,6 +292,22 @@
|
|||
<source>Please enter your password:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</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>
|
||||
<name>LocationPreview</name>
|
||||
|
|
Loading…
Reference in a new issue