Skip to content

Commit c6fd4e8

Browse files
committed
Show a error message when we couldn't connect to google cal server.
When generating a user code to login. See issue #18.
1 parent 2ac696e commit c6fd4e8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

package/contents/ui/config/ConfigGoogleCalendar.qml

+5
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,17 @@ ConfigPage {
5151
}
5252
calendarsModel.calendarsShownChanged()
5353
}
54+
55+
onErrorFetchingUserCode: messageWidget.err(err)
5456
}
5557

5658

5759
HeaderText {
5860
text: i18n("Login")
5961
}
62+
MessageWidget {
63+
id: messageWidget
64+
}
6065
Column {
6166
visible: session.accessToken
6267
Text {

package/contents/ui/config/GoogleCalendarSession.qml

+11-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Item {
5050
property alias calendarIdList: calendarIdListData.value
5151

5252
signal newAccessToken()
53+
signal errorFetchingUserCode(string err)
5354

5455

5556
//---
@@ -65,9 +66,17 @@ Item {
6566
}
6667

6768
function generateUserCodeAndPoll() {
68-
getUserCode(function(err, data) {
69+
getUserCode(function(err, data, xhr) {
70+
if (err) {
71+
if (xhr.status == 0) { // Error connecting
72+
session.errorFetchingUserCode("Http Error 0: Could not connect to https://accounts.google.com")
73+
} else {
74+
session.errorFetchingUserCode(err)
75+
}
76+
return
77+
}
6978
data = JSON.parse(data)
70-
logger.debug('/o/oauth2/device/code Response', JSON.stringify(data, null, '\t'))
79+
logger.debugJSON('/o/oauth2/device/code Response', data)
7180

7281
deviceCode = data.device_code
7382
userCode = data.user_code

0 commit comments

Comments
 (0)