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
38 "*ConnMan variables for ENWC"
42 (defcustom enwc-cm-dbus-service "net.connman"
43 "ConnMan D-Bus service."
48 ;; DEMAND TO SEE LIFE'S MANAGER!!
50 (defcustom enwc-cm-dbus-manager-interface "net.connman.Manager"
51 "ConnMan D-Bus Manager interface."
55 (defcustom enwc-cm-dbus-service-interface "net.connman.Service"
56 "ConnMan D-Bus Service interface."
60 (defvar enwc-cm-details-list
61 '("Name" "bssid" "Strength" "Security" "mode" "channel"))
63 (defun enwc-cm-get-services ()
64 (dbus-call-method :system
67 enwc-cm-dbus-manager-interface
70 (defun enwc-cm-get-networks ()
71 (let ((services (enwc-cm-get-services)))
72 (mapcar 'car services)))
74 (defun enwc-cm-get-network (id)
75 (nth id (enwc-cm-get-services)))
78 (defun enwc-cm-scan (wired)
79 (dbus-call-method :system
81 "/net/connman/technology/(ethernet|wifi)"
82 "net.connman.Technology"
86 (defun enwc-cm-connect (wired id)
87 (dbus-call-method :system
89 "/net/connman/service/serviceID"
90 enwc-cm-dbus-service-interface
94 (defun enwc-cm-disconnect (wired)
95 (dbus-call-method :system
97 "/net/connman/service/CONNECTED-SERVICE"
98 enwc-cm-dbus-service-interface
101 (defun enwc-cm-get-nw-prop (id prop)
102 (let ((network (enwc-cm-get-network id)))
103 (car (cadr (assoc prop (cadr network))))))
105 (defun enwc-cm-get-wireless-network-property (id prop)
106 (enwc-cm-get-nw-prop id prop))
108 (defun enwc-cm-get-encryption-type (id)
109 (enwc-cm-get-nw-prop id "Security"))
111 (defun enwc-cm-get-ip-addr (wired id)
112 (let ((ipv4-config (enwc-cm-get-nw-prop id "IPv4.Configuration")))
113 (car (cadr (assoc "Address" ipv4-config)))))
115 (defun enwc-cm-get-netmask (wired id)
116 (let ((ipv4-config (enwc-cm-get-nw-prop id "IPv4.Configuration")))
117 (car (cadr (assoc "Netmask" ipv4-config)))))
119 (defun enwc-cm-get-gateway (wired id)
120 (let ((ipv4-config (enwc-cm-get-nw-prop id "IPv4.Configuration")))
121 (car (cadr (assoc "Gateway" ipv4-config)))))
123 (defun enwc-cm-get-dns (wired id)
124 (enwc-cm-get-nw-prop id "Nameservers.Configuration"))
126 (defun enwc-cm-set-nw-prop (wired id prop val)
127 (dbus-call-method :system
129 (car (enwc-cm-get-network id))
130 enwc-cm-dbus-service-interface
135 (defun enwc-cm-save-nw-settings (wired id settings)
136 (let* ((ipv4 (enwc-cm-get-nw-prop id "IPv4.Configuration"))
137 (method (car (cadr (assoc "Method" ipv4))))
138 (ip-addr (cdr (assoc "addr" settings)))
139 (netmask (cdr (assoc "netmask" settings)))
140 (gateway (cdr (assoc "gateway" settings)))
141 new-ipv4-config new-dns-config)
142 (setq new-ipv4-config
143 (list (list (cons "Method" (cons (cons method nil) nil))
144 (cons "Address" (cons (cons ip-addr nil) nil))
145 (cons "Netmask" (cons (cons netmask nil) nil))
146 (cons "Gateway" (cons (cons gateway nil) nil)))))
148 (list (list (cdr (assoc "dns1" settings))
149 (cdr (assoc "dns2" settings)))))
150 (enwc-cm-set-nw-prop wired id "IPv4.Configuration"
152 (enwc-cm-set-nw-prop wired id "Nameservers.Configuration"