[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3662795 23/76: (enwc-cm-scan, enwc-cm-dict-assoc, enwc-cm-
From: |
Ian Dunn |
Subject: |
[elpa] master 3662795 23/76: (enwc-cm-scan, enwc-cm-dict-assoc, enwc-cm-get-network-props): Cleaned up code. |
Date: |
Thu, 23 Feb 2017 19:42:47 -0500 (EST) |
branch: master
commit 3662795d9c0e1ae511c156d826eb666a719073f5
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>
(enwc-cm-scan, enwc-cm-dict-assoc, enwc-cm-get-network-props): Cleaned up
code.
(enwc-cm-get-profile-props, enwc-cm-save-profile): Updated to fit new
front-end.
---
lisp/enwc-cm.el | 66 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 32 insertions(+), 34 deletions(-)
diff --git a/lisp/enwc-cm.el b/lisp/enwc-cm.el
index 5ff6eef..2b54e44 100644
--- a/lisp/enwc-cm.el
+++ b/lisp/enwc-cm.el
@@ -35,7 +35,7 @@
(defgroup enwc-cm nil
"*ConnMan variables for ENWC"
- :prefix "ewnc-cm-"
+ :prefix "enwc-cm-"
:group 'enwc)
(defcustom enwc-cm-dbus-service "net.connman"
@@ -43,8 +43,6 @@
:group 'enwc-cm
:type 'string)
-;; DEMAND TO SEE LIFE'S MANAGER!!
-
(defcustom enwc-cm-dbus-manager-interface "net.connman.Manager"
"ConnMan D-Bus Manager interface."
:group 'enwc-cm
@@ -118,7 +116,8 @@
;; scan
(defun enwc-cm-scan (wired)
- (let ((path (if wired (enwc-cm-get-wired-tech-path)
+ (let ((path (if wired
+ (enwc-cm-get-wired-tech-path)
(enwc-cm-get-wifi-tech-path))))
(dbus-call-method-asynchronously :system
path
@@ -135,15 +134,15 @@
;; "Scan"))
;; get-network-props
+;; Might combine this with enwc-nm-get-dbus-dict-entry
(defun enwc-cm-dict-assoc (dict prop)
(let ((path-list (split-string prop "/"))
(cur-list dict))
(while (and path-list cur-list)
(let ((cur-path (pop path-list)))
(setq cur-list
- (if (assoc cur-path cur-list)
- (caadr (assoc cur-path cur-list))
- nil))))
+ (when (assoc cur-path cur-list)
+ (caadr (assoc cur-path cur-list))))))
(if (and cur-list (consp cur-list)) (car cur-list) cur-list)))
(defun enwc-cm-get-nw-prop (id prop)
@@ -152,10 +151,10 @@
(defun enwc-cm-get-network-props (id wired)
(let ((network (enwc-cm-get-network id))
- props)
+ props)
;; network should be a pair, (path . props)
- (if (not network)
- (error "Invalid Network Id %d" id))
+ (unless network
+ (error "Invalid Network Id %d" id))
(setq props (cadr network))
(mapcar
(lambda (det)
@@ -171,16 +170,16 @@
props
ipv4-settings
dns-settings)
- (if (not network)
- (error "Invalid Network Id %d" id))
+ (unless network
+ (error "Invalid Network Id %d" id))
(setq props (cadr network))
- (setq ipv4-settings (enwc-cm-dict-assoc "IPv4.Configuration" props)
- dns-settings (enwc-cm-dict-assoc "Domains.Configuration" props))
- `(("addr" . ,(cadr (assoc "Address" ipv4-settings)))
- ("netmask" . ,(cadr (assoc "Netmask" ipv4-settings)))
- ("gateway" . ,(cadr (assoc "Gateway" ipv4-settings)))
- ("dns1" . ,(nth 0 dns-settings))
- ("dns2" . ,(nth 1 dns-settings)))))
+ (setq ipv4-settings (enwc-cm-dict-assoc "IPv4/Configuration" props)
+ dns-settings (enwc-cm-dict-assoc "Domains/Configuration" props))
+ `((addr . ,(cadr (assoc "Address" ipv4-settings)))
+ (netmask . ,(cadr (assoc "Netmask" ipv4-settings)))
+ (gateway . ,(cadr (assoc "Gateway" ipv4-settings)))
+ (dns1 . ,(nth 0 dns-settings))
+ (dns2 . ,(nth 1 dns-settings)))))
;; get-current-nw-id
(defun enwc-cm-is-disconnected-p (service)
@@ -208,10 +207,10 @@
(enwc-cm--find-connected-service services 0)))
;; save-profile
-(defun enwc-cm-set-nw-prop (wired id prop val)
+(defun enwc-cm-set-nw-prop (nw prop val &optional wired)
(dbus-call-method :system
enwc-cm-dbus-service
- (car (enwc-cm-get-network id))
+ (car nw)
enwc-cm-dbus-service-interface
"SetProperty"
:string prop
@@ -222,25 +221,25 @@
props
ipv4-settings
dns-settings)
- (if (not network)
- (error "Invalid Network Id %d" id))
+ (unless network
+ (error "Invalid Network Id %d" id))
(setq props (cadr network))
(setq ipv4-settings
`((("Method" ("manual"))
- ("Address" (,(cdr (assoc "addr" settings))))
- ("Netmask" (,(cdr (assoc "netmask" settings))))
- ("Gateway" (,(cdr (assoc "gateway" settings)))))))
+ ("Address" (,(alist-get 'addr settings "")))
+ ("Netmask" (,(alist-get 'netmask settings "")))
+ ("Gateway" (,(alist-get 'gateway settings ""))))))
(setq dns-settings
- `((,(cdr (assoc "dns1" settings)))
- (,(cdr (assoc "dns2" settings)))))
- (enwc-cm-set-nw-prop wired prof "IPv4.Configuration" ipv4-settings)
- (enwc-cm-set-nw-prop wired prof "Domains.Configuration" dns-settings)))
+ `((,(alist-get 'dns1 settings ""))
+ (,(alist-get 'dns2 settings ""))))
+ (enwc-cm-set-nw-prop prof "IPv4.Configuration" ipv4-settings wired)
+ (enwc-cm-set-nw-prop prof "Domains.Configuration" dns-settings wired)))
;; check-connecting-p
(defun enwc-cm--find-connecting-service (services)
- (if services
- (or (enwc-cm-is-connecting-p (car services))
- (enwc-cm--find-connecting-service (cdr services)))))
+ (when services
+ (or (enwc-cm-is-connecting-p (car services))
+ (enwc-cm--find-connecting-service (cdr services)))))
(defun enwc-cm-check-connecting-p ()
(let ((services (enwc-cm-get-services)))
@@ -308,7 +307,6 @@ METHOD is assumed to be the camel-case D-Bus method."
;; Run during setup.
(defun enwc-cm-setup ()
-
;; Setup the agent.
(dbus-register-service :session enwc-cm-dbus-agent-service)
- [elpa] master d091e21 16/76: (enwc-get-profile-sec-info): Removed., (continued)
- [elpa] master d091e21 16/76: (enwc-get-profile-sec-info): Removed., Ian Dunn, 2017/02/23
- [elpa] master 20afe01 22/76: (enwc-wicd-save-nw-settings): Updated to work with new interface., Ian Dunn, 2017/02/23
- [elpa] master ca50c21 21/76: (enwc--int-to-byte-list, enwc--byte-list-to-int, enwc--htonl): Added to assist with D-Bus conversion., Ian Dunn, 2017/02/23
- [elpa] master e5c36d3 26/76: (enwc-nm-details-list): Removed., Ian Dunn, 2017/02/23
- [elpa] master 421b0d9 35/76: (enwc-wicd-setup): Renamed to `enwc-wicd-load'., Ian Dunn, 2017/02/23
- [elpa] master 7a3c057 03/76: Added support for toggling the mode line display., Ian Dunn, 2017/02/23
- [elpa] master b5e612f 04/76: * enwc.el (enwc-display-networks, enwc-maybe-pretty-entry): Added support for colorizing the current network., Ian Dunn, 2017/02/23
- [elpa] master 89f9418 08/76: enwc.el (enwc-display-wireless-networks): Removed old comment., Ian Dunn, 2017/02/23
- [elpa] master d6aa3ee 02/76: Fixed up enwc-wicd network properties., Ian Dunn, 2017/02/23
- [elpa] master f77237c 12/76: (enwc-format-mode-line-string): Checks to confirm that scan data exists., Ian Dunn, 2017/02/23
- [elpa] master 3662795 23/76: (enwc-cm-scan, enwc-cm-dict-assoc, enwc-cm-get-network-props): Cleaned up code.,
Ian Dunn <=
- [elpa] master 01075fa 28/76: Fixed up docstrings., Ian Dunn, 2017/02/23
- [elpa] master 11443eb 34/76: enwc-setup.el: Fixed up header and footer., Ian Dunn, 2017/02/23
- [elpa] master 561f9e1 27/76: (enwc-wicd-get-profile-info, enwc-wicd-get-profile-sec-info): Improved docstring., Ian Dunn, 2017/02/23
- [elpa] master cb32122 13/76: (enwc-nm-prop-to-prop, enwc-wicd-prop-to-prop): Convert the properties used internally to the property names used externally., Ian Dunn, 2017/02/23
- [elpa] master d6bee52 32/76: (enwc-wicd.el): Fixed opening header., Ian Dunn, 2017/02/23
- [elpa] master 5088938 40/76: Removed erroneous comment., Ian Dunn, 2017/02/23
- [elpa] master 17f27c6 18/76: (enwc-nm-prop-to-prop, enwc-nm-get-sec-types): Removed., Ian Dunn, 2017/02/23
- [elpa] master ee90297 31/76: (enwc-nm.el): Fixed several docstrings, and file header., Ian Dunn, 2017/02/23
- [elpa] master 4e0d5a2 41/76: Cosmetic changes., Ian Dunn, 2017/02/23
- [elpa] master 8f21449 45/76: Removed tag 2.0, Ian Dunn, 2017/02/23