summaryrefslogtreecommitdiff
path: root/src/gmcerts.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-03 10:41:15 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-03 10:41:15 +0200
commitad86fbe2cffa2bea07d004782e711932c5c91a79 (patch)
tree5df37073ad27b9893c4f42673e02e39ceb0a1176 /src/gmcerts.c
parent6e917280380316eba77b1dfa983daf488510e70f (diff)
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.
Diffstat (limited to 'src/gmcerts.c')
-rw-r--r--src/gmcerts.c16
1 files changed, 15 insertions, 1 deletions
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) {
146} 146}
147 147
148iBool isUsedOn_GmIdentity(const iGmIdentity *d, const iString *url) { 148iBool isUsedOn_GmIdentity(const iGmIdentity *d, const iString *url) {
149#if 0
149 size_t pos = iInvalidPos; 150 size_t pos = iInvalidPos;
150 locate_StringSet(d->useUrls, url, &pos); 151 locate_StringSet(d->useUrls, url, &pos);
151 if (pos < size_StringSet(d->useUrls)) { 152 if (pos < size_StringSet(d->useUrls)) {
@@ -159,6 +160,12 @@ iBool isUsedOn_GmIdentity(const iGmIdentity *d, const iString *url) {
159 return iTrue; 160 return iTrue;
160 } 161 }
161 } 162 }
163#endif
164 iConstForEach(StringSet, i, d->useUrls) {
165 if (startsWithCase_String(url, cstr_String(i.value))) {
166 return iTrue;
167 }
168 }
162 return iFalse; 169 return iFalse;
163} 170}
164 171
@@ -193,7 +200,13 @@ void setUse_GmIdentity(iGmIdentity *d, const iString *url, iBool use) {
193 iAssert(wasInserted); 200 iAssert(wasInserted);
194 } 201 }
195 else { 202 else {
196 remove_StringSet(d->useUrls, url); 203 iForEach(Array, i, &d->useUrls->strings.values) {
204 iString *used = i.value;
205 if (startsWithCase_String(url, cstr_String(used))) {
206 deinit_String(used);
207 remove_ArrayIterator(&i);
208 }
209 }
197 } 210 }
198} 211}
199 212
@@ -202,6 +215,7 @@ void clearUse_GmIdentity(iGmIdentity *d) {
202} 215}
203 216
204const iString *findUse_GmIdentity(const iGmIdentity *d, const iString *url) { 217const iString *findUse_GmIdentity(const iGmIdentity *d, const iString *url) {
218 if (!d) return NULL;
205 iConstForEach(StringSet, using, d->useUrls) { 219 iConstForEach(StringSet, using, d->useUrls) {
206 if (startsWith_String(url, cstr_String(using.value))) { 220 if (startsWith_String(url, cstr_String(using.value))) {
207 return using.value; 221 return using.value;