summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gmrequest.c7
-rw-r--r--src/ui/documentwidget.c35
2 files changed, 27 insertions, 15 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index c0697f49..7b110c03 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -343,7 +343,12 @@ int certFlags_GmRequest(const iGmRequest *d) {
343 343
344iDate certExpirationDate_GmRequest(const iGmRequest *d) { 344iDate certExpirationDate_GmRequest(const iGmRequest *d) {
345 iDate expiry; 345 iDate expiry;
346 validUntil_TlsCertificate(serverCertificate_TlsRequest(d->req), &expiry); 346 if (d->req) {
347 validUntil_TlsCertificate(serverCertificate_TlsRequest(d->req), &expiry);
348 }
349 else {
350 iZap(expiry);
351 }
347 return expiry; 352 return expiry;
348} 353}
349 354
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index dd119e3e..d13f6f01 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -84,6 +84,7 @@ struct Impl_DocumentWidget {
84 iObjectList *media; 84 iObjectList *media;
85 iGmDocument *doc; 85 iGmDocument *doc;
86 int certFlags; 86 int certFlags;
87 iDate certExpiry;
87 iBool selecting; 88 iBool selecting;
88 iRangecc selectMark; 89 iRangecc selectMark;
89 iRangecc foundMark; 90 iRangecc foundMark;
@@ -106,6 +107,7 @@ void init_DocumentWidget(iDocumentWidget *d) {
106 iWidget *w = as_Widget(d); 107 iWidget *w = as_Widget(d);
107 init_Widget(w); 108 init_Widget(w);
108 setId_Widget(w, "document"); 109 setId_Widget(w, "document");
110 iZap(d->certExpiry);
109 d->state = blank_DocumentState; 111 d->state = blank_DocumentState;
110 d->url = new_String(); 112 d->url = new_String();
111 d->titleUser = new_String(); 113 d->titleUser = new_String();
@@ -430,7 +432,8 @@ static void updateTrust_DocumentWidget_(iDocumentWidget *d) {
430 iAssert(d->request); 432 iAssert(d->request);
431#define openLock_CStr "\U0001f513" 433#define openLock_CStr "\U0001f513"
432#define closedLock_CStr "\U0001f512" 434#define closedLock_CStr "\U0001f512"
433 d->certFlags = certFlags_GmRequest(d->request); 435 d->certFlags = certFlags_GmRequest(d->request);
436 d->certExpiry = certExpirationDate_GmRequest(d->request);
434 iLabelWidget *lock = findWidget_App("navbar.lock"); 437 iLabelWidget *lock = findWidget_App("navbar.lock");
435 if (~d->certFlags & available_GmRequestCertFlag) { 438 if (~d->certFlags & available_GmRequestCertFlag) {
436 setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iTrue); 439 setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iTrue);
@@ -603,22 +606,24 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
603 } 606 }
604 else if (isCommand_UserEvent(ev, "server.showcert")) { 607 else if (isCommand_UserEvent(ev, "server.showcert")) {
605 const char *unchecked = red_ColorEscape "\u2610"; 608 const char *unchecked = red_ColorEscape "\u2610";
606 const char *checked = green_ColorEscape "\u2611"; 609 const char *checked = green_ColorEscape "\u2611";
607 makeMessage_Widget( 610 makeMessage_Widget(
608 cyan_ColorEscape "CERTIFICATE STATUS", 611 cyan_ColorEscape "CERTIFICATE STATUS",
609 format_CStr("%s%s Certificate %s\n" 612 format_CStr("%s%s Domain name %s\n"
610 "%s%s Domain name %s\n" 613 "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n"
611 "%s%s %s\n"
612 "%s%s %s", 614 "%s%s %s",
613 d->certFlags & available_GmRequestCertFlag ? checked : unchecked,
614 gray75_ColorEscape,
615 d->certFlags & available_GmRequestCertFlag ? "available" : "not available",
616 d->certFlags & domainVerified_GmRequestCertFlag ? checked : unchecked, 615 d->certFlags & domainVerified_GmRequestCertFlag ? checked : unchecked,
617 gray75_ColorEscape, 616 gray75_ColorEscape,
618 d->certFlags & domainVerified_GmRequestCertFlag ? "matches" : "mismatch", 617 d->certFlags & domainVerified_GmRequestCertFlag ? "matches" : "mismatch",
619 d->certFlags & timeVerified_GmRequestCertFlag ? checked : unchecked, 618 d->certFlags & timeVerified_GmRequestCertFlag ? checked : unchecked,
620 gray75_ColorEscape, 619 gray75_ColorEscape,
621 d->certFlags & timeVerified_GmRequestCertFlag ? "Not expired" : "Expired", 620 d->certFlags & timeVerified_GmRequestCertFlag ? "Not expired" : "Expired",
621 d->certExpiry.year,
622 d->certExpiry.month,
623 d->certExpiry.day,
624 d->certExpiry.hour,
625 d->certExpiry.minute,
626 d->certExpiry.second,
622 d->certFlags & trusted_GmRequestCertFlag ? checked : unchecked, 627 d->certFlags & trusted_GmRequestCertFlag ? checked : unchecked,
623 gray75_ColorEscape, 628 gray75_ColorEscape,
624 d->certFlags & trusted_GmRequestCertFlag ? "Trusted on first use" : "Not trusted")); 629 d->certFlags & trusted_GmRequestCertFlag ? "Trusted on first use" : "Not trusted"));
@@ -778,7 +783,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
778 } 783 }
779 } 784 }
780 else if (ev->type == SDL_MOUSEWHEEL) { 785 else if (ev->type == SDL_MOUSEWHEEL) {
781 scroll_DocumentWidget_(d, -3 * ev->wheel.y * lineHeight_Text(default_FontId)); 786 scroll_DocumentWidget_(d, -3 * ev->wheel.y * lineHeight_Text(paragraph_FontId));
782 return iTrue; 787 return iTrue;
783 } 788 }
784 else if (ev->type == SDL_MOUSEMOTION) { 789 else if (ev->type == SDL_MOUSEMOTION) {
@@ -831,8 +836,10 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
831 if (isMediaLink_GmDocument(d->doc, linkId)) { 836 if (isMediaLink_GmDocument(d->doc, linkId)) {
832 if (!requestMedia_DocumentWidget_(d, linkId)) { 837 if (!requestMedia_DocumentWidget_(d, linkId)) {
833 if (linkFlags_GmDocument(d->doc, linkId) & content_GmLinkFlag) { 838 if (linkFlags_GmDocument(d->doc, linkId) & content_GmLinkFlag) {
839 /* Dismiss shown content on click. */
834 setImage_GmDocument(d->doc, linkId, NULL, NULL); 840 setImage_GmDocument(d->doc, linkId, NULL, NULL);
835 d->hoverLink = NULL; 841 d->hoverLink = NULL;
842 scroll_DocumentWidget_(d, 0);
836 updateVisible_DocumentWidget_(d); 843 updateVisible_DocumentWidget_(d);
837 refresh_Widget(w); 844 refresh_Widget(w);
838 return iTrue; 845 return iTrue;
@@ -964,7 +971,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
964 appendFormat_String( 971 appendFormat_String(
965 &text, " %s\U0001f7a8", isHover ? white_ColorEscape : ""); 972 &text, " %s\U0001f7a8", isHover ? white_ColorEscape : "");
966 } 973 }
967 drawAlign_Text(default_FontId, 974 drawAlign_Text(uiLabel_FontId,
968 add_I2(topRight_Rect(run->bounds), origin), 975 add_I2(topRight_Rect(run->bounds), origin),
969 fg, 976 fg,
970 right_Alignment, 977 right_Alignment,
@@ -975,7 +982,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
975 else if (run->flags & endOfLine_GmRunFlag && 982 else if (run->flags & endOfLine_GmRunFlag &&
976 (mr = findMediaRequest_DocumentWidget_(d->widget, run->linkId)) != NULL) { 983 (mr = findMediaRequest_DocumentWidget_(d->widget, run->linkId)) != NULL) {
977 if (!isFinished_GmRequest(mr->req)) { 984 if (!isFinished_GmRequest(mr->req)) {
978 draw_Text(default_FontId, 985 draw_Text(uiLabel_FontId,
979 topRight_Rect(linkRect), 986 topRight_Rect(linkRect),
980 linkColor_GmDocument(doc, run->linkId), 987 linkColor_GmDocument(doc, run->linkId),
981 " \u2014 Fetching\u2026"); 988 " \u2014 Fetching\u2026");
@@ -1014,7 +1021,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1014 cstr_String(collect_String(format_Date(&date, "%b %d")))); 1021 cstr_String(collect_String(format_Date(&date, "%b %d"))));
1015 } 1022 }
1016 if (!isEmpty_String(&str)) { 1023 if (!isEmpty_String(&str)) {
1017 const iInt2 textSize = measure_Text(default_FontId, cstr_String(&str)); 1024 const iInt2 textSize = measure_Text(uiLabel_FontId, cstr_String(&str));
1018 int tx = topRight_Rect(linkRect).x; 1025 int tx = topRight_Rect(linkRect).x;
1019 const char *msg = cstr_String(&str); 1026 const char *msg = cstr_String(&str);
1020 if (tx + textSize.x > right_Rect(d->widgetBounds)) { 1027 if (tx + textSize.x > right_Rect(d->widgetBounds)) {
@@ -1022,9 +1029,9 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1022 fillRect_Paint(&d->paint, (iRect){ init_I2(tx, top_Rect(linkRect)), textSize }, 1029 fillRect_Paint(&d->paint, (iRect){ init_I2(tx, top_Rect(linkRect)), textSize },
1023 black_ColorId); 1030 black_ColorId);
1024 msg += 4; /* skip the space and dash */ 1031 msg += 4; /* skip the space and dash */
1025 tx += measure_Text(default_FontId, " \u2014").x / 2; 1032 tx += measure_Text(uiLabel_FontId, " \u2014").x / 2;
1026 } 1033 }
1027 drawAlign_Text(default_FontId, 1034 drawAlign_Text(uiLabel_FontId,
1028 init_I2(tx, top_Rect(linkRect)), 1035 init_I2(tx, top_Rect(linkRect)),
1029 fg - 1, 1036 fg - 1,
1030 left_Alignment, 1037 left_Alignment,