summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gmrequest.c10
-rw-r--r--src/gmutil.c4
-rw-r--r--src/gmutil.h2
-rw-r--r--src/ui/documentwidget.c24
4 files changed, 28 insertions, 12 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index 3faa2833..bb6ac23e 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -111,7 +111,8 @@ enum iGmRequestState {
111 initialized_GmRequestState, 111 initialized_GmRequestState,
112 receivingHeader_GmRequestState, 112 receivingHeader_GmRequestState,
113 receivingBody_GmRequestState, 113 receivingBody_GmRequestState,
114 finished_GmRequestState 114 finished_GmRequestState,
115 failure_GmRequestState,
115}; 116};
116 117
117struct Impl_GmRequest { 118struct Impl_GmRequest {
@@ -301,7 +302,12 @@ static void requestFinished_GmRequest_(iAnyObject *obj) {
301 } 302 }
302 SDL_RemoveTimer(d->timeoutId); 303 SDL_RemoveTimer(d->timeoutId);
303 d->timeoutId = 0; 304 d->timeoutId = 0;
304 d->state = finished_GmRequestState; 305 d->state = (status_TlsRequest(d->req) == error_TlsRequestStatus ? failure_GmRequestState
306 : finished_GmRequestState);
307 if (d->state == failure_GmRequestState) {
308 d->resp.statusCode = tlsFailure_GmStatusCode;
309 set_String(&d->resp.meta, errorMessage_TlsRequest(d->req));
310 }
305 checkServerCertificate_GmRequest_(d); 311 checkServerCertificate_GmRequest_(d);
306 unlock_Mutex(&d->mutex); 312 unlock_Mutex(&d->mutex);
307 iNotifyAudience(d, finished, GmRequestFinished); 313 iNotifyAudience(d, finished, GmRequestFinished);
diff --git a/src/gmutil.c b/src/gmutil.c
index 43586e55..5f09a176 100644
--- a/src/gmutil.c
+++ b/src/gmutil.c
@@ -237,6 +237,10 @@ static const struct {
237 "Too Many Redirects", 237 "Too Many Redirects",
238 "You may be stuck in a redirection loop. The next redirected URL is below if you " 238 "You may be stuck in a redirection loop. The next redirected URL is below if you "
239 "want to continue manually."} }, 239 "want to continue manually."} },
240 { tlsFailure_GmStatusCode,
241 { 0x1f5a7, /* networked computers */
242 "Network/TLS Failure",
243 "We could not communicate with the requested host." } },
240 { temporaryFailure_GmStatusCode, 244 { temporaryFailure_GmStatusCode,
241 { 0x1f50c, /* electric plug */ 245 { 0x1f50c, /* electric plug */
242 "Temporary Failure", 246 "Temporary Failure",
diff --git a/src/gmutil.h b/src/gmutil.h
index 88572f22..8b4f7033 100644
--- a/src/gmutil.h
+++ b/src/gmutil.h
@@ -40,6 +40,8 @@ enum iGmStatusCode {
40 failedToOpenFile_GmStatusCode, 40 failedToOpenFile_GmStatusCode,
41 unknownStatusCode_GmStatusCode, 41 unknownStatusCode_GmStatusCode,
42 invalidLocalResource_GmStatusCode, 42 invalidLocalResource_GmStatusCode,
43 tlsFailure_GmStatusCode,
44
43 none_GmStatusCode = 0, 45 none_GmStatusCode = 0,
44 /* general status code categories */ 46 /* general status code categories */
45 categoryInput_GmStatusCode = 1, 47 categoryInput_GmStatusCode = 1,
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 9e8e644e..60e08459 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -666,6 +666,16 @@ static void setSource_DocumentWidget_(iDocumentWidget *d, const iString *source)
666 refresh_Widget(as_Widget(d)); 666 refresh_Widget(as_Widget(d));
667} 667}
668 668
669static void updateTheme_DocumentWidget_(iDocumentWidget *d) {
670 if (isEmpty_String(d->titleUser)) {
671 setThemeSeed_GmDocument(d->doc,
672 collect_Block(newRange_Block(urlHost_String(d->mod.url))));
673 }
674 else {
675 setThemeSeed_GmDocument(d->doc, &d->titleUser->chars);
676 }
677}
678
669static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode code, 679static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode code,
670 const iString *meta) { 680 const iString *meta) {
671 iString *src = collectNewCStr_String("# "); 681 iString *src = collectNewCStr_String("# ");
@@ -678,6 +688,9 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode
678 case tooManyRedirects_GmStatusCode: 688 case tooManyRedirects_GmStatusCode:
679 appendFormat_String(src, "\n=> %s\n", cstr_String(meta)); 689 appendFormat_String(src, "\n=> %s\n", cstr_String(meta));
680 break; 690 break;
691 case tlsFailure_GmStatusCode:
692 appendFormat_String(src, "\n\n>%s\n", cstr_String(meta));
693 break;
681 case failedToOpenFile_GmStatusCode: 694 case failedToOpenFile_GmStatusCode:
682 case certificateNotValid_GmStatusCode: 695 case certificateNotValid_GmStatusCode:
683 appendFormat_String(src, "\n\n%s", cstr_String(meta)); 696 appendFormat_String(src, "\n\n%s", cstr_String(meta));
@@ -702,21 +715,12 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode
702 } 715 }
703 } 716 }
704 setSource_DocumentWidget_(d, src); 717 setSource_DocumentWidget_(d, src);
718 updateTheme_DocumentWidget_(d);
705 init_Anim(&d->scrollY, 0); 719 init_Anim(&d->scrollY, 0);
706 init_Anim(&d->sideOpacity, 0); 720 init_Anim(&d->sideOpacity, 0);
707 d->state = ready_RequestState; 721 d->state = ready_RequestState;
708} 722}
709 723
710static void updateTheme_DocumentWidget_(iDocumentWidget *d) {
711 if (isEmpty_String(d->titleUser)) {
712 setThemeSeed_GmDocument(d->doc,
713 collect_Block(newRange_Block(urlHost_String(d->mod.url))));
714 }
715 else {
716 setThemeSeed_GmDocument(d->doc, &d->titleUser->chars);
717 }
718}
719
720static void updateFetchProgress_DocumentWidget_(iDocumentWidget *d) { 724static void updateFetchProgress_DocumentWidget_(iDocumentWidget *d) {
721 iLabelWidget *prog = findWidget_App("document.progress"); 725 iLabelWidget *prog = findWidget_App("document.progress");
722 const size_t dlSize = d->request ? size_Block(body_GmRequest(d->request)) : 0; 726 const size_t dlSize = d->request ? size_Block(body_GmRequest(d->request)) : 0;