diff options
author | Vivien Kraus <vivien@planete-kraus.eu> | 2021-10-04 16:06:47 +0200 |
---|---|---|
committer | Vivien Kraus <vivien@planete-kraus.eu> | 2021-10-04 23:22:15 +0200 |
commit | dd18ea62055a95733db6c7bc507e01783e526858 (patch) | |
tree | b97c9f2a7162293783647642cdc414e4c89052b2 | |
parent | 99e06ec6d2e38abd28e2a3110676108de5700406 (diff) |
gui: add an account when the account adding button is clicked
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | po/disfluid.pot | 9 | ||||
-rw-r--r-- | po/fr.po | 13 | ||||
-rw-r--r-- | src/scm/webid-oidc/client/gui/Makefile.am | 2 | ||||
-rw-r--r-- | src/scm/webid-oidc/client/gui/accounts-widget-logic.scm | 75 | ||||
-rw-r--r-- | src/scm/webid-oidc/client/gui/accounts-widget.scm | 22 |
6 files changed, 96 insertions, 26 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in index 53cc8aa..d2b2a74 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -42,6 +42,7 @@ src/scm/webid-oidc/client/gui/application.scm src/scm/webid-oidc/client/gui/application-hooks.scm src/scm/webid-oidc/client/gui/account-widget.scm src/scm/webid-oidc/client/gui/accounts-widget.scm +src/scm/webid-oidc/client/gui/accounts-widget-logic.scm src/scm/webid-oidc/client/gui/authorization-prompt.scm src/scm/webid-oidc/client/gui/authorizations-widget.scm src/scm/webid-oidc/client/gui/client-widget.scm diff --git a/po/disfluid.pot b/po/disfluid.pot index bfd8bbc..1d64deb 100644 --- a/po/disfluid.pot +++ b/po/disfluid.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: disfluid SNAPSHOT\n" "Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n" -"POT-Creation-Date: 2021-10-04 23:19+0200\n" +"POT-Creation-Date: 2021-10-04 23:21+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -651,12 +651,7 @@ msgstr "" msgid "You don’t have set up an account yet." msgstr "" -#: src/scm/webid-oidc/client/gui/accounts-widget.scm:135 -#, scheme-format -msgid "Stub: adding an account with identity provider ~s...\n" -msgstr "" - -#: src/scm/webid-oidc/client/gui/accounts-widget.scm:139 +#: src/scm/webid-oidc/client/gui/accounts-widget-logic.scm:75 msgid "Stub: please enter an URI or a host name...\n" msgstr "" @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: webid-oidc 0.0.0\n" "Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n" -"POT-Creation-Date: 2021-10-04 23:19+0200\n" +"POT-Creation-Date: 2021-10-04 23:21+0200\n" "PO-Revision-Date: 2021-10-04 23:06+0200\n" "Last-Translator: Vivien Kraus <vivien@planete-kraus.eu>\n" "Language-Team: French <vivien@planete-kraus.eu>\n" @@ -705,12 +705,7 @@ msgstr "" msgid "You don’t have set up an account yet." msgstr "Vous n’avez pas encore défini de compte." -#: src/scm/webid-oidc/client/gui/accounts-widget.scm:135 -#, scheme-format -msgid "Stub: adding an account with identity provider ~s...\n" -msgstr "Bouchon : ajout d’un compte avec le fournisseur d’identité ~s…\n" - -#: src/scm/webid-oidc/client/gui/accounts-widget.scm:139 +#: src/scm/webid-oidc/client/gui/accounts-widget-logic.scm:75 msgid "Stub: please enter an URI or a host name...\n" msgstr "Bouchon : veuillez entrer une URI ou un nom d’hôte…\n" @@ -2688,6 +2683,10 @@ msgid "Update" msgstr "Mettre à jour" #, scheme-format +#~ msgid "Stub: adding an account with identity provider ~s...\n" +#~ msgstr "Bouchon : ajout d’un compte avec le fournisseur d’identité ~s…\n" + +#, scheme-format #~ msgid "To log in on ~a, please visit: ~a\n" #~ msgstr "Pour vous connecte avec ~a, veuillez visiter : ~a\n" diff --git a/src/scm/webid-oidc/client/gui/Makefile.am b/src/scm/webid-oidc/client/gui/Makefile.am index 97b1cb6..fc8f751 100644 --- a/src/scm/webid-oidc/client/gui/Makefile.am +++ b/src/scm/webid-oidc/client/gui/Makefile.am @@ -19,6 +19,7 @@ dist_guiclientwebidoidcmod_DATA += \ %reldir%/client-widget.scm \ %reldir%/account-widget.scm \ %reldir%/accounts-widget.scm \ + %reldir%/accounts-widget-logic.scm \ %reldir%/application-hooks.scm \ %reldir%/application.scm \ %reldir%/authorization-prompt.scm \ @@ -30,6 +31,7 @@ guiclientwebidoidcgo_DATA += \ %reldir%/client-widget.go \ %reldir%/account-widget.go \ %reldir%/accounts-widget.go \ + %reldir%/accounts-widget-logic.go \ %reldir%/application-hooks.go \ %reldir%/application.go \ %reldir%/authorization-prompt.go \ diff --git a/src/scm/webid-oidc/client/gui/accounts-widget-logic.scm b/src/scm/webid-oidc/client/gui/accounts-widget-logic.scm new file mode 100644 index 0000000..2ea9024 --- /dev/null +++ b/src/scm/webid-oidc/client/gui/accounts-widget-logic.scm @@ -0,0 +1,75 @@ +;; disfluid, implementation of the Solid specification +;; Copyright (C) 2021 Vivien Kraus + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU Affero General Public License as +;; published by the Free Software Foundation, either version 3 of the +;; License, or (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU Affero General Public License for more details. + +;; You should have received a copy of the GNU Affero General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +(define-module (webid-oidc client gui accounts-widget-logic) + #:use-module (ice-9 match) + #:use-module (ice-9 exceptions) + #:use-module (ice-9 i18n) + #:use-module (ice-9 receive) + #:use-module (ice-9 optargs) + #:use-module (ice-9 pretty-print) + #:use-module (ice-9 threads) + #:use-module (srfi srfi-9) + #:use-module (srfi srfi-19) + #:use-module (srfi srfi-26) + #:use-module (webid-oidc errors) + #:use-module ((webid-oidc parameters) #:prefix p:) + #:use-module ((webid-oidc stubs) #:prefix stubs:) + #:use-module ((webid-oidc config) #:prefix config:) + #:use-module (webid-oidc web-i18n) + #:use-module (webid-oidc offloading) + #:use-module (webid-oidc client client) + #:use-module (webid-oidc client accounts) + #:use-module (webid-oidc client gui account-widget) + #:use-module ((webid-oidc client gui settings) #:prefix settings:) + #:use-module ((webid-oidc client gui clock) #:prefix clock:) + #:use-module (webid-oidc client gui application-hooks) + #:use-module (webid-oidc client gui authorizations-widget) + #:use-module (webid-oidc jwk) + #:use-module (webid-oidc oidc-id-token) + #:use-module (web uri) + #:use-module (web response) + #:use-module (rnrs bytevectors) + #:use-module (oop goops) + #:declarative? #t + #:duplicates (merge-generics) + #:export + ( + add-account-button-clicked + )) + +(define (add-account-button-clicked issuer clear-issuer-entry!) + (define (as-host-name host) + (false-if-exception + (build-uri 'https #:host host))) + (match issuer + ((or (? string? (= string->uri (? uri? uri))) + (? string? (= as-host-name (? uri? uri)))) + (clear-issuer-entry!) + (use-authorizations-widget + (lambda () + (let ((new-account + (make <account> + #:issuer uri))) + (clock:wait + (lambda () + (let ((old (settings:main-account)) + (other (settings:other-accounts))) + (if old + (settings:other-accounts `(,new-account ,@other)) + (settings:main-account new-account))))))))) + (else + (format (current-error-port) (G_ "Stub: please enter an URI or a host name...\n"))))) diff --git a/src/scm/webid-oidc/client/gui/accounts-widget.scm b/src/scm/webid-oidc/client/gui/accounts-widget.scm index 3064e9a..b9e5403 100644 --- a/src/scm/webid-oidc/client/gui/accounts-widget.scm +++ b/src/scm/webid-oidc/client/gui/accounts-widget.scm @@ -36,6 +36,8 @@ #:use-module (webid-oidc client gui account-widget) #:use-module ((webid-oidc client gui settings) #:prefix settings:) #:use-module (webid-oidc client gui application-hooks) + #:use-module (webid-oidc client gui authorizations-widget) + #:use-module (webid-oidc client gui accounts-widget-logic) #:use-module (webid-oidc jwk) #:use-module (webid-oidc oidc-id-token) #:use-module (web uri) @@ -126,20 +128,16 @@ other) ((@ (gi) connect) add-account-button clicked (lambda _ - (define (as-host-name host) - (false-if-exception - (build-uri 'https #:host host))) - (match (entry:get-text identity-provider-entry) - ((or (? string? (= string->uri (? uri? uri))) - (? string? (= as-host-name (? uri? uri)))) - ((@ (ice-9 format) format) (current-error-port) (G_ "Stub: adding an account with identity provider ~s...\n") - (uri->string uri)) - (entry:set-text identity-provider-entry "")) - (else - ((@ (ice-9 format) format) (current-error-port) (G_ "Stub: please enter an URI or a host name...\n")))))) + ((@ (webid-oidc client gui accounts-widget-logic) add-account-button-clicked) + (entry:get-text identity-provider-entry) + (lambda () + (entry:set-text identity-provider-entry ""))))) ((@ (gi) connect) identity-provider-entry activate (lambda _ - (button:clicked add-account-button)))) + ((@ (webid-oidc client gui accounts-widget-logic) add-account-button-clicked) + (entry:get-text identity-provider-entry) + (lambda () + (entry:set-text identity-provider-entry "")))))) (set-accounts (settings:main-account) (settings:other-accounts)) (add-hook! settings:accounts-changed-hook set-accounts)))) |