Auth bug fix
[ubi] / qml / ubi / InitPage.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import "UIConstants.js" as Const
3 import "u1.js" as U1
4 import "components"
5
6 Showable {
7     id: root
8
9     hidden: false
10
11     Component.onCompleted: init()
12
13     function init() {
14         if(Utils.isAuthorized()) {
15             //title = "Hi, "+Utils.name();
16             login();
17         } else {
18             pageStack.initialPage = "LoginPage.qml";
19             hide();
20         }
21     }
22
23     function login() {
24         pageStack.currentPage.init();
25     }
26
27     function onRespRootNode(resp) {
28         hide();
29     }
30
31     function onErr(status) {
32         hide()
33         if(status==401) {
34             tip.show(qsTr("Ubuntu One authorization has failed. Try once again or check login settings."));
35         } else if(status==0) {
36             tip.show(qsTr("Unable to connect. Check internet connection."));
37         } else {
38             tip.show(qsTr("Unknown error: ")+status);
39         }
40     }
41
42     MouseArea {
43         anchors.fill: parent
44     }
45
46     Rectangle {
47         id: box
48
49         width: root.width; height: root.height
50         color: Const.DEFAULT_BACKGROUND_COLOR
51
52         Column {
53             spacing: Const.TEXT_MARGIN
54             anchors.horizontalCenter: parent.horizontalCenter
55             anchors.verticalCenter: parent.verticalCenter
56
57             Image {
58                 id: pic
59                 source: "images/ubi100.png"
60                 width: 104; height: 70
61                 anchors.horizontalCenter: parent.horizontalCenter
62             }
63
64             Text {
65                 id: loading
66                 anchors.horizontalCenter: parent.horizontalCenter
67                 font.pixelSize: 25
68                 color: "white"
69                 text: qsTr("Connecting...")
70             }
71
72             BusyIndicator {
73                 anchors.horizontalCenter: parent.horizontalCenter
74                 running: true
75             }
76         }
77
78         Text {
79             anchors.bottom: ver.top
80             anchors.horizontalCenter: parent.horizontalCenter
81             font.pixelSize: 20
82             color: "white"
83             text: "v0.9.3-2 © 2012 Michal Kosciesza"
84         }
85
86         Text {
87             id: ver
88             anchors.bottom: box.bottom
89             anchors.bottomMargin: 2*Const.TEXT_MARGIN
90             anchors.horizontalCenter: parent.horizontalCenter
91             font.pixelSize: 20
92             color: "white"
93             text: "http://ubi.garage.maemo.org"
94         }
95
96     }
97 }