aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix 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 General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu installer newt ethernet)
  #:use-module (gnu installer connman)
  #:use-module (gnu installer steps)
  #:use-module (gnu installer newt utils)
  #:use-module (gnu installer newt page)
  #:use-module (guix i18n)
  #:use-module (ice-9 format)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-35)
  #:export (run-ethernet-page))

(define (ethernet-services)
  "Return all the connman services of ethernet type."
  (let ((services (connman-services)))
    (filter (lambda (service)
              (and (string=? (service-type service) "ethernet")
                   (not (string-null? (service-name service)))))
            services)))

(define (ethernet-service->text service)
  "Return a string describing the given ethernet SERVICE."
  (let* ((name (service-name service))
         (path (service-path service))
         (full-name (string-append name "-" path))
         (state (service-state service))
         (connected? (or (string=? state "online")
                         (string=? state "ready"))))
    (format #f "~c ~a~%"
            (if connected? #\* #\ )
            full-name)))

(define (connect-ethernet-service service)
  "Connect to the given ethernet SERVICE. Display a connecting page while the
connection is pending."
  (let* ((service-name (service-name service))
         (form (draw-connecting-page service-name)))
    (connman-connect service)
    (destroy-form-and-pop form)
    service))

(define (run-ethernet-page)
  (match (ethernet-services)
    (()
     (run-error-page
      (G_ "No ethernet service available, please try again.")
      (G_ "No service"))
     (abort-to-prompt 'installer-step 'abort))
    ((service)
     ;; Only one service is available so return it directly.
     service)
    ((services ...)
     (run-listbox-selection-page
      #:info-text (G_ "Please select an ethernet network.")
      #:title (G_ "Ethernet connection")
      #:listbox-items services
      #:listbox-item->text ethernet-service->text
      #:listbox-height (min (+ (length services) 2) 5)
      #:button-text (G_ "Exit")
      #:button-callback-procedure
      (lambda _
        (abort-to-prompt 'installer-step 'abort))
      #:listbox-callback-procedure connect-ethernet-service))))
07d9fc7b4e444107f916d'>builders.scm2902logplainabout -rw-r--r--cache.scm2999logplainabout -rw-r--r--challenge.scm10719logplainabout -rw-r--r--channels.scm26215logplainabout -rw-r--r--civodul.key88561logplainabout -rw-r--r--combinators.scm3045logplainabout -rw-r--r--containers.scm10924logplainabout -rw-r--r--cpan.scm3659logplainabout -rw-r--r--cpio.scm3154logplainabout -rw-r--r--cran.scm4994logplainabout -rw-r--r--crate.scm15551logplainabout -rw-r--r--cve-sample.json46446logplainabout -rw-r--r--cve.scm3672logplainabout -rw-r--r--debug-link.scm6709logplainabout -rw-r--r--derivations.scm62919logplainabout -rw-r--r--discovery.scm2540logplainabout -rw-r--r--dsa.key1432logplainabout -rw-r--r--ed25519.key417logplainabout -rw-r--r--ed25519.sec467logplainabout -rw-r--r--ed25519bis.key409logplainabout -rw-r--r--ed25519bis.sec459logplainabout -rw-r--r--elpa.scm2850logplainabout -rw-r--r--file-systems.scm4717logplainabout -rw-r--r--gem.scm6455logplainabout -rw-r--r--gexp.scm69279logplainabout -rw-r--r--git-authenticate.scm15597logplainabout -rw-r--r--git.scm6826logplainabout -rw-r--r--glob.scm2331logplainabout -rw-r--r--gnu-maintenance.scm1688logplainabout -rw-r--r--grafts.scm22364logplainabout -rw-r--r--graph.scm22214logplainabout -rw-r--r--gremlin.scm3478logplainabout -rw-r--r--guix-archive.sh2855logplainabout -rw-r--r--guix-authenticate.sh2963logplainabout -rw-r--r--guix-build-branch.sh2249logplainabout -rw-r--r--guix-build.sh10900logplainabout -rw-r--r--guix-daemon.sh8336logplainabout -rw-r--r--guix-describe.sh1405logplainabout -rw-r--r--guix-download.sh1593logplainabout -rw-r--r--guix-environment-container.sh5740logplainabout -rw-r--r--guix-environment.sh8861logplainabout -rw-r--r--guix-gc.sh2819logplainabout -rw-r--r--guix-git-authenticate.sh2176logplainabout -rw-r--r--guix-graph.sh3001logplainabout -rw-r--r--guix-hash.sh2588logplainabout -rw-r--r--guix-lint.sh2579logplainabout -rw-r--r--guix-pack-localstatedir.sh2565logplainabout -rw-r--r--guix-pack-relocatable.sh4140logplainabout -rw-r--r--guix-pack.sh5089logplainabout -rw-r--r--guix-package-aliases.sh2050logplainabout -rw-r--r--guix-package-net.sh7696logplainabout -rw-r--r--guix-package.sh15400logplainabout -rw-r--r--guix-repl.sh2202logplainabout -rw-r--r--guix-system.sh9642logplainabout -rw-r--r--hackage.scm10660logplainabout -rw-r--r--import-utils.scm6173logplainabout -rw-r--r--inferior.scm10870logplainabout -rw-r--r--lint.scm40775logplainabout -rw-r--r--lzlib.scm4749logplainabout -rw-r--r--modules.scm2582logplainabout -rw-r--r--monads.scm9099logplainabout -rw-r--r--nar.scm21502logplainabout -rw-r--r--networking.scm4056logplainabout -rw-r--r--opam.scm7629logplainabout -rw-r--r--openpgp.scm9822logplainabout -rw-r--r--pack.scm10180logplainabout -rw-r--r--packages.scm68609logplainabout -rw-r--r--pki.scm5220logplainabout -rw-r--r--print.scm2705logplainabout -rw-r--r--processes.scm4691logplainabout -rw-r--r--profiles.scm29127logplainabout -rw-r--r--publish.scm25948logplainabout -rw-r--r--pypi.scm13712logplainabout -rw-r--r--records.scm15123logplainabout -rw-r--r--rsa.key953logplainabout -rw-r--r--scripts-build.scm12015logplainabout -rw-r--r--scripts.scm2034logplainabout -rw-r--r--search-paths.scm1768logplainabout -rw-r--r--services.scm11536logplainabout d---------services37logplain -rw-r--r--sets.scm1507logplainabout -rw-r--r--signing-key.pub302logplainabout -rw-r--r--signing-key.sec983logplainabout -rw-r--r--size.scm4576logplainabout -rw-r--r--snix.scm2504logplainabout -rw-r--r--status.scm12235logplainabout -rw-r--r--store-database.scm3718logplainabout -rw-r--r--store-deduplication.scm4533logplainabout -rw-r--r--store-roots.scm1899logplainabout -rw-r--r--store.scm56516logplainabout -rw-r--r--substitute.scm21770logplainabout -rw-r--r--swh.scm3789logplainabout -rw-r--r--syscalls.scm20993logplainabout -rw-r--r--system.scm5143logplainabout -rw-r--r--test.drv5922logplainabout -rw-r--r--texlive.scm4493logplainabout -rw-r--r--ui.scm8936logplainabout -rw-r--r--union.scm9714logplainabout -rw-r--r--upstream.scm1963logplainabout -rw-r--r--utils.scm9783logplainabout -rw-r--r--uuid.scm2755logplainabout -rw-r--r--workers.scm2172logplainabout -rw-r--r--zlib.scm2237logplainabout