]> code.delx.au - gnu-emacs-elpa/blob - packages/enwc/enwc-setup.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / enwc / enwc-setup.el
1 ;; enwc-setup.el - Setup routines for ENWC
2
3 ;; Copyright (C) 2012,2013 Free Software Foundation, Inc.
4
5 ;; Author: Ian Dunn
6 ;; Keywords: enwc, network, wicd, manager, nm
7
8 ;; This file is part of ENWC
9
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)
13 ;; any later version.
14
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.
19
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
23 ;; 02110-1301, USA.
24
25
26 (require 'enwc)
27 (require 'enwc-wicd)
28 (require 'enwc-nm)
29
30 (defun enwc-setup-backend (cur-back)
31 "Sets up ENWC to use the correct function for the backend CUR-BACK."
32 (let ((sym-name (symbol-name cur-back)))
33 (setq enwc-scan-func (intern (concat "enwc-"
34 sym-name
35 "-scan"))
36 enwc-get-nw-func (intern (concat "enwc-"
37 sym-name
38 "-get-networks"))
39 enwc-get-wireless-nw-prop-func (intern (concat "enwc-"
40 sym-name
41 "-get-wireless-network-property"))
42 enwc-get-wireless-nw-props-func (intern (concat "enwc-"
43 sym-name
44 "-get-wireless-nw-props"))
45 enwc-details-list (symbol-value (intern (concat "enwc-"
46 sym-name
47 "-details-list")))
48 enwc-get-encryption-type-func (intern (concat "enwc-"
49 sym-name
50 "-get-encryption-type"))
51 enwc-wireless-connect-func (intern (concat "enwc-"
52 sym-name
53 "-connect"))
54 enwc-get-current-nw-id-func (intern (concat "enwc-"
55 sym-name
56 "-get-current-nw-id"))
57 enwc-check-connecting-func (intern (concat "enwc-"
58 sym-name
59 "-check-connecting"))
60 enwc-get-wired-profiles-func (intern (concat "enwc-"
61 sym-name
62 "-get-wired-profiles"))
63 enwc-is-wired-func (intern (concat "enwc-"
64 sym-name
65 "-is-wired"))
66 enwc-wired-connect-func (intern (concat "enwc-"
67 sym-name
68 "-wired-connect"))
69 enwc-wired-disconnect-func (intern (concat "enwc-"
70 sym-name
71 "-wired-disconnect"))
72 enwc-get-sec-types-func (intern (concat "enwc-"
73 sym-name
74 "-get-sec-types"))
75 enwc-get-ip-addr-func (intern (concat "enwc-"
76 sym-name
77 "-get-ip-addr"))
78 enwc-get-netmask-func (intern (concat "enwc-"
79 sym-name
80 "-get-netmask"))
81 enwc-get-gateway-func (intern (concat "enwc-"
82 sym-name
83 "-get-gateway"))
84 enwc-get-dns-func (intern (concat "enwc-"
85 sym-name
86 "-get-dns"))
87 enwc-get-nw-info-func (intern (concat "enwc-"
88 sym-name
89 "-get-nw-info"))
90 enwc-save-nw-settings-func (intern (concat "enwc-"
91 sym-name
92 "-save-nw-settings"))
93 )
94 (funcall (intern (concat "enwc-" sym-name "-setup")))))
95
96 (defun enwc-setup ()
97 "Sets up ENWC.
98 This setups ENWC and confirms that one of the backends can be found
99 on D-Bus."
100 (setq global-mode-string (append global-mode-string
101 '(enwc-display-string)))
102 (run-at-time t 1 'enwc-update-mode-line)
103
104 (let ((cur-back nil)
105 (back-list enwc-backends))
106 (while (and back-list (not cur-back))
107 (setq cur-back (pop back-list))
108 (if (not (dbus-ping :system
109 (symbol-value (intern (concat "enwc-"
110 (symbol-name cur-back)
111 "-dbus-service")))))
112 (setq cur-back nil)))
113 (if cur-back
114 (enwc-setup-backend cur-back)
115 (error "No usable backend found."))))
116
117 (provide 'enwc-setup)
118
119 ;;; End of File.