1 ;;; enwc-nm.el - The NetworkManager backend to ENWC
3 ;; Copyright (C) 2012,2013 Free Software Foundation, Inc.
6 ;; Keywords: enwc, network, wicd, manager, nm
8 ;; This file is part of ENWC
10 ;; ENWC is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; ENWC is distributed in the hope that it will be useful, but WITHOUT
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 ;; License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with ENWC; see the file COPYING. If not, write to the Free
22 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 ;; This requires NetworkManager >= 0.9.6
34 "*NetworkManager variables for ENWC"
38 (defcustom enwc-nm-dbus-service "org.freedesktop.NetworkManager"
39 "NetworkManager D-Bus service."
43 (defcustom enwc-nm-dbus-path "/org/freedesktop/NetworkManager"
44 "The default D-Bus path for NetworkManager."
48 (defcustom enwc-nm-dbus-settings-path "/org/freedesktop/NetworkManager/Settings"
49 "The settings D-Bus path for NetworkManager."
53 (defcustom enwc-nm-dbus-interface "org.freedesktop.NetworkManager"
54 "The default D-Bus interface for NetworkManager."
58 (defcustom enwc-nm-dbus-wireless-interface "org.freedesktop.NetworkManager.Device.Wireless"
59 "The wireless D-Bus interface for NetworkManager."
63 (defcustom enwc-nm-dbus-wired-interface "org.freedesktop.NetworkManager.Device.Wired"
64 "The wired D-Bus interface for NetworkManager."
68 (defcustom enwc-nm-dbus-device-interface "org.freedesktop.NetworkManager.Device"
69 "The device D-Bus interface for NetworkManager."
73 (defcustom enwc-nm-dbus-accesspoint-interface "org.freedesktop.NetworkManager.AccessPoint"
74 "The access point D-Bus interface for NetworkManager."
78 (defcustom enwc-nm-dbus-settings-interface "org.freedesktop.NetworkManager.Settings"
79 "The settings D-Bus interface for NetworkManager."
83 (defcustom enwc-nm-dbus-connections-interface "org.freedesktop.NetworkManager.Settings.Connection"
84 "The connections D-Bus interface for NetworkManager."
88 (defcustom enwc-nm-dbus-active-interface "org.freedesktop.NetworkManager.Connection.Active"
89 "The active connection D-Bus interface for NetworkManager."
93 (defvar enwc-nm-details-list
94 '("Ssid" "HwAddress" "Strength" "Flags" "Mode" "Frequency")
95 "The list of the desired details to be obtained from each network.")
97 (defvar enwc-nm-sec-types
98 '(("eap-leap" . (("Name" . "eap-leap")
99 ("reqs" . ((("identity" . "Username")
100 ("password" . "Password"))))))
101 ("eap-peap" . (("Name" . "eap-peap")
102 ("reqs" . ((("anonymous-identity" . "Anonymous Identity")
103 ("ca-cert" . "CA Certificate")
104 ("phase2-auth" . "Inner Authentication")
105 ("phase1-peapver" . "PEAP Version")
106 ("identity" . "Username")
107 ("password" . "Password"))))))
108 ("eap-tls" . (("Name" . "eap-tls")
109 ("reqs" . ((("identity" . "Identity")
110 ("client-cert" . "User Certificate")
111 ("ca-cert" . "CA Certificate")
112 ("private-key" . "Private Key")
113 ("private-key-password" . "Private Key Password"))))))
114 ("eap-ttls" . (("Name" . "eap-ttls")
115 ("reqs" . ((("anonymous-identity" . "Anonymous Identity")
116 ("ca-cert" . "CA Certificate")
117 ("phase2-auth" . "Inner Authentication")
118 ("identity" . "Username")
119 ("password" . "Password"))))))
120 ("wpa-psk" . (("Name" . "wpa2")
121 ("reqs" . ((("psk" . "PSK"))))))
122 ("wep" . (("Name" . "wep")
123 ("reqs" . ((("wep-key0" . "WEP Key")
124 ("wep-key-type" . "WEP Key Type"))))))
125 ("leap" . (("Name" . "leap")
126 ("reqs" . ((("leap-username" . "Username")
127 ("leap-password" . "Password"))))))
129 "The security types for NetworkManager.
130 This is still in the process of being worked on."
133 (defvar enwc-nm-wired-dev nil
134 "The wired device object path.")
136 (defvar enwc-nm-wireless-dev nil
137 "The wireless device object path.")
139 (defvar enwc-nm-active-ap nil
140 "The active access point object path.")
142 (defvar enwc-nm-connecting-p nil
143 "Whether or not NetworkManager is connecting.")
145 (defvar enwc-nm-wired-p nil
146 "Whether or not NetworkManager is wired.")
148 (defvar enwc-nm-edit-info nil
149 "The information for the network connection being edited.")
151 (defun enwc-nm-get-settings (conn)
152 "Gets the connection settings.
153 CONN is an object path to the connection."
154 (dbus-call-method :system
157 enwc-nm-dbus-connections-interface
162 (defun enwc-nm-list-connections ()
163 "List the connections."
164 (dbus-call-method :system
166 enwc-nm-dbus-settings-path
167 enwc-nm-dbus-settings-interface
172 (defun enwc-nm-get-device-by-name (name)
173 (dbus-call-method :system
176 enwc-nm-dbus-interface
181 ;; Settings, Connections
182 (defun enwc-nm-get-uuid-by-ssid (ssid)
183 "Gets the uuid of the network with ssid SSID."
184 (let ((conns (enwc-nm-list-connections))
185 cur-conn cur-ssid uuid)
186 (while (and conns (not uuid))
187 (setq cur-conn (pop conns))
188 (let ((settings (enwc-nm-get-settings cur-conn)))
189 (if (not (assoc "802-11-wireless" settings))
192 (dbus-byte-array-to-string (car (cadr (assoc "ssid"
193 (cadr (assoc "802-11-wireless"
195 (if (string= cur-ssid ssid)
197 (car (cadr (assoc "uuid"
198 (cadr (assoc "connection"
202 (defun enwc-nm-get-uuid-by-id (id)
203 "Gets a network connection's uuid by the network's id.
204 ID is a string that NetworkManager uses to identify this network."
205 (let ((conns (enwc-nm-list-connections))
206 cur-conn cur-id uuid)
207 (while (and conns (not uuid))
208 (setq cur-conn (pop conns))
209 (let ((settings (enwc-nm-get-settings cur-conn))
211 (if (not (assoc "connection" settings))
213 (setq conn-set (assoc "connection" settings))
214 (setq cur-id (car (cadr (assoc "id" (cadr conn-set)))))
215 (if (string= cur-id id)
216 (setq uuid (car (cadr (assoc "uuid" (cadr conn-set)))))))))))
218 (defun enwc-nm-get-conn-by-uuid (uuid)
219 (dbus-call-method :system
221 enwc-nm-dbus-settings-path
222 enwc-nm-dbus-settings-interface
223 "GetConnectionByUuid"
228 (defun enwc-nm-get-conn-by-ssid (ssid)
229 "Gets the connection path for the access point with ssid SSID."
230 (let ((uuid (enwc-nm-get-uuid-by-ssid ssid)))
232 (enwc-nm-get-conn-by-uuid uuid)
235 (defun enwc-nm-get-conn-by-id (id)
236 "Gets a connection object with the id ID.
237 ID is the identifier used by Network Manager."
238 (let ((uuid (enwc-nm-get-uuid-by-id id)))
239 (enwc-nm-get-conn-by-uuid uuid)))
242 (defun enwc-nm-scan ()
243 "The NetworkManager scan function."
244 (dbus-call-method :system
247 enwc-nm-dbus-wireless-interface
250 '(:array :signature "{sv}")))
253 (defun enwc-nm-get-networks ()
254 "The NetworkManager get networks function.
255 This returns a list of D-Bus paths to the access points."
256 (dbus-call-method :system
259 enwc-nm-dbus-wireless-interface
264 (defun enwc-nm-get-wireless-network-property (id prop)
265 "The NetworkManager get wireless network property function.
266 This runs like normal, using element ID of `enwc-access-points'
267 to determine the access point path, then obtains the property
268 PROP from that access point. It also sets the channel from the
269 frequency if necessary."
270 (let ((ap (nth id enwc-access-points))
273 (if (string= mod-prop "essid")
274 (setq mod-prop "Ssid"))
275 (setq ret (dbus-get-property :system
278 enwc-nm-dbus-accesspoint-interface
282 (if (not enwc-nm-edit-info)
285 (setq ret (assoc mod-prop
286 (cadr (assoc "802-1x"
287 enwc-nm-edit-info))))
289 (setq ret (assoc mod-prop
290 (cadr (assoc "802-11-wireless-security"
291 enwc-nm-edit-info)))))
292 (setq ret (car (cadr ret))))))
293 (if (string= mod-prop "Frequency")
294 (setq ret (number-to-string (1+ (/ (- ret 2412) 5)))))
295 (if (string= mod-prop "Ssid")
296 (setq ret (dbus-byte-array-to-string ret)))
297 (if (string= mod-prop "Mode")
298 (setq ret (cond ((= ret 0) "Unknown")
300 ((= ret 2) "Infrastructure"))))
303 (defun enwc-nm-get-wireless-nw-props (id)
304 (let ((ap (nth id enwc-access-points))
307 (setq ret (dbus-get-all-properties :system
310 enwc-nm-dbus-accesspoint-interface))
311 (setq tmp-val (cdr (assoc "Mode" ret)))
312 (setcdr (assoc "Frequency" ret)
313 (number-to-string (1+ (/ (- (cdr (assoc "Frequency" ret))
315 (setcdr (assoc "Ssid" ret)
316 (dbus-byte-array-to-string (cdr (assoc "Ssid" ret))))
317 (setcdr (assoc "Mode" ret)
318 (cond ((= tmp-val 0) "Unkown")
319 ((= tmp-val 1) "Ad-Hoc")
320 ((= tmp-val 2) "Infrastructure")))
323 (defun enwc-nm-get-conn-by-nid (nid)
324 "Gets a connection object with the network id NID."
325 (let* ((ssid (enwc-nm-get-wireless-network-property nid
327 (uuid (enwc-nm-get-uuid-by-ssid ssid)))
329 (enwc-nm-get-conn-by-uuid uuid)
332 (defun enwc-nm-get-encryption-type (id)
333 "The NetworkManager get encryption type function.
334 This gets the WPA flags and RSN flags from access point in ID.
335 If both are 0, then it returns WEP, otherwise WPA."
336 (let ((wpa-flags (enwc-nm-get-wireless-network-property id "WpaFlags"))
337 (rsn-flags (enwc-nm-get-wireless-network-property id "RsnFlags")))
338 (if (and (= wpa-flags 0) (= rsn-flags 0))
343 (defun enwc-nm-connect (id)
344 "The NetworkManager connect function.
345 This gets the connection path from ID, and connects to it."
346 (let ((ssid (enwc-nm-get-wireless-network-property id "Ssid")))
347 (dbus-call-method :system
350 enwc-nm-dbus-interface
353 :object-path (enwc-nm-get-conn-by-ssid ssid)
354 :object-path enwc-nm-wireless-dev
355 :object-path (nth id enwc-access-points))))
358 (defun enwc-nm-string-idx (obj list)
359 (let ((tmp-list list)
362 (while (and (not cur-obj) tmp-list)
363 (setq cur-obj (pop tmp-list))
364 (setq cur-pos (1+ cur-pos))
365 (if (not (string= obj cur-obj))
369 (defun enwc-nm-wireless-prop-changed (props)
370 (if (assoc "ActiveAccessPoint" props)
371 (setq enwc-nm-active-ap (car (cadr (assoc "ActiveAccessPoint"
375 (defun enwc-nm-get-current-nw-id (wired)
376 "The NetworkManager get current network id function.
377 This simply checks for the active access point."
378 (if (or wired (string= enwc-nm-active-ap "/"))
380 (enwc-nm-string-idx enwc-nm-active-ap enwc-access-points)))
382 (defun enwc-nm-prop-changed (state)
383 (setq enwc-nm-connecting-p (eq state 40)))
386 (defun enwc-nm-check-connecting ()
387 "The NetworkManager check connecting function."
388 enwc-nm-connecting-p)
391 (defun enwc-nm-disconnect-wireless ()
392 (dbus-call-method :system
395 enwc-nm-dbus-device-interface
398 ;; Settings, Connections
399 (defun enwc-nm-get-wired-profiles ()
400 (let ((profs-list (enwc-nm-list-connections)))
402 (let ((props (enwc-nm-get-settings x)))
403 (if (string= (caar props) "connection")
404 (car (cadr (car (cadr (car props))))))))
407 (defun enwc-nm-wired-connect (id)
408 (let ((nid (nth id enwc-access-points)))
409 (dbus-call-method :system
412 enwc-nm-dbus-interface
414 :object-path (enwc-nm-get-conn-by-id nid)
415 :object-path enwc-nm-wired-dev
419 (defun enwc-nm-wired-disconnect ()
420 (dbus-call-method :system
423 enwc-nm-dbus-device-interface
426 (defun enwc-nm-dev-prop-changed (new-state old-state reason)
427 (setq enwc-nm-wired-p (eq new-state 100)))
430 (defun enwc-nm-is-wired ()
433 ;; Each entry in sec-types should be:
434 ;; ("IDENT" (("Name" . "NAME") ("reqs" . (("key1" . "Entry1") ("key2" . "Entry2") ... ))))
436 ;; "IDENT" => String that identifies this to the backend.
437 ;; "NAME" => String that ENWC displays
438 ;; "reqs" => Constant string, but the association list holds entries
439 ;; required by the security type, i.e. user, passphrase, etc.
440 ;; "keyXX" => String that the backend uses for this security entry.
441 ;; "EntryXX" => String that ENWC displays for this security entry.
443 (defun enwc-nm-get-sec-types (wired)
444 "Get security types."
450 (defun enwc-nm-gen-uuid ()
455 (number-sequence 0 7)))
457 (setq fin-str (format "%04x%04x-%04x-%04x-%04x-%04x%04x%04x"
467 (defun enwc-nm-convert-addr (addr)
469 (let* ((hex-addr (format "%08x" addr))
470 (ret-addr (format "%i.%i.%i.%i"
471 (string-to-number (substring hex-addr
474 (string-to-number (substring hex-addr
477 (string-to-number (substring hex-addr
480 (string-to-number (substring hex-addr
486 (defun enwc-nm-addr-back (addr)
487 (let ((bytes (split-string addr "."))
489 (setq ret-val (logior (lsh (string-to-number (nth 3 bytes))
491 (lsh (string-to-number (nth 2 bytes))
493 (lsh (string-to-number (nth 1 bytes))
495 (lsh (string-to-number (nth 0 bytes))
498 ;; These next two come from libnm-util/nm-utils.c in NM's source.
500 (defun enwc-nm-netmask-to-prefix (netmask)
501 "Converts a netmask to a prefix.
502 NETMASK is an ip address in network byte order."
504 (let* ((mask netmask)
506 (cur-mark (logand (lsh mask (* -8 cur-pos)) 255))
508 (while (and (eq cur-mark 255) (>= cur-pos 0))
510 (setq cur-pos (1- cur-pos))
511 (setq cur-mark (logand (lsh mask (* -8 cur-pos)) 255))
515 (let ((v (logand (lsh mask (* -8 cur-pos)) 255)))
516 (while (not (eq v 0))
518 (setq v (lsh v 1)))))
522 (defun enwc-nm-prefix-to-netmask (prefix)
523 "Converts a prefix to a netmask.
524 PREFIX is an integer <= 32."
529 (setq netmask (logior netmask msk))
530 (setq msk (lsh msk -1))
534 (defun enwc-nm-get-nw-info (wired id)
535 (let ((conn (enwc-nm-get-conn-by-nid id)))
537 (setq enwc-nm-edit-info
538 (enwc-nm-get-settings conn))))
540 (let (ip-addr netmask gateway dns-list nw-info)
541 (if enwc-nm-edit-info
543 (setq ip-addr (nth 0 (caar (cadr (assoc "addresses"
545 enwc-nm-edit-info))))))
546 netmask (nth 3 (caar (cadr (assoc "addresses"
548 enwc-nm-edit-info))))))
549 gateway (nth 2 (caar (cadr (assoc "address"
551 enwc-nm-edit-info))))))
552 dns-list (car (cadr (assoc "dns" (cadr (assoc "ipv4"
553 enwc-nm-edit-info))))))
554 (setq ip-addr (enwc-nm-convert-addr ip-addr)
555 netmask (enwc-nm-convert-addr netmask)
556 gateway (enwc-nm-convert-addr gateway)
557 dns-list (mapcar 'enwc-nm-convert-addr
559 (setq nw-info (list (cons (cons "addr"
561 (cons (cons "netmask"
563 (cons (cons "gateway"
573 (cons (cons "enctype"
578 (defun enwc-nm-get-ip-addr (wired id)
579 "Gets the IP Address of a connection profile."
580 (let ((props (enwc-nm-get-settings (enwc-nm-get-conn-by-nid id)))
584 (setq ipaddr (nth 0 (caar (cadr (assoc "addresses"
587 (setq ret-addr (enwc-nm-convert-addr ipaddr)))))
589 (defun enwc-nm-get-netmask (wired id)
590 "Gets the Netmask of a connection profile."
591 (let ((props (enwc-nm-get-settings (enwc-nm-get-conn-by-nid id)))
592 ipaddr hex-addr ret-addr)
595 (setq ipaddr (nth 3 (caar (cadr (assoc "addresses"
598 (setq hex-addr (enwc-nm-prefix-to-netmask ipaddr))
599 (setq ret-addr (format "%i.%i.%i.%i"
600 (logand hex-addr 255)
601 (logand (lsh hex-addr -8) 255)
602 (logand (lsh hex-addr -16) 255)
603 (logand (lsh hex-addr -24) 255))))))
606 (defun enwc-nm-get-gateway (wired id)
607 "Gets the Gateway of a connection profile."
608 (let ((props (enwc-nm-get-settings (enwc-nm-get-conn-by-nid id)))
612 (setq ipaddr (nth 2 (caar (cadr (assoc "addresses"
615 (setq ret-addr (enwc-nm-convert-addr ipaddr)))))
617 (defun enwc-nm-get-dns (wired id)
618 "Gets the DNS settings of a connection profile."
619 (let ((props (enwc-nm-get-settings (enwc-nm-get-conn-by-nid id)))
621 (setq dns-list (car (cadr (assoc "dns" (cadr (assoc "ipv4"
623 (mapcar 'enwc-nm-convert-addr
626 (defun enwc-nm-process-enctype (settings nw-settings)
627 "Process the encryption type.
628 Sets up the encryption type passed in through SETTINGS."
629 (let* ((ret-list nw-settings)
630 (req-list (nthcdr 6 settings))
631 (enctype (cdr (assoc "enctype" settings)))
634 ;;(name-list (cdr (assoc "reqs" (cdr (assoc enctype enwc-nm-sec-types)))))
637 ;; There is a possibility that any of these don't exist in
640 (setq new-list `("802-11-wireless-security" (("pairwise" (("wep40" "wep104")))
641 ("group" (("wep40" "wep104")))
643 ("key-mgmt" (nil)))))
645 (if (not (assoc "802-11-wireless-security" ret-list))
646 (setq ret-list (append ret-list (list new-list))))
648 (if (or (string= enctype "eap-leap")
649 (string= enctype "eap-peap")
650 (string= enctype "eap-tls")
651 (string= enctype "eap-ttls"))
653 (setq key-name "802-1x")
654 (setq key-mgmt "ieee8021x")
655 (setq req-list (push (cons "eap" (substring enctype 4)) req-list))
657 ;;(setcdr (assoc "eap" (cadr (assoc "802-1x" ret-list))) (list (list (list (substring enctype 4)))))
659 (setq key-name "802-11-wireless-security")
661 (cond ((string= enctype "wep") "none")
662 ((string= enctype "wpa-psk") "wpa-psk")
663 ((string= enctype "leap") "iee8021x"))))
664 (setcdr (assoc "key-mgmt" (cadr (assoc "802-11-wireless-security" ret-list)))
665 (list (list key-mgmt)))
667 (if (string= enctype "leap")
668 (setcdr (assoc "auth-alg" (cadr (assoc "802-11-wireless-security" ret-list)))
669 (list (list "leap"))))
671 (setq name-list (cons key-name
672 (list (mapcar (lambda (x)
674 (cons (cons (cdr x) nil)
678 (if (not (assoc key-name ret-list))
679 (setq ret-list (append ret-list (list name-list)))
680 (setcdr (assoc key-name ret-list) (list name-list)))
683 (if (or (string= enctype "eap-leap")
684 (string= enctype "eap-peap")
685 (string= enctype "eap-tls")
686 (string= enctype "eap-ttls"))
687 (setcdr (assoc "eap" (cadr (assoc "802-1x" ret-list)))
688 (cons (cons (cons (substring enctype 4) nil) nil) nil)))
692 (defun enwc-nm-finalize-settings (settings)
693 "Sets up all of the D-BUS types of a settings list.
694 SETTINGS is the list of settings list to setup.
695 This will place all of the necessary markers in the list,
696 such as :array, :dict-entry, etc."
700 (setq first-one (cons :dict-entry first-one))
708 (cons :dict-entry this-one))
710 (cons (list :string (car y)
712 (if (string= (car y) "ssid")
713 (cons (dbus-string-to-byte-array
714 (dbus-byte-array-to-string (car (cadr y))))
719 (nreverse this-one))) nil)))
722 (nreverse first-one))))
724 (defun enwc-nm-create-settings (wired ssid)
725 (let ((uuid (enwc-nm-gen-uuid))
726 (id (concat ssid " settings"))
736 (setq new-ssid (dbus-string-to-byte-array ssid))
738 (setq 80211-list `("802-11-wireless" (("security" (nil))
740 ("mode" ("infrastructure")))))
742 (setq ret-list (append ret-list (list 80211-list))
743 type "802-11-wireless"))
744 (setq type "802-3-ethernet"))
745 (setq conn-list `("connection" (("id" (,id))
747 ("autoconnect" (nil))
750 (setq ipv4-list '("ipv4" (("addresses" (nil))
755 (setq ipv6-list '("ipv4" (("addresses" (nil))
760 (setq ret-list (append ret-list (list conn-list)))
761 (setq ret-list (append ret-list (list ipv4-list)))
762 (setq ret-list (append ret-list (list ipv6-list)))
765 (defun enwc-nm-setup-settings (wired id settings)
766 "Sets up NetworkManager settings.
767 Gets the current network properties of network ID
768 and uses the information in the association list SETTINGS
769 to put it in the form that NetworkManager will recognize."
771 (let (ssid uuid conn props)
773 (if (not enwc-nm-edit-info)
776 (enwc-nm-get-wireless-network-property (nth id
779 (setq props (enwc-nm-create-settings wired ssid)))
780 (setq props enwc-nm-edit-info))
782 (print enwc-nm-edit-info)
783 ;; (setq uuid (enwc-nm-get-uuid-by-ssid ssid))
785 ;; (setq conn (enwc-nm-get-conn-by-uuid uuid)))))
789 ;; (enwc-nm-get-settings (enwc-nm-get-conn-by-nid id))
790 ;; (enwc-nm-create-settings wired ssid)))
792 (setcdr (assoc "type" (cadr (assoc "connection" props)))
793 (list (list (cond (wired "802-3-ethernet")
794 ((not wired) "802-11-wireless")))))
796 (if (= (length (cdr (assoc "addr" settings))) 0)
797 (setcdr (assoc "addresses" (cadr (assoc "ipv4" props)))
798 (cons (cons nil nil) nil))
800 (setcdr (assoc "addresses" (cadr (assoc "ipv4" props)))
801 (list (list (list (list (enwc-nm-addr-back
802 (cdr (assoc "addr" settings)))
803 (enwc-nm-netmask-to-prefix (enwc-nm-addr-back
804 (cdr (assoc "netmask"
807 (cdr (assoc "gateway" settings)))))))))
809 (if (= (length (cdr (assoc "dns1" settings))) 0)
810 (setcdr (assoc "dns" (cadr (assoc "ipv4" props)))
811 (cons (cons nil nil) nil))
812 (setcdr (assoc "dns" (cadr (assoc "ipv4" props)))
813 (list (list (list (enwc-nm-addr-back
814 (cdr (assoc "dns1" settings)))
816 (cdr (assoc "dns2" settings))))))))
818 (setq props (enwc-nm-process-enctype settings props))
821 (enwc-nm-finalize-settings props)))
823 (defun enwc-nm-save-nw-settings (wired id settings)
824 "Saves network settings.
825 ID is the network id of the profile to save,
826 WIRED denotes whether or not this is a wired profile,
827 and SETTINGS is the list of settings."
828 (let ((mod-sets (enwc-nm-setup-settings wired id settings)))
831 (dbus-call-method :system
833 ;;(nth id enwc-access-points)
834 (enwc-nm-get-conn-by-nid id)
835 enwc-nm-dbus-connections-interface
836 (if (not enwc-nm-edit-info)
843 (defun enwc-nm-setup ()
844 (setq enwc-nm-wired-dev (enwc-nm-get-device-by-name enwc-wired-device)
845 enwc-nm-wireless-dev (enwc-nm-get-device-by-name enwc-wireless-device))
847 (dbus-register-signal :system
850 enwc-nm-dbus-wireless-interface
854 (dbus-register-signal :system
857 enwc-nm-dbus-wireless-interface
861 (setq enwc-nm-active-ap
862 (let ((cur-net (dbus-get-property :system
865 enwc-nm-dbus-wireless-interface
866 "ActiveAccessPoint")))
867 (if (string= cur-net "/")
871 (dbus-register-signal :system
874 enwc-nm-dbus-wireless-interface
876 'enwc-nm-wireless-prop-changed)
878 (setq enwc-nm-connecting-p
879 (let ((state (dbus-get-property :system
882 enwc-nm-dbus-interface
886 (dbus-register-signal :system
889 enwc-nm-dbus-device-interface
891 'enwc-nm-dev-prop-changed)
893 (setq enwc-nm-wired-p
894 (let ((state (dbus-get-property :system
897 enwc-nm-dbus-device-interface
900 (dbus-register-signal :system
903 enwc-nm-dbus-interface
905 'enwc-nm-prop-changed)