[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e5c36d3 26/76: (enwc-nm-details-list): Removed.
From: |
Ian Dunn |
Subject: |
[elpa] master e5c36d3 26/76: (enwc-nm-details-list): Removed. |
Date: |
Thu, 23 Feb 2017 19:42:47 -0500 (EST) |
branch: master
commit e5c36d3081079ccc8a54be5a2b445ae490aaeebd
Author: Ian D <address@hidden>
Commit: Ian D <address@hidden>
(enwc-nm-details-list): Removed.
(enwc-nm-get-settings): Implemented `enwc-nm-dbus-call-method'.
(enwc-nm-get-wired-profiles): Fixed to find correct profiles.
(enwc-nm-string-idx): Removed.
(enwc-nm-prop-changed): Improved docstring.
(enwc-nm-gen-uuid): Cleaned up code.
(enwc-nm-convert-addr, enwc-nm-addr-back): Added type checking.
(enwc-nm-netmask-to-prefix, enwc-nm-prefix-to-netmask): Implemented
`enwc--htonl'.
(enwc-nm-get-dbus-dict-entry, enwc-nm-set-dbus-dict-entry): Added type
checking.
---
lisp/enwc-nm.el | 81 +++++++++++++++++++++------------------------------------
1 file changed, 29 insertions(+), 52 deletions(-)
diff --git a/lisp/enwc-nm.el b/lisp/enwc-nm.el
index feff840..b349a80 100644
--- a/lisp/enwc-nm.el
+++ b/lisp/enwc-nm.el
@@ -90,10 +90,6 @@
:group 'enwc-nm
:type 'string)
-(defvar enwc-nm-details-list
- '("Ssid" "HwAddress" "Strength" "Flags" "Mode" "Frequency")
- "The list of the desired details to be obtained from each network.")
-
(defvar enwc-nm-wired-dev nil
"The wired device object path.")
@@ -150,12 +146,8 @@
(defun enwc-nm-get-settings (conn)
"Gets the connection settings.
CONN is an object path to the connection."
- (dbus-call-method :system
- enwc-nm-dbus-service
- conn
- enwc-nm-dbus-connections-interface
- "GetSettings"
- :timeout 25000))
+ (enwc-nm-dbus-call-method "GetSettings" conn
+ enwc-nm-dbus-connections-interface))
(defun enwc-nm-list-connections ()
"List the connections."
@@ -184,8 +176,9 @@ This returns a list of D-Bus paths to the access points."
(mapcar
(lambda (x)
(let ((props (enwc-nm-get-settings x)))
- (when (string= (caar props) "connection")
- (car (cadr (car (cadr (car props))))))))
+ (when (string= (enwc-nm-get-dbus-dict-entry "connection/type" props)
+ "802-3-ethernet")
+ (enwc-nm-get-dbus-dict-entry "connection/id" props))))
profs-list)))
;;;;;;;;;;;;;
@@ -296,20 +289,6 @@ If both are 0, then it returns WEP, otherwise WPA."
;; Get Current network id
;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defun enwc-nm-string-idx (obj ls)
- "Determine the index of string OBJ in LIST."
- (cl-check-type obj string)
- (cl-check-type ls list)
- (let ((tmp-list ls)
- (cur-pos -1)
- cur-obj)
- (while (and (not cur-obj) tmp-list)
- (setq cur-obj (pop tmp-list))
- (setq cur-pos (1+ cur-pos))
- (unless (string= obj cur-obj)
- (setq cur-obj nil)))
- cur-pos))
-
(defun enwc-nm-wireless-prop-changed (props)
"Called when network properties are changed.
PROPS is a list of updated properties."
@@ -327,7 +306,9 @@ This simply checks for the active access point."
(defun enwc-nm-prop-changed (state)
"Called when NetworkManager's state is changed.
-STATE is the new state."
+STATE is the new state
+
+If STATE is 40, then NetworkManager is connecting to a new AP."
(setq enwc-nm-connecting-p (eq state 40)))
;;;;;;;;;;;;;;;;;;;;;;
@@ -352,12 +333,11 @@ STATE is the new state."
(defun enwc-nm-gen-uuid ()
"Generate a UUID."
(random t)
- (let ((hex-nums
+ (apply 'format
+ "%04x%04x-%04x-%04x-%04x-%04x%04x%04x"
(mapcar (lambda (x)
(random 65535))
- (number-sequence 0 7)))
- fin-str)
- (setq fin-str (apply 'format "%04x%04x-%04x-%04x-%04x-%04x%04x%04x"
hex-nums))))
+ (number-sequence 0 7))))
(defmacro enwc-nm--hex-substring (str st ed)
"Get a standard integer from hex string STR starting at ST and ending st ED"
@@ -365,7 +345,7 @@ STATE is the new state."
(defun enwc-nm-convert-addr (addr)
"Convert an address ADDR from an integer in network byte order to a string."
- (if addr
+ (if (and addr (integerp addr))
(let* ((hex-addr (format "%08x" addr))
(subs (mapcar
(lambda (n)
@@ -376,6 +356,7 @@ STATE is the new state."
(defun enwc-nm-addr-back (addr)
"Convert an IP address ADDR in dots notation to an integer."
+ (cl-check-type addr string)
(let* ((bytes (split-string addr "\\."))
(byte-string (mapcar
(lambda (n) (lsh (string-to-number (nth n bytes))
@@ -388,36 +369,30 @@ STATE is the new state."
(defun enwc-nm-netmask-to-prefix (netmask)
"Converts a netmask to a CIDR prefix.
NETMASK is an ip address in network byte order."
- (if netmask
- (let* ((mask netmask)
- (cur-pos 3)
- (cur-mark (logand (lsh mask (* -8 cur-pos)) 255))
- (pf 0))
- (while (and (eq cur-mark 255) (>= cur-pos 0))
- (setq pf (+ pf 8))
- (setq cur-pos (1- cur-pos))
- (setq cur-mark (logand (lsh mask (* -8 cur-pos)) 255)))
-
- (if (>= cur-pos 0)
- (let ((v (logand (lsh mask (* -8 cur-pos)) 255)))
- (while (not (eq v 0))
- (setq pf (1+ pf))
- (setq v (lsh v 1)))))
- pf)
+ (if (and netmask (integerp netmask))
+ (progn
+ (setq netmask (enwc--htonl netmask))
+ (while (cl-evenp netmask)
+ (setq netmask (lsh netmask -1)))
+ (floor (log (1+ netmask) 2)))
0))
(defun enwc-nm-prefix-to-netmask (prefix)
"Converts a CIDR prefix to a netmask.
PREFIX is an integer <= 32."
- (cl-check-type prefix integer)
- (setq prefix (min prefix 32))
- (enwc--htonl (lsh (1- (expt 2 prefix)) (- 32 prefix))))
+ (if (and prefix (integerp prefix))
+ (progn
+ (setq prefix (min prefix 32))
+ (enwc--htonl (lsh (1- (expt 2 prefix)) (- 32 prefix))))
+ 0))
(defun enwc-nm-get-dbus-dict-entry (entry dict)
"Get an entry ENTRY from D-Bus dictionary DICT.
ENTRY is in the form LVL1/LVL2/.../LVLN, where each LVLi is a string
representing another layer in the dictionary."
+ (cl-check-type entry string)
+ (cl-check-type dict list)
(let ((ent-strs (split-string entry "/"))
(cur-ent dict)
cur-str)
@@ -429,7 +404,9 @@ representing another layer in the dictionary."
cur-ent))
(defun enwc-nm-set-dbus-dict-entry (entry dict value)
- "Set an entry."
+ "Set entry ENTRY in D-Bus dictionary DICT to VALUE."
+ (cl-check-type entry string)
+ (cl-check-type dict list)
(let ((ent-strs (split-string entry "/"))
(cur-ent dict)
cur-str)
- [elpa] master updated (b30addd -> da7e3c6), Ian Dunn, 2017/02/23
- [elpa] master e8b1d77 05/76: * enwc.el (enwc-display-mode-line-timer): Added a variable for the mode line timer., Ian Dunn, 2017/02/23
- [elpa] master 4a3acfc 07/76: * enwc.el (enwc-enable-display-mode-line, enwc-disable-display-mode-line, enwc-toggle-display-mode-line): Broke enable/disable mode line functionality into different functions., Ian Dunn, 2017/02/23
- [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 <=
- [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, 2017/02/23
- [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