[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 218aa82 25/76: Fixed prefix of customization group.
From: |
Ian Dunn |
Subject: |
[elpa] master 218aa82 25/76: Fixed prefix of customization group. |
Date: |
Thu, 23 Feb 2017 19:42:47 -0500 (EST) |
branch: master
commit 218aa82b8cfd1dec16a73fdfb5ee44c6309c4b96
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>
Fixed prefix of customization group.
(enwc-sec-types): Removed.
(enwc-get-profile-info-func): Removed.
(enwc-last-scan): Improved docstring.
(enwc--int-to-byte-list, enwc--byte-list-to-int, enwc--htonl): Added type
checking.
(enwc-update-width): Cleaned up code.
(enwc-maybe-pretty-entry): Removed.
(enwc--propertize-entry): Added to replace `enwc-maybe-pretty-entry'.
(enwc-display-wireless-networks): Implemented `enwc--propertize-entry'.
(enwc-display-networks, enwc-find-network): Cleaned up code.
(enwc-supplicant-template-alist): Fixed up default settings.
(enwc-sec-widget-data): Fixed to handle phase 1 and phase 2 templates.
---
lisp/enwc.el | 159 ++++++++++++++++++++++++++++++-----------------------------
1 file changed, 82 insertions(+), 77 deletions(-)
diff --git a/lisp/enwc.el b/lisp/enwc.el
index 9b0252e..ec54086 100644
--- a/lisp/enwc.el
+++ b/lisp/enwc.el
@@ -51,7 +51,7 @@
(defgroup enwc nil
"*The Emacs Network Client"
- :prefix "ewnc-"
+ :prefix "enwc-"
:group 'applications)
(defcustom enwc-wireless-device "wlan0"
@@ -110,11 +110,6 @@ connection.
:group 'enwc
:type 'string)
-(defcustom enwc-sec-types
- '("wpa" "wep" "wpa-leap" "wpa-peap" "leap" "peap")
- "The security types used for ENWC.
-Each of these have associations within the back-ends.")
-
;;; The function variables for the abstract layer.
(defvar enwc-scan-func nil
@@ -151,8 +146,6 @@ check whether or not a wired connection is active.")
(defvar enwc-get-profile-info-func nil)
-(defvar enwc-get-profile-sec-info-func nil)
-
(defvar enwc-save-nw-settings-func nil
"The function variable to be used in `enwc-save-nw-settings'.
This is redefined during setup to be the function to save
@@ -192,7 +185,16 @@ WIDTH is used during display to keep track of the width of
each one.
CONV is the conversion function used during display.")
(defvar enwc-last-scan nil
- "The most recent scan results.")
+ "The most recent scan results.
+
+This will be an association list of the form:
+
+((ID . ((strength . STRENGTH) (essid . ESSID) ...)) ...)
+
+Each ID is a backend-specific network ID.
+
+Each key in the children association lists corresponds to an entry in
+`enwc-details-alist'.")
(defvar enwc-access-points nil
"The most recent access point list.")
@@ -264,6 +266,7 @@ each word by SEPS, which defaults to \"-\"."
(defun enwc--int-to-byte-list (n)
"Convert 32-bit integer N into a byte list."
+ (cl-check-type n integer)
(let (ret)
(dotimes (x 4 ret)
(push (logand n 255) ret)
@@ -271,12 +274,14 @@ each word by SEPS, which defaults to \"-\"."
(defun enwc--byte-list-to-int (bl)
"Convert byte list BL into a 32-bit integer."
+ (cl-check-type n list)
(let ((ret 0))
(dolist (x bl ret)
(setq ret (logior (lsh ret 8) x)))))
(defun enwc--htonl (n)
"Convert 32-bit integer N from hardware to network byte order."
+ (cl-check-type n integer)
(enwc--byte-list-to-int (nreverse (enwc--int-to-byte-list n))))
;;;;;;;;;;;;;;;;;;;;
@@ -509,12 +514,11 @@ This modifies the width entry in `enwc-details-alist'
that corresponds to
DETAIL.
If VAL is not specified, then use the width of the display name for DETAIL."
- (unless val
- (setq val (1+ (length (cdr (assq 'display (cdr (assq detail
enwc-details-alist))))))))
- (setq val
- (max val (cdr (assq 'width (cdr (assq detail enwc-details-alist))))))
- (setcdr (assq 'width (cdr (assq detail enwc-details-alist)))
- val))
+ (let ((det (alist-get detail enwc-details-alist)))
+ (unless val
+ (setq val (1+ (length (alist-get 'display det)))))
+ (setq val (max val (alist-get 'width det)))
+ (setcdr (assq 'width det) val)))
(defun enwc-reset-widths ()
"Reset the column widths for display."
@@ -560,11 +564,19 @@ NETWORKS must be in the form returned from
(insert pr)
(insert "\n"))))
-(defmacro enwc-maybe-pretty-entry (entry)
- `(if (eq cur-id (cdr (assq 'id nw)))
- (propertize ,entry
- 'font-lock-face 'enwc-connected-face)
- ,entry))
+(defmacro enwc--propertize-entry (network-entry)
+ "Propertize network entry NETWORK-ENTRY."
+ `(mapcar
+ (lambda (det)
+ (let* ((conv (alist-get 'conv (cdr det)))
+ (ent (alist-get (car det) (cdr ,network-entry)))
+ (conv-ent (funcall conv ent)))
+ (if (equal cur-id (car nw))
+ (propertize conv-ent
+ 'font-lock-face
+ 'enwc-connected-face)
+ conv-ent)))
+ enwc-details-alist))
(defun enwc-display-wireless-networks (networks)
"Displays the networks in the list NETWORKS in the current buffer.
@@ -572,11 +584,9 @@ NETWORKS must be in the format returned by
`enwc-scan-internal-wireless'."
(unless (get-buffer "*ENWC*")
(enwc-setup-buffer t))
- (unless (listp networks)
- (signal 'wrong-type-argument `(listp ,networks)))
+ (cl-check-type networks list)
(with-current-buffer (get-buffer "*ENWC*")
- (let ((cur-id (enwc-get-current-nw-id))
- entries)
+ (let ((cur-id (enwc-get-current-nw-id)))
(setq tabulated-list-format
(apply 'vector
(mapcar
@@ -589,17 +599,7 @@ NETWORKS must be in the format returned by
(mapcar
(lambda (nw)
`(,(car nw)
- ,(apply 'vector
- (mapcar
- (lambda (det)
- (let ((conv (alist-get 'conv (cdr det)))
- (ent (alist-get (car det) (cdr nw))))
- (if (equal cur-id (car nw))
- (propertize (funcall conv ent)
- 'font-lock-face
- 'enwc-connected-face)
- (funcall conv ent))))
- enwc-details-alist))))
+ ,(apply 'vector (enwc--propertize-entry nw))))
networks)))
(tabulated-list-init-header)
@@ -611,8 +611,7 @@ This is an entry to the display functions,
and checks whether or not ENWC is using wired."
(unless (eq major-mode 'enwc-mode)
(enwc-setup-buffer))
- (unless (listp networks)
- (signal 'wrong-type-argument `(listp ,networks)))
+ (cl-check-type networks list)
(if enwc-using-wired
(enwc-display-wired-networks networks)
(enwc-display-wireless-networks networks)))
@@ -630,18 +629,15 @@ Otherwise, it actually returns it."
(enwc-scan-internal))
(let ((nets (or networks enwc-last-scan))
need-break cur-net)
- (unless nets
- (setq nets enwc-last-scan))
- (while (and nets (not need-break))
- (let (cur-essid)
- (setq cur-net (pop nets))
- (setq cur-essid (cdr (assq 'essid cur-net)))
- (when (string= cur-essid essid)
- (setq need-break t))))
- (if need-break
+ (while (and nets (not cur-net))
+ (setq cur-net (pop nets))
+ (unless (string-equal (alist-get 'essid (cdr-safe cur-ent))
+ essid)
+ (setq cur-net nil)))
+ (if cur-net
(if (called-interactively-p 'any)
- (message (number-to-string (cdr (assq 'id cur-net))))
- (cdr (assq 'id cur-net)))
+ (message "Network %d has essid %s" (number-to-string (car
cur-net)) essid)
+ (car cur-net))
(when (called-interactively-p 'any)
(message "Network not found.")))))
@@ -872,44 +868,44 @@ For more information, see the documentation for
wpa_supplicant.")
`((wep . ((key-mgmt . ("none"))
(wep-key0 . req)
(wep-tx-keyidx . "0")))
- (wpa2 . ((proto . ("wpa" "rsn"))
- (key-mgmt . "wpa-psk")
- (pairwise . ("ccmp" "tkip"))
- (group . ("ccmp" "tkip"))
+ (wpa2 . ((proto . ("WPA" "RSN"))
+ (key-mgmt . "WPA-PSK")
+ (pairwise . ("CCMP" "TKIP"))
+ (group . ("CCMP" "TKIP"))
(psk . req)))
- (leap . ((eap . "leap")
- (key-mgmt . ("ieee8021x"))
- (auth-alg . "leap")
+ (leap . ((eap . "LEAP")
+ (key-mgmt . ("IEEE8021X"))
+ (auth-alg . "LEAP")
(identity . req)
(password . req)))
- (eap-fast . ((proto . ("rsn" "wpa"))
- (pairwise . ("ccmp" "tkip"))
- (group . ("ccmp" "tkip"))
- (key-mgmt . ("wpa-eap"))
- (eap . "fast")
+ (eap-fast . ((proto . ("RSN" "WPA"))
+ (pairwise . ("CCMP" "TKIP"))
+ (group . ("CCMP" "TKIP"))
+ (key-mgmt . ("WPA-EAP"))
+ (eap . "FAST")
(identity . req)
(password . req)
(phase1 . ((fast-provisioning . "1")))
(pac-file . opt)))
- (eap-tls . ((key-mgmt . ("wpa-eap"))
- (pairwise . ("tkip"))
- (group . ("tkip"))
- (eap . "tls")
+ (eap-tls . ((key-mgmt . ("WPA-EAP"))
+ (pairwise . ("TKIP"))
+ (group . ("TKIP"))
+ (eap . "TLS")
(identity . req)
(ca-cert . opt)
(client-cert . opt)
(private-key . req)
(private-key-passwd . req)))
- (peap . ((proto . ("rsn"))
- (key-mgmt . ("wpa-eap"))
- (pairwise . ("ccmp"))
- (eap . "peap")
+ (peap . ((proto . ("RSN"))
+ (key-mgmt . ("WPA-EAP"))
+ (pairwise . ("CCMP"))
+ (eap . "PEAP")
(identity . req)
(password . req)))
- (peap-tkip . ((proto . ("wpa"))
- (key-mgmt . ("wpa-eap"))
- (pairwise . ("tkip"))
- (group . ("tkip"))
+ (peap-tkip . ((proto . ("WPA"))
+ (key-mgmt . ("WPA-EAP"))
+ (pairwise . ("TKIP"))
+ (group . ("TKIP"))
(eap . "PEAP")
(identity . req)
(password . req)
@@ -976,7 +972,7 @@ If specified, SEC-INFO is passed to the templates to
initialize them."
(widget-create (enwc-create-template-menu sec-info)))
(defun enwc-sec-widget-data (widget)
- "Get the data from a securirty widget WIDGET."
+ "Get the data from a security widget WIDGET."
(let* ((type (widget-get (widget-get widget :choice) :tag))
(values (widget-value widget))
(template (assq (intern type) enwc-supplicant-template-alist)))
@@ -985,10 +981,19 @@ If specified, SEC-INFO is passed to the templates to
initialize them."
(setq template (cdr template))
(cons
`(sec-type ,(intern type))
- (mapcar
- (lambda (val)
- (cons (car val) (pop values)))
- template))))
+ (cl-mapcar
+ (lambda (val v)
+ (let ((vl v))
+ (when (or (eq (car val) 'phase1)
+ (eq (car val) 'phase2))
+ (let ((subs
+ (mapcar
+ (lambda (arg)
+ (enwc--str-to-sym (downcase (widget-get arg :tag))))
+ (widget-get (alist-get (car val) enwc-supplicant-alist)
:args))))
+ (setq vl (cl-mapcar 'cons subs v))))
+ (cons (car val) vl)))
+ template values))))
(defvar enwc-network-edit-widget nil
"The network information widget used in the edit buffer.")
- [elpa] master a3c59cc 74/76: Updated version to 2.0beta1, (continued)
- [elpa] master a3c59cc 74/76: Updated version to 2.0beta1, Ian Dunn, 2017/02/23
- [elpa] master 2e271c6 72/76: Moved lisp files into top-level directory., Ian Dunn, 2017/02/23
- [elpa] master b673e3a 63/76: Added default setup and removed experimental WPA supplicant backend., Ian Dunn, 2017/02/23
- [elpa] master 2c298fc 70/76: Updated copyright and keywords on all files., Ian Dunn, 2017/02/23
- [elpa] master 8e44368 68/76: Moved enwc-setup to enwc.el, and added it to enwc., Ian Dunn, 2017/02/23
- [elpa] master 4462fba 56/76: Lots of changes to enwc.el., Ian Dunn, 2017/02/23
- [elpa] master 62fe017 71/76: Removed some files from docs., Ian Dunn, 2017/02/23
- [elpa] master 942d83d 15/76: enwc.el, enwc-setup.el: Consolidated and concretely defined front-end interface., Ian Dunn, 2017/02/23
- [elpa] master 6417d2c 49/76: Correctly merged old branch., Ian Dunn, 2017/02/23
- [elpa] master eb6b085 11/76: Fixed up copyright information., Ian Dunn, 2017/02/23
- [elpa] master 218aa82 25/76: Fixed prefix of customization group.,
Ian Dunn <=
- [elpa] master c9a94c8 44/76: Added tag 2.0 for changeset 3e2cab525cbc, Ian Dunn, 2017/02/23
- [elpa] master c4ac6fc 60/76: Fixed bug in 'enwc-load-default-backend', Ian Dunn, 2017/02/23
- [elpa] master b8697fd 62/76: Added force parameter to `enwc-load-backend'., Ian Dunn, 2017/02/23
- [elpa] master 2ebc214 01/76: Changed timeout on enwc-wicd-get-wireless-network-property., Ian Dunn, 2017/02/23
- [elpa] master 18e4a3a 06/76: Updated copyright notices., Ian Dunn, 2017/02/23
- [elpa] master 0d92006 09/76: (enwc-update-mode-line): Forces the mode line to update when ENWC updates its current signal., Ian Dunn, 2017/02/23
- [elpa] master 742b67a 19/76: Removed several network manager functions., Ian Dunn, 2017/02/23
- [elpa] master 773cef6 24/76: (enwc-backend-symbol-list): New variable., Ian Dunn, 2017/02/23
- [elpa] master b5686da 17/76: (enwc-wicd-get-sec-types): Removed., Ian Dunn, 2017/02/23
- [elpa] master 7914c48 10/76: (enwc-format-mode-line-string, enwc-update-mode-line): Added the option to customize the information displayed in the mode line., Ian Dunn, 2017/02/23