From ad86fbe2cffa2bea07d004782e711932c5c91a79 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 3 Dec 2021 10:41:15 +0200 Subject: Improving identity use The URL checks for determining which identity was in use were a bit too page-specific. Now the URL prefix usage is applied more consistently. The identity toolbar menu is now more useful in that it allows both switching identities and stopping the use of the current identity. --- src/gmcerts.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/gmcerts.c') diff --git a/src/gmcerts.c b/src/gmcerts.c index 345c36e0..ed4759be 100644 --- a/src/gmcerts.c +++ b/src/gmcerts.c @@ -146,6 +146,7 @@ iBool isUsed_GmIdentity(const iGmIdentity *d) { } iBool isUsedOn_GmIdentity(const iGmIdentity *d, const iString *url) { +#if 0 size_t pos = iInvalidPos; locate_StringSet(d->useUrls, url, &pos); if (pos < size_StringSet(d->useUrls)) { @@ -159,6 +160,12 @@ iBool isUsedOn_GmIdentity(const iGmIdentity *d, const iString *url) { return iTrue; } } +#endif + iConstForEach(StringSet, i, d->useUrls) { + if (startsWithCase_String(url, cstr_String(i.value))) { + return iTrue; + } + } return iFalse; } @@ -193,7 +200,13 @@ void setUse_GmIdentity(iGmIdentity *d, const iString *url, iBool use) { iAssert(wasInserted); } else { - remove_StringSet(d->useUrls, url); + iForEach(Array, i, &d->useUrls->strings.values) { + iString *used = i.value; + if (startsWithCase_String(url, cstr_String(used))) { + deinit_String(used); + remove_ArrayIterator(&i); + } + } } } @@ -202,6 +215,7 @@ void clearUse_GmIdentity(iGmIdentity *d) { } const iString *findUse_GmIdentity(const iGmIdentity *d, const iString *url) { + if (!d) return NULL; iConstForEach(StringSet, using, d->useUrls) { if (startsWith_String(url, cstr_String(using.value))) { return using.value; -- cgit v1.2.3