diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-03 17:25:37 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-03 17:25:37 +0200 |
commit | 4c1788101c325b67f29121573479f446350bfd25 (patch) | |
tree | e9704a64606eefc66fb1bc13ad67171b335eaad5 /src | |
parent | 016a4eff9ee552bd8d60564aaf1699242da6eab9 (diff) |
Improving the Page Information dialog
This should use a proper dialog instead of a simple message.
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/documentwidget.c | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index e3e9ce61..ff23b32b 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1553,6 +1553,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1553 | const char *checked = green_ColorEscape "\u2611"; | 1553 | const char *checked = green_ColorEscape "\u2611"; |
1554 | const char *actionLabels[] = { uiTextCaution_ColorEscape "Trust", "Copy Fingerprint", "Dismiss" }; | 1554 | const char *actionLabels[] = { uiTextCaution_ColorEscape "Trust", "Copy Fingerprint", "Dismiss" }; |
1555 | const char *actionCmds[] = { "server.trustcert", "server.copycert", "message.ok" }; | 1555 | const char *actionCmds[] = { "server.trustcert", "server.copycert", "message.ok" }; |
1556 | const iBool haveFingerprint = (d->certFlags & haveFingerprint_GmCertFlag) != 0; | ||
1556 | const iBool canTrust = | 1557 | const iBool canTrust = |
1557 | (d->certFlags == (available_GmCertFlag | haveFingerprint_GmCertFlag | | 1558 | (d->certFlags == (available_GmCertFlag | haveFingerprint_GmCertFlag | |
1558 | timeVerified_GmCertFlag | domainVerified_GmCertFlag)); | 1559 | timeVerified_GmCertFlag | domainVerified_GmCertFlag)); |
@@ -1562,8 +1563,9 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1562 | meta = &recent->cachedResponse->meta; | 1563 | meta = &recent->cachedResponse->meta; |
1563 | } | 1564 | } |
1564 | iString *msg = collectNew_String(); | 1565 | iString *msg = collectNew_String(); |
1565 | format_String(msg, | 1566 | appendFormat_String(msg, "%s\n%zu bytes\n", cstr_String(meta), size_Block(&d->sourceContent)); |
1566 | "%sCertificate Status:\n%s%s Domain name %s%s\n" | 1567 | appendFormat_String(msg, |
1568 | "\n%sCertificate Status:\n%s%s Domain name %s%s\n" | ||
1567 | "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n" | 1569 | "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n" |
1568 | "%s%s %s", | 1570 | "%s%s %s", |
1569 | uiHeading_ColorEscape, | 1571 | uiHeading_ColorEscape, |
@@ -1585,33 +1587,12 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1585 | d->certFlags & trusted_GmCertFlag ? checked : unchecked, | 1587 | d->certFlags & trusted_GmCertFlag ? checked : unchecked, |
1586 | uiText_ColorEscape, | 1588 | uiText_ColorEscape, |
1587 | d->certFlags & trusted_GmCertFlag ? "Trusted" : "Not trusted"); | 1589 | d->certFlags & trusted_GmCertFlag ? "Trusted" : "Not trusted"); |
1588 | iString *fp = collect_String(hexEncode_Block(d->certFingerprint)); | 1590 | setFocus_Widget(NULL); |
1589 | if (isEmpty_String(fp)) { | ||
1590 | setCStr_String(fp, "(not cached)"); | ||
1591 | } | ||
1592 | else { | ||
1593 | insertData_Block(&fp->chars, size_String(fp) / 2, "\n", 1); | ||
1594 | } | ||
1595 | appendFormat_String(msg, | ||
1596 | "\n%sFingerprint:\n%s%s", | ||
1597 | uiHeading_ColorEscape, | ||
1598 | uiText_ColorEscape, | ||
1599 | cstr_String(fp)); | ||
1600 | appendFormat_String(msg, | ||
1601 | "\n%sMedia Type:\n%s%s", | ||
1602 | uiHeading_ColorEscape, | ||
1603 | uiText_ColorEscape, | ||
1604 | cstr_String(meta)); | ||
1605 | appendFormat_String(msg, | ||
1606 | "\n%sContent Length:\n%s%zu", | ||
1607 | uiHeading_ColorEscape, | ||
1608 | uiText_ColorEscape, | ||
1609 | size_Block(&d->sourceContent)); | ||
1610 | iWidget *dlg = makeQuestion_Widget(uiHeading_ColorEscape "PAGE INFORMATION", | 1591 | iWidget *dlg = makeQuestion_Widget(uiHeading_ColorEscape "PAGE INFORMATION", |
1611 | cstr_String(msg), | 1592 | cstr_String(msg), |
1612 | actionLabels + (canTrust ? 0 : 1), | 1593 | actionLabels + (canTrust ? 0 : haveFingerprint ? 1 : 2), |
1613 | actionCmds + (canTrust ? 0 : 1), | 1594 | actionCmds + (canTrust ? 0 : haveFingerprint ? 1 : 2), |
1614 | canTrust ? 3 : 2); | 1595 | canTrust ? 3 : haveFingerprint ? 2 : 1); |
1615 | addAction_Widget(dlg, SDLK_ESCAPE, 0, "message.ok"); | 1596 | addAction_Widget(dlg, SDLK_ESCAPE, 0, "message.ok"); |
1616 | addAction_Widget(dlg, SDLK_SPACE, 0, "message.ok"); | 1597 | addAction_Widget(dlg, SDLK_SPACE, 0, "message.ok"); |
1617 | return iTrue; | 1598 | return iTrue; |
@@ -1621,6 +1602,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1621 | if (!isEmpty_Block(d->certFingerprint) && !isEmpty_Range(&host)) { | 1602 | if (!isEmpty_Block(d->certFingerprint) && !isEmpty_Range(&host)) { |
1622 | setTrusted_GmCerts(certs_App(), host, d->certFingerprint, &d->certExpiry); | 1603 | setTrusted_GmCerts(certs_App(), host, d->certFingerprint, &d->certExpiry); |
1623 | d->certFlags |= trusted_GmCertFlag; | 1604 | d->certFlags |= trusted_GmCertFlag; |
1605 | postCommand_App("document.reload"); | ||
1624 | postCommand_App("document.info"); | 1606 | postCommand_App("document.info"); |
1625 | } | 1607 | } |
1626 | return iTrue; | 1608 | return iTrue; |