Update WWW
[ubi] / qml / ubi / AccountPage.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import "components"
3 import "UIConstants.js" as Const
4 import "u1.js" as U1
5 import "bytesconv.js" as Conv
6
7 Page {
8     id: root
9     title: qsTr("Account")
10
11     property variant secrets
12
13     Component.onCompleted: init()
14
15     function init()
16     {
17         secrets = {
18             token: Utils.token(),
19             secret: Utils.tokenSecret(),
20             consumer_key : Utils.customerKey(),
21             consumer_secret: Utils.customerSecret()
22         };
23         mask.state = "busy";
24         U1.getAccount(secrets,root);
25     }
26
27     function onResp(secrets,account)
28     {
29         //console.log("onResp");
30         mask.state = "idle";
31
32         //uid.text = account.id;
33         username.text = account.username;
34         //nick.text = account.nickname;
35         email.text = account.email;
36         storage.text = Conv.bytesToSize(account.total_storage);
37     }
38
39     function onErr(status)
40     {
41         //console.log("onErr");
42         mask.state = "idle";
43         if(status==401) {
44             tip.show(qsTr("Authorization failed!"));
45         } else if(status==0) {
46             tip.show(qsTr("Unable to connect!"));
47         } else {
48             tip.show(qsTr("Error: ")+status);
49         }
50         pageStack.pop();
51     }
52
53     Flickable {
54         width: root.width
55         height: root.height
56         contentHeight: content.height+Const.SYSTEM_BAR_HEIGHT+Const.TEXT_MARGIN
57         y: Const.SYSTEM_BAR_HEIGHT+Const.TEXT_MARGIN
58
59         Column {
60             id: content
61             spacing: Const.DEFAULT_MARGIN
62             x: Const.TEXT_MARGIN
63
64             /*Text {
65                 font.pixelSize: 30
66                 color: "white"
67                 text: "Id:"
68             }
69             Text {
70                 id: uid
71                 font.pixelSize: 30
72                 color: "black"
73                 wrapMode: Text.Wrap
74                 width: root.width - 6*Const.DEFAULT_MARGIN
75             }*/
76             Text {
77                 font.pixelSize: 30
78                 color: "white"
79                 text: qsTr("User name:")
80             }
81             Text {
82                 id: username
83                 font.pixelSize: 30
84                 color: "black"
85                 wrapMode: Text.Wrap
86                 width: root.width - 6*Const.DEFAULT_MARGIN
87             }
88             Line {
89                 width: root.width-2*Const.TEXT_MARGIN
90             }
91             /*Text {
92                 font.pixelSize: 30
93                 color: "white"
94                 text: qsTr("Nickname:")
95             }
96             Text {
97                 id: nick
98                 font.pixelSize: 30
99                 color: "black"
100                 wrapMode: Text.Wrap
101                 width: root.width - 6*Const.DEFAULT_MARGIN
102             }*/
103             Text {
104                 font.pixelSize: 30
105                 color: "white"
106                 text: qsTr("Email:")
107             }
108             Text {
109                 id: email
110                 font.pixelSize: 30
111                 color: "black"
112                 wrapMode: Text.Wrap
113                 width: root.width - 6*Const.DEFAULT_MARGIN
114             }
115             Line {
116                 width: root.width-2*Const.TEXT_MARGIN
117             }
118             Text {
119                 font.pixelSize: 30
120                 color: "white"
121                 text: qsTr("Total storage:")
122             }
123             Text {
124                 id: storage
125                 font.pixelSize: 30
126                 color: "black"
127                 wrapMode: Text.Wrap
128                 width: root.width - 6*Const.DEFAULT_MARGIN
129             }
130             Spacer{}
131         }
132     }
133 }