diff options
-rw-r--r-- | src/ui/documentwidget.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 93505c13..7450ba12 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -82,6 +82,7 @@ struct Impl_DocumentWidget { | |||
82 | iAtomicInt isRequestUpdated; /* request has new content, need to parse it */ | 82 | iAtomicInt isRequestUpdated; /* request has new content, need to parse it */ |
83 | iObjectList *media; | 83 | iObjectList *media; |
84 | iGmDocument *doc; | 84 | iGmDocument *doc; |
85 | int certFlags; | ||
85 | iBool selecting; | 86 | iBool selecting; |
86 | iRangecc selectMark; | 87 | iRangecc selectMark; |
87 | iRangecc foundMark; | 88 | iRangecc foundMark; |
@@ -110,6 +111,7 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
110 | d->isRequestUpdated = iFalse; | 111 | d->isRequestUpdated = iFalse; |
111 | d->media = new_ObjectList(); | 112 | d->media = new_ObjectList(); |
112 | d->doc = new_GmDocument(); | 113 | d->doc = new_GmDocument(); |
114 | d->certFlags = 0; | ||
113 | d->selecting = iFalse; | 115 | d->selecting = iFalse; |
114 | d->selectMark = iNullRange; | 116 | d->selectMark = iNullRange; |
115 | d->foundMark = iNullRange; | 117 | d->foundMark = iNullRange; |
@@ -353,6 +355,7 @@ static void fetch_DocumentWidget_(iDocumentWidget *d) { | |||
353 | } | 355 | } |
354 | postCommandf_App("document.request.started url:%s", cstr_String(d->url)); | 356 | postCommandf_App("document.request.started url:%s", cstr_String(d->url)); |
355 | clear_ObjectList(d->media); | 357 | clear_ObjectList(d->media); |
358 | d->certFlags = 0; | ||
356 | d->state = fetching_DocumentState; | 359 | d->state = fetching_DocumentState; |
357 | set_Atomic(&d->isRequestUpdated, iFalse); | 360 | set_Atomic(&d->isRequestUpdated, iFalse); |
358 | d->request = new_GmRequest(); | 361 | d->request = new_GmRequest(); |
@@ -410,18 +413,18 @@ static void updateTrust_DocumentWidget_(iDocumentWidget *d) { | |||
410 | iAssert(d->request); | 413 | iAssert(d->request); |
411 | #define openLock_CStr "\U0001f513" | 414 | #define openLock_CStr "\U0001f513" |
412 | #define closedLock_CStr "\U0001f512" | 415 | #define closedLock_CStr "\U0001f512" |
413 | int certFlags = certFlags_GmRequest(d->request); | 416 | d->certFlags = certFlags_GmRequest(d->request); |
414 | iLabelWidget *lock = findWidget_App("navbar.lock"); | 417 | iLabelWidget *lock = findWidget_App("navbar.lock"); |
415 | if (~certFlags & available_GmRequestCertFlag) { | 418 | if (~d->certFlags & available_GmRequestCertFlag) { |
416 | setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iTrue); | 419 | setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iTrue); |
417 | updateTextCStr_LabelWidget(lock, gray50_ColorEscape openLock_CStr); | 420 | updateTextCStr_LabelWidget(lock, gray50_ColorEscape openLock_CStr); |
418 | return; | 421 | return; |
419 | } | 422 | } |
420 | setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iFalse); | 423 | setFlags_Widget(as_Widget(lock), disabled_WidgetFlag, iFalse); |
421 | if (~certFlags & domainVerified_GmRequestCertFlag) { | 424 | if (~d->certFlags & domainVerified_GmRequestCertFlag) { |
422 | updateTextCStr_LabelWidget(lock, red_ColorEscape closedLock_CStr); | 425 | updateTextCStr_LabelWidget(lock, red_ColorEscape closedLock_CStr); |
423 | } | 426 | } |
424 | else if (certFlags & trusted_GmRequestCertFlag) { | 427 | else if (d->certFlags & trusted_GmRequestCertFlag) { |
425 | updateTextCStr_LabelWidget(lock, green_ColorEscape closedLock_CStr); | 428 | updateTextCStr_LabelWidget(lock, green_ColorEscape closedLock_CStr); |
426 | } | 429 | } |
427 | else { | 430 | else { |
@@ -575,6 +578,29 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
575 | updateVisible_DocumentWidget_(d); | 578 | updateVisible_DocumentWidget_(d); |
576 | refresh_Widget(w); | 579 | refresh_Widget(w); |
577 | } | 580 | } |
581 | else if (isCommand_UserEvent(ev, "server.showcert")) { | ||
582 | const char *unchecked = red_ColorEscape "\u2610"; | ||
583 | const char *checked = green_ColorEscape "\u2611"; | ||
584 | makeMessage_Widget( | ||
585 | cyan_ColorEscape "CERTIFICATE STATUS", | ||
586 | format_CStr("%s%s Certificate %s\n" | ||
587 | "%s%s Domain name %s\n" | ||
588 | "%s%s %s\n" | ||
589 | "%s%s %s", | ||
590 | d->certFlags & available_GmRequestCertFlag ? checked : unchecked, | ||
591 | gray75_ColorEscape, | ||
592 | d->certFlags & available_GmRequestCertFlag ? "available" : "not available", | ||
593 | d->certFlags & domainVerified_GmRequestCertFlag ? checked : unchecked, | ||
594 | gray75_ColorEscape, | ||
595 | d->certFlags & domainVerified_GmRequestCertFlag ? "matches" : "mismatch", | ||
596 | d->certFlags & timeVerified_GmRequestCertFlag ? checked : unchecked, | ||
597 | gray75_ColorEscape, | ||
598 | d->certFlags & timeVerified_GmRequestCertFlag ? "Not expired" : "Expired", | ||
599 | d->certFlags & trusted_GmRequestCertFlag ? checked : unchecked, | ||
600 | gray75_ColorEscape, | ||
601 | d->certFlags & trusted_GmRequestCertFlag ? "Trusted on first use" : "Not trusted")); | ||
602 | return iTrue; | ||
603 | } | ||
578 | else if (isCommand_UserEvent(ev, "copy")) { | 604 | else if (isCommand_UserEvent(ev, "copy")) { |
579 | if (d->selectMark.start) { | 605 | if (d->selectMark.start) { |
580 | iRangecc mark = d->selectMark; | 606 | iRangecc mark = d->selectMark; |