diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-03 15:09:41 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-03 15:09:41 +0200 |
commit | ec30e00b93b08de5849795ce1359144dfd78c694 (patch) | |
tree | 44aa0f08f327a48cd85cf5ee6283505ed638f0a2 /src/ui/documentwidget.c | |
parent | 54ecf03f9ed055c8a84475eee0d5a50bb16eeb61 (diff) |
DocumentWidget: Certificate warning improvements
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 432dd290..a6cc8187 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -968,14 +968,14 @@ static void updateTrust_DocumentWidget_(iDocumentWidget *d, const iGmResponse *r | |||
968 | setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iFalse); | 968 | setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iFalse); |
969 | const iBool isDarkMode = isDark_ColorTheme(colorTheme_App()); | 969 | const iBool isDarkMode = isDark_ColorTheme(colorTheme_App()); |
970 | if (~d->certFlags & domainVerified_GmCertFlag) { | 970 | if (~d->certFlags & domainVerified_GmCertFlag) { |
971 | updateTextCStr_LabelWidget(lock, red_ColorEscape openLock_CStr); | 971 | updateTextCStr_LabelWidget(lock, red_ColorEscape "\u26a0"); |
972 | } | 972 | } |
973 | else if (d->certFlags & trusted_GmCertFlag) { | 973 | else if (d->certFlags & trusted_GmCertFlag) { |
974 | updateTextCStr_LabelWidget(lock, green_ColorEscape closedLock_CStr); | 974 | updateTextCStr_LabelWidget(lock, green_ColorEscape closedLock_CStr); |
975 | } | 975 | } |
976 | else { | 976 | else { |
977 | updateTextCStr_LabelWidget(lock, isDarkMode ? orange_ColorEscape closedLock_CStr | 977 | updateTextCStr_LabelWidget(lock, isDarkMode ? orange_ColorEscape "\u26a0" |
978 | : black_ColorEscape closedLock_CStr); | 978 | : black_ColorEscape "\u26a0"); |
979 | } | 979 | } |
980 | setBanner_GmDocument(d->doc, bannerType_DocumentWidget_(d)); | 980 | setBanner_GmDocument(d->doc, bannerType_DocumentWidget_(d)); |
981 | } | 981 | } |
@@ -2558,9 +2558,10 @@ static void drawBannerRun_DrawContext_(iDrawContext *d, const iGmRun *run, iInt2 | |||
2558 | const int days = secondsSince_Time(&oldUntil, &now) / 3600 / 24; | 2558 | const int days = secondsSince_Time(&oldUntil, &now) / 3600 / 24; |
2559 | if (days <= 30) { | 2559 | if (days <= 30) { |
2560 | appendFormat_String(&str, | 2560 | appendFormat_String(&str, |
2561 | "\nThe received certificate may have been recently renewed \u2014 it is " | 2561 | "\nThe received certificate may have been recently renewed " |
2562 | "for the correct domain and has not expired. The currently trusted " | 2562 | "\u2014 it is for the correct domain and has not expired. " |
2563 | "certificate will expire on %s, in %d days.", | 2563 | "The currently trusted certificate will expire on %s, " |
2564 | "in %d days.", | ||
2564 | cstrCollect_String(format_Date(&exp, "%Y-%m-%d")), | 2565 | cstrCollect_String(format_Date(&exp, "%Y-%m-%d")), |
2565 | days); | 2566 | days); |
2566 | } | 2567 | } |
@@ -2573,24 +2574,36 @@ static void drawBannerRun_DrawContext_(iDrawContext *d, const iGmRun *run, iInt2 | |||
2573 | appendFormat_String(&str, "\nThe received certificate has expired on %s.", | 2574 | appendFormat_String(&str, "\nThe received certificate has expired on %s.", |
2574 | cstrCollect_String(format_Date(&d->widget->certExpiry, "%Y-%m-%d"))); | 2575 | cstrCollect_String(format_Date(&d->widget->certExpiry, "%Y-%m-%d"))); |
2575 | } | 2576 | } |
2576 | if (certFlags & haveFingerprint_GmCertFlag) { | 2577 | else if (certFlags & timeVerified_GmCertFlag) { |
2577 | 2578 | appendFormat_String(&str, "\nThe received certificate is for the wrong domain (%s). " | |
2579 | "This may be a server configuration problem.", | ||
2580 | cstr_String(d->widget->certSubject)); | ||
2581 | } | ||
2582 | else { | ||
2583 | appendFormat_String(&str, "\nThe received certificate is expired AND for the " | ||
2584 | "wrong domain."); | ||
2578 | } | 2585 | } |
2579 | const iInt2 dims = advanceWrapRange_Text( | 2586 | const iInt2 dims = advanceWrapRange_Text( |
2580 | uiContent_FontId, width_Rect(rect) - 16 * gap_UI, range_String(&str)); | 2587 | uiContent_FontId, width_Rect(rect) - 16 * gap_UI, range_String(&str)); |
2581 | fillRect_Paint(&d->paint, | 2588 | const int warnHeight = run->visBounds.size.y - domainHeight; |
2582 | init_Rect(0, | 2589 | const int yOff = (lineHeight_Text(uiLabelLarge_FontId) - |
2583 | visPos.y + domainHeight, | 2590 | lineHeight_Text(uiContent_FontId)) / 2; |
2584 | d->widgetBounds.size.x, | 2591 | const iRect bgRect = |
2585 | dims.y + lineHeight_Text(uiContent_FontId) / 2), | 2592 | init_Rect(0, visPos.y + domainHeight, d->widgetBounds.size.x, warnHeight); |
2586 | orange_ColorId); | 2593 | fillRect_Paint(&d->paint, bgRect, orange_ColorId); |
2594 | if (!isDark_ColorTheme(colorTheme_App())) { | ||
2595 | drawHLine_Paint(&d->paint, | ||
2596 | topLeft_Rect(bgRect), width_Rect(bgRect), tmBannerTitle_ColorId); | ||
2597 | drawHLine_Paint(&d->paint, | ||
2598 | bottomLeft_Rect(bgRect), width_Rect(bgRect), tmBannerTitle_ColorId); | ||
2599 | } | ||
2587 | const int fg = black_ColorId; | 2600 | const int fg = black_ColorId; |
2601 | adjustEdges_Rect(&rect, warnHeight / 2 - dims.y / 2 - yOff, 0, 0, 0); | ||
2588 | bpos = topLeft_Rect(rect); | 2602 | bpos = topLeft_Rect(rect); |
2589 | draw_Text(uiLabelLarge_FontId, bpos, fg, "\u26a0"); | 2603 | draw_Text(uiLabelLarge_FontId, bpos, fg, "\u26a0"); |
2590 | adjustEdges_Rect(&rect, 0, -8 * gap_UI, 0, 8 * gap_UI); | 2604 | adjustEdges_Rect(&rect, 0, -8 * gap_UI, 0, 8 * gap_UI); |
2591 | drawWrapRange_Text(uiContent_FontId, | 2605 | drawWrapRange_Text(uiContent_FontId, |
2592 | addY_I2(topLeft_Rect(rect), (lineHeight_Text(uiLabelLarge_FontId) - | 2606 | addY_I2(topLeft_Rect(rect), yOff), |
2593 | lineHeight_Text(uiContent_FontId)) / 2), | ||
2594 | width_Rect(rect), | 2607 | width_Rect(rect), |
2595 | fg, | 2608 | fg, |
2596 | range_String(&str)); | 2609 | range_String(&str)); |