summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Houston <stephen@localhost.localdomain>2017-10-17 16:53:57 -0500
committerStephen Houston <stephen@localhost.localdomain>2017-10-17 16:53:57 -0500
commita59247cec4b93e616bffcab24f21ab0dafefe5de (patch)
treee6c914a2f356b43e0a5706824bf5bc4e1c973fda
-rw-r--r--build/.ninja_depsbin0 -> 41244 bytes
-rw-r--r--build/.ninja_log21
-rw-r--r--build/build.ninja147
-rw-r--r--build/compile_commands.json12
-rw-r--r--build/config.h33
-rwxr-xr-xbuild/e_gadget_wirelessbin0 -> 156960 bytes
-rw-r--r--build/e_gadget_wireless@exe/src_connman.c.obin0 -> 125504 bytes
-rw-r--r--build/e_gadget_wireless@exe/src_wireless.c.obin0 -> 130528 bytes
-rw-r--r--build/meson-logs/install-log.txt6
-rw-r--r--build/meson-logs/meson-log.txt81
-rw-r--r--build/meson-private/build.datbin0 -> 31330 bytes
-rw-r--r--build/meson-private/cleantrees.datbin0 -> 146 bytes
-rw-r--r--build/meson-private/coredata.datbin0 -> 27274 bytes
-rw-r--r--build/meson-private/install.datbin0 -> 1049 bytes
-rw-r--r--build/meson-private/meson_benchmark_setup.datbin0 -> 6 bytes
-rw-r--r--build/meson-private/meson_test_setup.datbin0 -> 6 bytes
-rw-r--r--build/meson-private/sanitycheckc.c1
-rwxr-xr-xbuild/meson-private/sanitycheckc.exebin0 -> 7936 bytes
-rw-r--r--build/wireless.desktop5
-rw-r--r--build/wireless.edjbin0 -> 104152 bytes
-rw-r--r--meson.build100
-rw-r--r--perms.sh3
-rw-r--r--src/connman.c1684
-rw-r--r--src/wireless.c1676
-rw-r--r--src/wireless.h149
-rw-r--r--theme/bt_base.pngbin0 -> 10501 bytes
-rw-r--r--theme/bt_sig_1.pngbin0 -> 14771 bytes
-rw-r--r--theme/bt_sig_2.pngbin0 -> 11506 bytes
-rw-r--r--theme/cell_base.pngbin0 -> 5730 bytes
-rw-r--r--theme/cell_sig_1.pngbin0 -> 2250 bytes
-rw-r--r--theme/cell_sig_2.pngbin0 -> 3211 bytes
-rw-r--r--theme/cell_sig_3.pngbin0 -> 3572 bytes
-rw-r--r--theme/cell_sig_4.pngbin0 -> 3714 bytes
-rw-r--r--theme/eth.pngbin0 -> 3087 bytes
-rw-r--r--theme/exlclam.pngbin0 -> 4328 bytes
-rw-r--r--theme/hole_tiny.pngbin0 -> 128 bytes
-rw-r--r--theme/led_tiny_green.pngbin0 -> 225 bytes
-rw-r--r--theme/led_tiny_orange.pngbin0 -> 234 bytes
-rw-r--r--theme/lock_insecure.pngbin0 -> 8014 bytes
-rw-r--r--theme/lock_locked.pngbin0 -> 7054 bytes
-rw-r--r--theme/slot_horiz_bottom.pngbin0 -> 199 bytes
-rw-r--r--theme/slot_horiz_top.pngbin0 -> 269 bytes
-rw-r--r--theme/wifi_base.pngbin0 -> 5017 bytes
-rw-r--r--theme/wifi_shadow.pngbin0 -> 3932 bytes
-rw-r--r--theme/wifi_sig_1.pngbin0 -> 1709 bytes
-rw-r--r--theme/wifi_sig_2.pngbin0 -> 4510 bytes
-rw-r--r--theme/wifi_sig_3.pngbin0 -> 8332 bytes
-rw-r--r--theme/wireless.edc958
-rw-r--r--theme/wireless.edc_backup958
-rw-r--r--wireless.desktop.in5
-rw-r--r--wireless.pngbin0 -> 14127 bytes
51 files changed, 5839 insertions, 0 deletions
diff --git a/build/.ninja_deps b/build/.ninja_deps
new file mode 100644
index 0000000..c3a3932
--- /dev/null
+++ b/build/.ninja_deps
Binary files differ
diff --git a/build/.ninja_log b/build/.ninja_log
new file mode 100644
index 0000000..ac8f212
--- /dev/null
+++ b/build/.ninja_log
@@ -0,0 +1,21 @@
1# ninja log v5
22 203 0 wireless.edj 5f6cf4b79771fa81
31 349 0 e_gadget_wireless@exe/src_wireless.c.o 18bf86fab2d56169
40 359 0 e_gadget_wireless@exe/src_connman.c.o 696a00897a81364a
5359 550 0 e_gadget_wireless 13ed9feccd66b10c
62 235 0 meson-install f511b0e8cb26cc97
76 304 0 e_gadget_wireless@exe/src_wireless.c.o 18bf86fab2d56169
8304 506 0 e_gadget_wireless 13ed9feccd66b10c
91 162 0 meson-install f511b0e8cb26cc97
105 305 0 e_gadget_wireless@exe/src_wireless.c.o 18bf86fab2d56169
11305 514 0 e_gadget_wireless 13ed9feccd66b10c
121 158 0 meson-install f511b0e8cb26cc97
134 300 0 e_gadget_wireless@exe/src_wireless.c.o 18bf86fab2d56169
14301 509 0 e_gadget_wireless 13ed9feccd66b10c
151 157 0 meson-install f511b0e8cb26cc97
164 354 0 e_gadget_wireless@exe/src_wireless.c.o 18bf86fab2d56169
17355 553 0 e_gadget_wireless 13ed9feccd66b10c
181 170 0 meson-install f511b0e8cb26cc97
193 343 0 e_gadget_wireless@exe/src_wireless.c.o 18bf86fab2d56169
20343 548 0 e_gadget_wireless 13ed9feccd66b10c
218 228 0 meson-install f511b0e8cb26cc97
diff --git a/build/build.ninja b/build/build.ninja
new file mode 100644
index 0000000..a0e5c47
--- /dev/null
+++ b/build/build.ninja
@@ -0,0 +1,147 @@
1# This is the build file for project "wireless"
2# It is autogenerated by the Meson build system.
3# Do not edit by hand.
4
5ninja_required_version = 1.5.1
6
7# Rules for compiling.
8
9rule c_COMPILER
10 command = cc $ARGS -MMD -MQ $out -MF '$DEPFILE' -o $out -c $in
11 deps = gcc
12 depfile = $DEPFILE
13 description = Compiling C object $out.
14
15rule c_PCH
16 command = cc $ARGS -MMD -MQ $out -MF '$DEPFILE' -o $out -c $in
17 deps = gcc
18 depfile = $DEPFILE
19 description = Precompiling header $in.
20
21
22# Rules for linking.
23
24rule STATIC_LINKER
25 command = rm -f $out && gcc-ar $LINK_ARGS $out $in
26 description = Linking static target $out.
27
28rule c_LINKER
29 command = cc $ARGS -o $out $in $LINK_ARGS $aliasing
30 description = Linking target $out.
31
32
33rule SHSYM
34 command = "/usr/bin/python3" "/usr/bin/meson" --internal symbolextractor $in $out $CROSS
35 restat = 1
36 description = Generating symbol file $out.
37
38# Other rules
39
40rule CUSTOM_COMMAND
41 command = $COMMAND
42 description = $DESC
43 restat = 1
44
45rule CUSTOM_COMMAND_DEP
46 command = $COMMAND
47 description = $DESC
48 deps = gcc
49 depfile = $DEPFILE
50 restat = 1
51
52rule REGENERATE_BUILD
53 command = /usr/bin/python3 /usr/bin/meson --internal regenerate /home/stephen/code/wireless /home/stephen/code/wireless/build --backend ninja
54 description = Regenerating build files.
55 generator = 1
56
57
58# Phony build target, always out of date
59build PHONY: phony
60
61# Build rules for targets
62
63build e_gadget_wireless@exe/src_wireless.c.o: c_COMPILER ../src/wireless.c
64 DEPFILE = e_gadget_wireless@exe/src_wireless.c.o.d
65 ARGS = -Ie_gadget_wireless@exe -I. -I.. -I../../ -I../../../ -I../ -I/usr/local/include/enlightenment -I/usr/local/include/efl-1 -I/usr/local/include/eina-1 -I/usr/local/include/eina-1/eina -I/usr/local/include/eet-1 -I/usr/local/include/emile-1 -I/usr/local/include/eo-1 -I/usr/local/include/ecore-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/local/include/ecore-ipc-1 -I/usr/local/include/ecore-con-1 -I/usr/local/include/eldbus-1 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/local/include/ecore-file-1 -I/usr/local/include/ecore-input-1 -I/usr/local/include/eeze-1 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/local/include/ecore-input-evas-1 -I/usr/local/include/evas-1 -I/usr/local/include/evas-1/canvas -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/luajit-2.1 -I/usr/local/include/efreet-1 -I/usr/local/include/eio-1 -I/usr/local/include/emotion-1 -I/usr/local/include/elementary-1 -I/usr/include/libdrm -I/usr/local/include/ecore-wl2-1 -I/usr/local/include/ecore-drm2-1 -I/usr/local/include/elput-1 -I/usr/local/include/ecore-x-1 -I/usr/local/include/elocation-1 -I/usr/local/include/ecore-imf-1 -I/usr/local/include/ethumb-client-1 -I/usr/local/include/ethumb-1 -I/usr/local/include/edje-1 -I/usr/local/include/ecore-audio-1 -I/usr/local/include/embryo-1 -I/usr/local/include/ecore-imf-evas-1 -I/usr/local/include/ecore-evas-1 -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -O0 -g -DHAVE_CONFIG_H=1 -pthread
66
67build e_gadget_wireless@exe/src_connman.c.o: c_COMPILER ../src/connman.c
68 DEPFILE = e_gadget_wireless@exe/src_connman.c.o.d
69 ARGS = -Ie_gadget_wireless@exe -I. -I.. -I../../ -I../../../ -I../ -I/usr/local/include/enlightenment -I/usr/local/include/efl-1 -I/usr/local/include/eina-1 -I/usr/local/include/eina-1/eina -I/usr/local/include/eet-1 -I/usr/local/include/emile-1 -I/usr/local/include/eo-1 -I/usr/local/include/ecore-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/local/include/ecore-ipc-1 -I/usr/local/include/ecore-con-1 -I/usr/local/include/eldbus-1 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/local/include/ecore-file-1 -I/usr/local/include/ecore-input-1 -I/usr/local/include/eeze-1 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/local/include/ecore-input-evas-1 -I/usr/local/include/evas-1 -I/usr/local/include/evas-1/canvas -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/luajit-2.1 -I/usr/local/include/efreet-1 -I/usr/local/include/eio-1 -I/usr/local/include/emotion-1 -I/usr/local/include/elementary-1 -I/usr/include/libdrm -I/usr/local/include/ecore-wl2-1 -I/usr/local/include/ecore-drm2-1 -I/usr/local/include/elput-1 -I/usr/local/include/ecore-x-1 -I/usr/local/include/elocation-1 -I/usr/local/include/ecore-imf-1 -I/usr/local/include/ethumb-client-1 -I/usr/local/include/ethumb-1 -I/usr/local/include/edje-1 -I/usr/local/include/ecore-audio-1 -I/usr/local/include/embryo-1 -I/usr/local/include/ecore-imf-evas-1 -I/usr/local/include/ecore-evas-1 -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -O0 -g -DHAVE_CONFIG_H=1 -pthread
70
71build e_gadget_wireless: c_LINKER e_gadget_wireless@exe/src_wireless.c.o e_gadget_wireless@exe/src_connman.c.o
72 LINK_ARGS = -Wl,--no-undefined -Wl,--as-needed -L/usr/local/lib -Wl,--start-group -lecore_ipc -lecore_input_evas -leeze -lelementary -lefl -leina -leet -levas -lecore -lecore_evas -lecore_file -lecore_input -ledje -leo -lethumb_client -lemotion -lecore_imf -lecore_con -leldbus -lefreet -lefreet_mime -lefreet_trash -leio -lpthread -lm -ldl -lrt -Wl,--end-group -lecore_wl2 -lecore_drm2 -lwayland-server -lwayland-client -lxkbcommon -luuid -lecore_x -L/usr/local/lib -lelementary -lefl -leina -leet -levas -lecore -lecore_evas -lecore_file -lecore_input -ledje -leo -lethumb_client -lemotion -lecore_imf -lecore_con -leldbus -lefreet -lefreet_mime -lefreet_trash -leio -lpthread -lm -ldl -lrt
73
74build wireless.edj: CUSTOM_COMMAND ../theme/wireless.edc | /usr/local/bin/edje_cc
75 COMMAND = /usr/local/bin/edje_cc -id /home/stephen/code/wireless/theme ../theme/wireless.edc wireless.edj
76 description = Generating$ wireless.edj$ with$ a$ custom$ command.
77
78# Test rules
79
80build meson-test: CUSTOM_COMMAND all PHONY
81 COMMAND = /usr/bin/python3 -u /usr/bin/meson test --no-rebuild --print-errorlogs
82 DESC = Running$ all$ tests.
83 pool = console
84
85build test: phony meson-test
86
87build meson-benchmark: CUSTOM_COMMAND all PHONY
88 COMMAND = /usr/bin/python3 -u /usr/bin/meson test --benchmark --logbase benchmarklog --num-processes=1 --no-rebuild
89 DESC = Running$ benchmark$ suite.
90 pool = console
91
92build benchmark: phony meson-benchmark
93
94# Install rules
95
96build meson-install: CUSTOM_COMMAND PHONY | all
97 DESC = Installing$ files.
98 COMMAND = /usr/bin/python3 /usr/bin/meson --internal install /home/stephen/code/wireless/build/meson-private/install.dat
99 pool = console
100
101build install: phony meson-install
102
103build meson-dist: CUSTOM_COMMAND PHONY
104 DESC = Creating$ source$ packages
105 COMMAND = /usr/bin/python3 /usr/bin/meson --internal dist /home/stephen/code/wireless /home/stephen/code/wireless/build /usr/bin/python3 /usr/bin/meson
106 pool = console
107
108build dist: phony meson-dist
109
110# Suffix
111
112build meson-scan-build: CUSTOM_COMMAND PHONY
113 COMMAND = /usr/bin/python3 /usr/bin/meson --internal scanbuild /home/stephen/code/wireless /home/stephen/code/wireless/build /usr/bin/python3 /usr/bin/meson
114 pool = console
115
116build scan-build: phony meson-scan-build
117
118build meson-uninstall: CUSTOM_COMMAND PHONY
119 COMMAND = /usr/bin/python3 /usr/bin/meson --internal uninstall
120 pool = console
121
122build uninstall: phony meson-uninstall
123
124build all: phony e_gadget_wireless wireless.edj
125
126default all
127
128build clean: phony meson-clean
129
130build meson-clean-ctlist: CUSTOM_COMMAND PHONY
131 COMMAND = /usr/bin/python3 /usr/bin/meson --internal cleantrees /home/stephen/code/wireless/build/meson-private/cleantrees.dat
132 description = Cleaning$ custom$ target$ directories.
133
134build clean-ctlist: phony meson-clean-ctlist
135
136build meson-clean: CUSTOM_COMMAND PHONY | clean-ctlist
137 COMMAND = ninja -t clean
138 description = Cleaning.
139
140build build.ninja: REGENERATE_BUILD ../meson.build ../wireless.desktop.in meson-private/coredata.dat
141 pool = console
142
143build reconfigure: REGENERATE_BUILD PHONY
144 pool = console
145
146build ../meson.build ../wireless.desktop.in meson-private/coredata.dat: phony
147
diff --git a/build/compile_commands.json b/build/compile_commands.json
new file mode 100644
index 0000000..afe9b51
--- /dev/null
+++ b/build/compile_commands.json
@@ -0,0 +1,12 @@
1[
2 {
3 "directory": "/home/stephen/code/wireless/build",
4 "command": "cc -Ie_gadget_wireless@exe -I. -I.. -I../../ -I../../../ -I../ -I/usr/local/include/enlightenment -I/usr/local/include/efl-1 -I/usr/local/include/eina-1 -I/usr/local/include/eina-1/eina -I/usr/local/include/eet-1 -I/usr/local/include/emile-1 -I/usr/local/include/eo-1 -I/usr/local/include/ecore-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/local/include/ecore-ipc-1 -I/usr/local/include/ecore-con-1 -I/usr/local/include/eldbus-1 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/local/include/ecore-file-1 -I/usr/local/include/ecore-input-1 -I/usr/local/include/eeze-1 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/local/include/ecore-input-evas-1 -I/usr/local/include/evas-1 -I/usr/local/include/evas-1/canvas -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/luajit-2.1 -I/usr/local/include/efreet-1 -I/usr/local/include/eio-1 -I/usr/local/include/emotion-1 -I/usr/local/include/elementary-1 -I/usr/include/libdrm -I/usr/local/include/ecore-wl2-1 -I/usr/local/include/ecore-drm2-1 -I/usr/local/include/elput-1 -I/usr/local/include/ecore-x-1 -I/usr/local/include/elocation-1 -I/usr/local/include/ecore-imf-1 -I/usr/local/include/ethumb-client-1 -I/usr/local/include/ethumb-1 -I/usr/local/include/edje-1 -I/usr/local/include/ecore-audio-1 -I/usr/local/include/embryo-1 -I/usr/local/include/ecore-imf-evas-1 -I/usr/local/include/ecore-evas-1 -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -O0 -g -DHAVE_CONFIG_H=1 -pthread -MMD -MQ 'e_gadget_wireless@exe/src_wireless.c.o' -MF 'e_gadget_wireless@exe/src_wireless.c.o.d' -o 'e_gadget_wireless@exe/src_wireless.c.o' -c ../src/wireless.c",
5 "file": "../src/wireless.c"
6 },
7 {
8 "directory": "/home/stephen/code/wireless/build",
9 "command": "cc -Ie_gadget_wireless@exe -I. -I.. -I../../ -I../../../ -I../ -I/usr/local/include/enlightenment -I/usr/local/include/efl-1 -I/usr/local/include/eina-1 -I/usr/local/include/eina-1/eina -I/usr/local/include/eet-1 -I/usr/local/include/emile-1 -I/usr/local/include/eo-1 -I/usr/local/include/ecore-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/local/include/ecore-ipc-1 -I/usr/local/include/ecore-con-1 -I/usr/local/include/eldbus-1 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/local/include/ecore-file-1 -I/usr/local/include/ecore-input-1 -I/usr/local/include/eeze-1 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/local/include/ecore-input-evas-1 -I/usr/local/include/evas-1 -I/usr/local/include/evas-1/canvas -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/luajit-2.1 -I/usr/local/include/efreet-1 -I/usr/local/include/eio-1 -I/usr/local/include/emotion-1 -I/usr/local/include/elementary-1 -I/usr/include/libdrm -I/usr/local/include/ecore-wl2-1 -I/usr/local/include/ecore-drm2-1 -I/usr/local/include/elput-1 -I/usr/local/include/ecore-x-1 -I/usr/local/include/elocation-1 -I/usr/local/include/ecore-imf-1 -I/usr/local/include/ethumb-client-1 -I/usr/local/include/ethumb-1 -I/usr/local/include/edje-1 -I/usr/local/include/ecore-audio-1 -I/usr/local/include/embryo-1 -I/usr/local/include/ecore-imf-evas-1 -I/usr/local/include/ecore-evas-1 -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -O0 -g -DHAVE_CONFIG_H=1 -pthread -MMD -MQ 'e_gadget_wireless@exe/src_connman.c.o' -MF 'e_gadget_wireless@exe/src_connman.c.o.d' -o 'e_gadget_wireless@exe/src_connman.c.o' -c ../src/connman.c",
10 "file": "../src/connman.c"
11 }
12]
diff --git a/build/config.h b/build/config.h
new file mode 100644
index 0000000..ff50683
--- /dev/null
+++ b/build/config.h
@@ -0,0 +1,33 @@
1/*
2 * Autogenerated by the Meson build system.
3 * Do not edit, your changes will be lost.
4 */
5
6#pragma once
7
8#define BINDIR "/usr/local/bin"
9
10#define DATADIR "/usr/local/share"
11
12#define MODULE_ARCH "linux-gnu-x86_64-ver-0.22"
13
14#define PACKAGE "wireless"
15
16#define PACKAGE_NAME "wireless"
17
18#define PACKAGE_VERSION "1.1.99"
19
20#define THEMEDIR "/usr/local/lib64/enlightenment/gadgets/ver-0.22/wireless"
21
22#define VERSION "1.1.99"
23
24#define _ALL_SOURCE 1
25
26#define _GNU_SOURCE 1
27
28#define _POSIX_PTHREAD_SEMANTICS 1
29
30#define _TANDEM_SOURCE 1
31
32#define __EXTENSIONS__ 1
33
diff --git a/build/e_gadget_wireless b/build/e_gadget_wireless
new file mode 100755
index 0000000..bb10daf
--- /dev/null
+++ b/build/e_gadget_wireless
Binary files differ
diff --git a/build/e_gadget_wireless@exe/src_connman.c.o b/build/e_gadget_wireless@exe/src_connman.c.o
new file mode 100644
index 0000000..496928b
--- /dev/null
+++ b/build/e_gadget_wireless@exe/src_connman.c.o
Binary files differ
diff --git a/build/e_gadget_wireless@exe/src_wireless.c.o b/build/e_gadget_wireless@exe/src_wireless.c.o
new file mode 100644
index 0000000..458b8f4
--- /dev/null
+++ b/build/e_gadget_wireless@exe/src_wireless.c.o
Binary files differ
diff --git a/build/meson-logs/install-log.txt b/build/meson-logs/install-log.txt
new file mode 100644
index 0000000..b1971a8
--- /dev/null
+++ b/build/meson-logs/install-log.txt
@@ -0,0 +1,6 @@
1# List of files installed by Meson
2# Does not contain files installed by custom scripts.
3/usr/local/lib64/enlightenment/gadgets/ver-0.22/wireless/e_gadget_wireless
4/usr/local/lib64/enlightenment/gadgets/ver-0.22/wireless/wireless.edj
5/usr/local/lib64/enlightenment/gadgets/ver-0.22/wireless/wireless.desktop
6/usr/local/share/icons/wireless.png
diff --git a/build/meson-logs/meson-log.txt b/build/meson-logs/meson-log.txt
new file mode 100644
index 0000000..28d0aa7
--- /dev/null
+++ b/build/meson-logs/meson-log.txt
@@ -0,0 +1,81 @@
1Build started at 2017-10-17T15:28:06.434914
2Python binary: /usr/bin/python3
3Python system: Linux
4The Meson build system
5Version: 0.42.0
6Source dir: /home/stephen/code/wireless
7Build dir: /home/stephen/code/wireless/build
8Build type: native build
9Project name: wireless
10Sanity testing C compiler: cc
11Is cross compiler: False.
12Sanity check compiler command line: cc /home/stephen/code/wireless/build/meson-private/sanitycheckc.c -o /home/stephen/code/wireless/build/meson-private/sanitycheckc.exe
13Sanity check compile stdout:
14
15-----
16Sanity check compile stderr:
17
18-----
19Running test binary command: /home/stephen/code/wireless/build/meson-private/sanitycheckc.exe
20Native C compiler: cc (gcc 7.1.1)
21Build machine cpu family: x86_64
22Build machine cpu: x86_64
23Running compile:
24Working directory: /tmp/tmp4alpwtte
25Command line: cc /tmp/tmp4alpwtte/testfile.c -O0 -std=gnu99 -pipe -D_FILE_OFFSET_BITS=64 -c -o /tmp/tmp4alpwtte/output.obj
26
27Code:
28
29 #include <features.h>
30 int main () {
31 /* If it's not defined as a macro, try to use as a symbol */
32 #ifndef __UCLIBC__
33 __UCLIBC__;
34 #endif
35 }
36Compiler stdout:
37
38Compiler stderr:
39 /tmp/tmp4alpwtte/testfile.c: In function ‘main’:
40/tmp/tmp4alpwtte/testfile.c:6:17: error: ‘__UCLIBC__’ undeclared (first use in this function); did you mean ‘__GLIBC__’?
41 __UCLIBC__;
42 ^~~~~~~~~~
43 __GLIBC__
44/tmp/tmp4alpwtte/testfile.c:6:17: note: each undeclared identifier is reported only once for each function it appears in
45
46Header <features.h> has symbol "__UCLIBC__": NO
47Running compile:
48Working directory: /tmp/tmpilqnuyyo
49Command line: cc /tmp/tmpilqnuyyo/testfile.c -O0 -std=gnu99 -pipe -D_FILE_OFFSET_BITS=64 -c -o /tmp/tmpilqnuyyo/output.obj
50
51Code:
52
53 #include <features.h>
54 int main () {
55 /* If it's not defined as a macro, try to use as a symbol */
56 #ifndef __dietlibc__
57 __dietlibc__;
58 #endif
59 }
60Compiler stdout:
61
62Compiler stderr:
63 /tmp/tmpilqnuyyo/testfile.c: In function ‘main’:
64/tmp/tmpilqnuyyo/testfile.c:6:17: error: ‘__dietlibc__’ undeclared (first use in this function); did you mean ‘__divtc3’?
65 __dietlibc__;
66 ^~~~~~~~~~~~
67 __divtc3
68/tmp/tmpilqnuyyo/testfile.c:6:17: note: each undeclared identifier is reported only once for each function it appears in
69
70Header <features.h> has symbol "__dietlibc__": NO
71Program edje_cc found: YES (/usr/local/bin/edje_cc)
72Found pkg-config: /usr/bin/pkg-config (1.3.8)
73Determining dependency 'enlightenment' with pkg-config executable '/usr/bin/pkg-config'
74Native dependency enlightenment found: YES 0.21.99.23146
75Determining dependency 'elementary' with pkg-config executable '/usr/bin/pkg-config'
76Native dependency elementary found: YES 1.20.99.55838
77Got pkgconfig variable release : ver-0.22
78Configuring wireless.desktop using configuration
79Configuring config.h using configuration
80Program perms.sh found: YES (/bin/sh /home/stephen/code/wireless/perms.sh)
81Build targets in project: 2
diff --git a/build/meson-private/build.dat b/build/meson-private/build.dat
new file mode 100644
index 0000000..bf763b2
--- /dev/null
+++ b/build/meson-private/build.dat
Binary files differ
diff --git a/build/meson-private/cleantrees.dat b/build/meson-private/cleantrees.dat
new file mode 100644
index 0000000..336bba9
--- /dev/null
+++ b/build/meson-private/cleantrees.dat
Binary files differ
diff --git a/build/meson-private/coredata.dat b/build/meson-private/coredata.dat
new file mode 100644
index 0000000..3d68762
--- /dev/null
+++ b/build/meson-private/coredata.dat
Binary files differ
diff --git a/build/meson-private/install.dat b/build/meson-private/install.dat
new file mode 100644
index 0000000..64b94b6
--- /dev/null
+++ b/build/meson-private/install.dat
Binary files differ
diff --git a/build/meson-private/meson_benchmark_setup.dat b/build/meson-private/meson_benchmark_setup.dat
new file mode 100644
index 0000000..482c0e3
--- /dev/null
+++ b/build/meson-private/meson_benchmark_setup.dat
Binary files differ
diff --git a/build/meson-private/meson_test_setup.dat b/build/meson-private/meson_test_setup.dat
new file mode 100644
index 0000000..482c0e3
--- /dev/null
+++ b/build/meson-private/meson_test_setup.dat
Binary files differ
diff --git a/build/meson-private/sanitycheckc.c b/build/meson-private/sanitycheckc.c
new file mode 100644
index 0000000..d267288
--- /dev/null
+++ b/build/meson-private/sanitycheckc.c
@@ -0,0 +1 @@
int main(int argc, char **argv) { int class=0; return class; }
diff --git a/build/meson-private/sanitycheckc.exe b/build/meson-private/sanitycheckc.exe
new file mode 100755
index 0000000..50362c8
--- /dev/null
+++ b/build/meson-private/sanitycheckc.exe
Binary files differ
diff --git a/build/wireless.desktop b/build/wireless.desktop
new file mode 100644
index 0000000..6888d4c
--- /dev/null
+++ b/build/wireless.desktop
@@ -0,0 +1,5 @@
1[Desktop Entry]
2Type=Application
3Name=Wireless
4Exec=/usr/local/lib64/enlightenment/gadgets/ver-0.22/wireless/e_gadget_wireless
5Icon=/usr/local/share/icons/wireless.png
diff --git a/build/wireless.edj b/build/wireless.edj
new file mode 100644
index 0000000..907b88e
--- /dev/null
+++ b/build/wireless.edj
Binary files differ
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..dbb4808
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,100 @@
1project('wireless', 'c',
2 version: '1.1.99',
3 license: 'BSD 2 clause',
4 default_options: [ 'c_std=gnu99', 'warning_level=2' ],
5 meson_version: '>= 0.40.0')
6
7add_global_arguments('-DHAVE_CONFIG_H=1', language: 'c')
8dir_prefix = get_option('prefix')
9dir_bin = join_paths(dir_prefix, get_option('bindir'))
10dir_sysconf = get_option('sysconfdir')
11dir_data = join_paths(dir_prefix, get_option('datadir'))
12dir_include = join_paths(dir_prefix, get_option('includedir'))
13dir_include_e = join_paths(dir_include, meson.project_name())
14dir_lib = join_paths(dir_prefix, get_option('libdir'))
15
16pkgconfig = import('pkgconfig')
17cc = meson.get_compiler('c')
18
19release = 'ver-0.22'
20host_os = host_machine.system()
21if host_os == 'linux'
22 if cc.has_header_symbol('features.h', '__UCLIBC__')
23 host_os = 'linux-uclibc'
24 elif cc.has_header_symbol('features.h', '__dietlibc__')
25 host_os = 'linux-dietlibc'
26 else
27 host_os = 'linux-gnu'
28 endif
29endif
30
31module_arch = '@0@-@1@-@2@'.format(host_os, host_machine.cpu_family(), release)
32edje_cmd = find_program('edje_cc')
33
34dep_e = dependency('enlightenment')
35deps = [
36 dep_e,
37 dependency('elementary'),
38]
39dir_gadgets = join_paths([dir_lib, 'enlightenment/gadgets', dep_e.get_pkgconfig_variable('release')])
40
41config_h = configuration_data()
42config_h.set('_GNU_SOURCE', '1')
43config_h.set('_ALL_SOURCE', '1')
44config_h.set('_POSIX_PTHREAD_SEMANTICS', '1')
45config_h.set('_TANDEM_SOURCE', '1')
46config_h.set('__EXTENSIONS__', '1')
47
48config_h.set_quoted('MODULE_ARCH', module_arch)
49config_h.set_quoted('PACKAGE', meson.project_name())
50config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
51config_h.set_quoted('VERSION', meson.project_version())
52config_h.set_quoted('PACKAGE_NAME', meson.project_name())
53config_h.set_quoted('BINDIR', dir_bin)
54config_h.set_quoted('DATADIR', dir_data)
55config_h.set_quoted('THEMEDIR', join_paths([dir_gadgets, 'wireless']))
56
57build_files = [
58 'src/wireless.h',
59 'src/wireless.c',
60 'src/connman.c'
61]
62
63inc = include_directories('.', '../../')
64
65executable('e_gadget_wireless',
66 build_files,
67 include_directories: inc,
68 dependencies: deps,
69 install_dir: join_paths([dir_gadgets, 'wireless']),
70 install: true)
71
72desktop_data = configuration_data()
73 desktop_data.set('GADGET_DIR', dir_gadgets)
74 desktop_data.set('DATA_DIR', dir_data)
75
76configure_file(input: 'wireless.desktop.in',
77 output: 'wireless.desktop',
78 install: true,
79 install_dir: join_paths([dir_gadgets, 'wireless']),
80 configuration: desktop_data)
81
82install_data('wireless.png',
83 install_dir: join_paths(dir_data, 'icons'))
84
85configure_file(output: 'config.h',
86 install: false,
87 configuration: config_h)
88
89cmd = [ edje_cmd,
90 '-id', join_paths(meson.source_root(), 'theme'),
91 '@INPUT@', '@OUTPUT@'
92 ]
93custom_target('wireless.edj',
94 input : 'theme/wireless.edc',
95 output : 'wireless.edj',
96 command : cmd,
97 install_dir: join_paths(dir_gadgets, 'wireless'),
98 install : true
99 )
100meson.add_install_script('perms.sh', join_paths([dir_gadgets, 'wireless']))
diff --git a/perms.sh b/perms.sh
new file mode 100644
index 0000000..1a25fc2
--- /dev/null
+++ b/perms.sh
@@ -0,0 +1,3 @@
1#!/bin/sh
2
3chmod a+r "$1/wireless.edj"
diff --git a/src/connman.c b/src/connman.c
new file mode 100644
index 0000000..b548796
--- /dev/null
+++ b/src/connman.c
@@ -0,0 +1,1684 @@
1#include "wireless.h"
2
3#define CONNMAN_BUS_NAME "net.connman"
4#define CONNMAN_MANAGER_IFACE CONNMAN_BUS_NAME ".Manager"
5#define CONNMAN_SERVICE_IFACE CONNMAN_BUS_NAME ".Service"
6#define CONNMAN_TECHNOLOGY_IFACE CONNMAN_BUS_NAME ".Technology"
7#define CONNMAN_TECHNOLOGY_PATH_ETHERNET "/net/connman/technology/ethernet"
8#define CONNMAN_TECHNOLOGY_PATH_WIFI "/net/connman/technology/wifi"
9#define CONNMAN_TECHNOLOGY_PATH_BT "/net/connman/technology/bluetooth"
10#define CONNMAN_TECHNOLOGY_PATH_CELLULAR "/net/connman/technology/cellular"
11#define CONNMAN_AGENT_IFACE "net.connman.Agent"
12#define CONNMAN_AGENT_PATH "/org/enlightenment/wireless/agent"
13
14#define CONNMAN_SERVICE_TYPE_ITER(i) \
15 for ((i) = 0; (i) < CONNMAN_SERVICE_TYPE_LAST; (i)++)
16
17#define MILLI_PER_SEC 1000
18#define CONNMAN_CONNECTION_TIMEOUT 60 * MILLI_PER_SEC
19
20#undef DBG
21#undef INF
22#undef WRN
23#undef ERR
24#undef CRI
25
26#define DBG(...) EINA_LOG_DOM_DBG(_connman_log_dom, __VA_ARGS__)
27#define INF(...) EINA_LOG_DOM_INFO(_connman_log_dom, __VA_ARGS__)
28#define WRN(...) EINA_LOG_DOM_WARN(_connman_log_dom, __VA_ARGS__)
29#define ERR(...) EINA_LOG_DOM_ERR(_connman_log_dom, __VA_ARGS__)
30#define CRI(...) EINA_LOG_DOM_CRIT(_connman_log_dom, __VA_ARGS__)
31
32typedef enum
33{
34 CONNMAN_STATE_NONE = -1, /* All unknown states */
35 CONNMAN_STATE_OFFLINE,
36 CONNMAN_STATE_IDLE,
37 CONNMAN_STATE_ASSOCIATION,
38 CONNMAN_STATE_CONFIGURATION,
39 CONNMAN_STATE_READY,
40 CONNMAN_STATE_ONLINE,
41 CONNMAN_STATE_DISCONNECT,
42 CONNMAN_STATE_FAILURE,
43} Connman_State;
44
45typedef enum
46{
47 CONNMAN_SERVICE_TYPE_NONE = -1, /* All non-supported types */
48 CONNMAN_SERVICE_TYPE_ETHERNET = 0,
49 CONNMAN_SERVICE_TYPE_WIFI = 1,
50 CONNMAN_SERVICE_TYPE_BLUETOOTH = 2,
51 CONNMAN_SERVICE_TYPE_CELLULAR = 3,
52 CONNMAN_SERVICE_TYPE_LAST = 4,
53} Connman_Service_Type;
54
55typedef struct Connman_Technology
56{
57 Connman_Service_Type type;
58 Eldbus_Proxy *proxy;
59 Eina_Stringshare *tethering_ssid;
60 Eina_Stringshare *tethering_passwd;
61 Eina_Bool powered : 1;
62 Eina_Bool connected : 1;
63 Eina_Bool tethering : 1;
64} Connman_Technology;
65
66typedef struct
67{
68 EINA_INLIST;
69 Eldbus_Proxy *proxy;
70
71 /* Private */
72 struct
73 {
74 Eldbus_Pending *connect;
75 Eldbus_Pending *disconnect;
76 Eldbus_Pending *remov;
77 void *data;
78 } pending;
79 Eldbus_Signal_Handler *handler;
80
81 /* Properties */
82 Eina_Stringshare *path;
83 Eina_Stringshare *name;
84 Wireless_Network_Security security;
85 Connman_State state;
86 Connman_Service_Type type;
87 uint8_t strength;
88
89 /* Connection */
90 unsigned int method;
91 Eina_Stringshare *address;
92 Eina_Stringshare *gateway;
93 union
94 {
95 struct
96 {
97 Eina_Stringshare *netmask;
98 } v4;
99 struct
100 {
101 Eina_Stringshare *prefixlength;
102 Wireless_Network_IPv6_Privacy privacy;
103 } v6;
104 } ip;
105
106 Eina_Array *domain_servers;
107 Eina_Array *name_servers;
108 Eina_Array *time_servers;
109
110 /* Proxy */
111 unsigned int proxy_type;
112 Eina_Stringshare *proxy_url;
113 Eina_Array *proxy_servers;
114 Eina_Array *proxy_excludes;
115 Eina_Bool ipv6 : 1;
116 Eina_Bool favorite : 1;
117} Connman_Service;
118
119typedef enum
120{
121 CONNMAN_FIELD_STATE_MANDATORY,
122 CONNMAN_FIELD_STATE_OPTIONAL,
123 CONNMAN_FIELD_STATE_ALTERNATE,
124 CONNMAN_FIELD_STATE_INFO,
125} Connman_Field_State;
126
127typedef struct Connman_Field
128{
129 const char *name;
130
131 Connman_Field_State requirement;
132 const char *type;
133 const char *value;
134} Connman_Field;
135
136static int _connman_log_dom = -1;
137
138static Eldbus_Proxy *proxy_manager;
139
140static Eldbus_Pending *pending_gettechnologies;
141static Eldbus_Pending *pending_getservices;
142static Eldbus_Pending *pending_getproperties_manager;
143
144static Eina_List *signal_handlers;
145
146static Eina_Inlist *connman_services_list[CONNMAN_SERVICE_TYPE_LAST];
147static Eina_Hash *connman_services[CONNMAN_SERVICE_TYPE_LAST];
148static Eldbus_Service_Interface *agent_iface;
149
150static Connman_Service *connman_current_service[CONNMAN_SERVICE_TYPE_LAST];
151static Wireless_Connection *connman_current_connection[CONNMAN_SERVICE_TYPE_LAST];
152
153static Connman_Technology connman_technology[CONNMAN_SERVICE_TYPE_LAST];
154
155/* connman -> wireless */
156static Eina_Hash *connman_services_map[CONNMAN_SERVICE_TYPE_LAST];
157
158static inline Eina_Bool
159_connman_service_is_connected(const Connman_Service *cs)
160{
161 return (cs->state >= CONNMAN_STATE_ASSOCIATION) && (cs->state <= CONNMAN_STATE_ONLINE);
162}
163
164static void
165_eldbus_proxy_del(Eldbus_Proxy *proxy)
166{
167 Eldbus_Object *obj;
168
169 obj = eldbus_proxy_object_get(proxy);
170 eldbus_proxy_unref(proxy);
171 eldbus_object_unref(obj);
172}
173
174static void
175_connman_service_connect_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
176{
177 Connman_Service *cs = data;
178 const char *error;
179
180 /* FIXME */
181 cs->pending.connect = NULL;
182 eldbus_message_error_get(msg, NULL, &error);
183}
184
185static Eina_Bool
186_connman_service_connect(Wireless_Network *wn)
187{
188 Connman_Service *cs;
189
190 cs = eina_hash_find(connman_services[wn->type], wn->path);
191 EINA_SAFETY_ON_NULL_RETURN_VAL(cs, EINA_FALSE);
192 if (!cs->pending.connect)
193 cs->pending.connect = eldbus_proxy_call(cs->proxy, "Connect",
194 _connman_service_connect_cb, cs,
195 CONNMAN_CONNECTION_TIMEOUT, "");
196 return !!cs->pending.connect;
197}
198
199static void
200_connman_update_technologies(void)
201{
202 Eina_Bool avail[CONNMAN_SERVICE_TYPE_LAST];
203 int i;
204
205 CONNMAN_SERVICE_TYPE_ITER(i)
206 avail[i] = connman_technology[i].type > -1;
207 wireless_service_type_available_set(avail);
208}
209
210static void
211_connman_update_enabled_technologies(void)
212{
213 Eina_Bool enabled[CONNMAN_SERVICE_TYPE_LAST];
214 int i;
215
216 CONNMAN_SERVICE_TYPE_ITER(i)
217 enabled[i] = connman_technology[i].powered;
218 wireless_service_type_enabled_set(enabled);
219}
220
221static Wireless_Network_State
222_connman_wifi_state_convert(Connman_State state)
223{
224 Wireless_Network_State wifi_state;
225 switch (state)
226 {
227 case CONNMAN_STATE_ASSOCIATION:
228 case CONNMAN_STATE_CONFIGURATION:
229 wifi_state = WIRELESS_NETWORK_STATE_CONFIGURING;
230 break;
231 case CONNMAN_STATE_READY:
232 wifi_state = WIRELESS_NETWORK_STATE_CONNECTED;
233 break;
234 case CONNMAN_STATE_ONLINE:
235 wifi_state = WIRELESS_NETWORK_STATE_ONLINE;
236 break;
237 case CONNMAN_STATE_FAILURE:
238 wifi_state = WIRELESS_NETWORK_STATE_FAILURE;
239 break;
240 case CONNMAN_STATE_NONE:
241 case CONNMAN_STATE_OFFLINE:
242 case CONNMAN_STATE_IDLE:
243 case CONNMAN_STATE_DISCONNECT:
244 default:
245 wifi_state = WIRELESS_NETWORK_STATE_NONE;
246 }
247 return wifi_state;
248}
249
250static Wireless_Network *
251_connman_service_convert(Connman_Service *cs)
252{
253 Wireless_Network *wn;
254
255 wn = calloc(1, sizeof(Wireless_Network));
256 wn->path = cs->path;
257 wn->name = cs->name;
258 wn->security = cs->security;
259 wn->state = _connman_wifi_state_convert(cs->state);
260 wn->type = cs->type;
261 wn->strength = cs->strength;
262 wn->connect_cb = _connman_service_connect;
263 return wn;
264}
265
266static void
267_connman_update_current_network(Connman_Service *cs, Connman_Service_Type type)
268{
269 if (connman_current_service[type] != cs)
270 {
271 free(connman_current_connection[type]);
272 connman_current_connection[type] = NULL;
273 if (cs)
274 connman_current_connection[type] = calloc(1, sizeof(Wireless_Connection));
275 }
276 connman_current_service[type] = cs;
277 if (cs)
278 {
279 connman_current_connection[type]->wn = eina_hash_find(connman_services_map[type], &cs);
280 memcpy(&connman_current_connection[type]->method,
281 &cs->method, sizeof(Wireless_Connection) - sizeof(void*));
282 }
283 else
284 connman_current_connection[type] = NULL;
285 wireless_wifi_current_networks_set(connman_current_connection);
286}
287
288static void
289_connman_update_networks(Connman_Service_Type type)
290{
291 Eina_Array *arr;
292 Connman_Service *cs;
293 Wireless_Network *wn;
294 Eina_Hash *map;
295 Connman_Service *services[CONNMAN_SERVICE_TYPE_LAST] = {NULL};
296
297 map = connman_services_map[type];
298 connman_services_map[type] = eina_hash_pointer_new(free);
299 arr = eina_array_new(eina_hash_population(connman_services[type]));
300 EINA_INLIST_FOREACH(connman_services_list[type], cs)
301 {
302 wn = _connman_service_convert(cs);
303 eina_hash_add(connman_services_map[type], &cs, wn);
304 eina_array_push(arr, wn);
305 if (connman_current_service[type] && _connman_service_is_connected(cs))
306 services[type] = cs;
307 }
308 memcpy(&connman_current_service, services, CONNMAN_SERVICE_TYPE_LAST * sizeof(void*));
309 arr = wireless_networks_set(arr);
310 _connman_update_current_network(connman_current_service[type], type);
311 eina_hash_free(map);
312 eina_array_free(arr);
313}
314
315static void
316_connman_update_airplane_mode(Eina_Bool offline)
317{
318 wireless_airplane_mode_set(offline);
319}
320
321static Connman_State
322str_to_state(const char *s)
323{
324 if (!strcmp(s, "offline"))
325 return CONNMAN_STATE_OFFLINE;
326 if (!strcmp(s, "idle"))
327 return CONNMAN_STATE_IDLE;
328 if (!strcmp(s, "association"))
329 return CONNMAN_STATE_ASSOCIATION;
330 if (!strcmp(s, "configuration"))
331 return CONNMAN_STATE_CONFIGURATION;
332 if (!strcmp(s, "ready"))
333 return CONNMAN_STATE_READY;
334 if (!strcmp(s, "online"))
335 return CONNMAN_STATE_ONLINE;
336 if (!strcmp(s, "disconnect"))
337 return CONNMAN_STATE_DISCONNECT;
338 if (!strcmp(s, "failure"))
339 return CONNMAN_STATE_FAILURE;
340
341 ERR("Unknown state %s", s);
342 return CONNMAN_STATE_NONE;
343}
344
345static Connman_Service_Type
346str_to_type(const char *s)
347{
348 if (!strcmp(s, "ethernet"))
349 return CONNMAN_SERVICE_TYPE_ETHERNET;
350 if (!strcmp(s, "wifi"))
351 return CONNMAN_SERVICE_TYPE_WIFI;
352 if (!strcmp(s, "bluetooth"))
353 return CONNMAN_SERVICE_TYPE_BLUETOOTH;
354 if (!strcmp(s, "cellular"))
355 return CONNMAN_SERVICE_TYPE_CELLULAR;
356
357 DBG("Unknown type %s", s);
358 return CONNMAN_SERVICE_TYPE_NONE;
359}
360
361static Wireless_Network_Security
362str_to_security(const char *s)
363{
364 if (!strcmp(s, "none")) return WIRELESS_NETWORK_SECURITY_NONE;
365 if (!strcmp(s, "wep")) return WIRELESS_NETWORK_SECURITY_WEP;
366 if (!strcmp(s, "psk")) return WIRELESS_NETWORK_SECURITY_PSK;
367 if (!strcmp(s, "ieee8021x")) return WIRELESS_NETWORK_SECURITY_IEEE8021X;
368 if (!strcmp(s, "wps")) return WIRELESS_NETWORK_SECURITY_WPS;
369 CRI("UNKNOWN TYPE %s", s);
370 return WIRELESS_NETWORK_SECURITY_NONE;
371}
372
373static void
374_connman_service_free(Connman_Service *cs)
375{
376 if (!cs) return;
377
378 if (cs->pending.connect)
379 {
380 eldbus_pending_cancel(cs->pending.connect);
381 free(cs->pending.data);
382 }
383 else if (cs->pending.disconnect)
384 {
385 eldbus_pending_cancel(cs->pending.disconnect);
386 free(cs->pending.data);
387 }
388 else if (cs->pending.remov)
389 {
390 eldbus_pending_cancel(cs->pending.remov);
391 free(cs->pending.data);
392 }
393 eina_stringshare_del(cs->address);
394 eina_stringshare_del(cs->gateway);
395 if (cs->ipv6)
396 eina_stringshare_del(cs->ip.v6.prefixlength);
397 else
398 eina_stringshare_del(cs->ip.v4.netmask);
399
400 eina_stringshare_del(cs->proxy_url);
401
402 array_clear(cs->domain_servers);
403 array_clear(cs->name_servers);
404 array_clear(cs->time_servers);
405
406 array_clear(cs->proxy_servers);
407 array_clear(cs->proxy_excludes);
408
409 eina_stringshare_del(cs->name);
410 eina_stringshare_del(cs->path);
411 eldbus_signal_handler_del(cs->handler);
412 DBG("service free %p || proxy %p", cs, cs->proxy);
413 _eldbus_proxy_del(cs->proxy);
414 connman_services_list[cs->type] = eina_inlist_remove(connman_services_list[cs->type], EINA_INLIST_GET(cs));
415
416 free(cs);
417}
418
419static void
420_connman_service_parse_stringarray(Eldbus_Message_Iter *value, Eina_Array **arr)
421{
422 Eldbus_Message_Iter *itr_array;
423 const char *s;
424
425 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value, "as",
426 &itr_array));
427 if (*arr)
428 {
429 while (eina_array_count(*arr))
430 eina_stringshare_del(eina_array_pop(*arr));
431 }
432 else
433 *arr = eina_array_new(1);
434 while (eldbus_message_iter_get_and_next(itr_array, 's', &s))
435 eina_array_push(*arr, eina_stringshare_add(s));
436}
437
438static void
439_connman_service_parse_prop_changed(Connman_Service *cs, const char *prop_name, Eldbus_Message_Iter *value)
440{
441 DBG("service %p %s prop %s", cs, cs->path, prop_name);
442
443 if (!strcmp(prop_name, "State"))
444 {
445 const char *state;
446 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value,
447 "s",
448 &state));
449 cs->state = str_to_state(state);
450 DBG("New state: %s %d", state, cs->state);
451 }
452 if (!strcmp(prop_name, "Favorite"))
453 {
454 Eina_Bool state;
455 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value,
456 "b",
457 &state));
458 cs->favorite = !!state;
459 DBG("New favorite state: %d", cs->favorite);
460 }
461 else if (!strcmp(prop_name, "Name"))
462 {
463 const char *name;
464 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value,
465 "s",
466 &name));
467 eina_stringshare_replace(&cs->name, name);
468 DBG("New name: %s", cs->name);
469 }
470 else if (!strcmp(prop_name, "Type"))
471 {
472 const char *type;
473 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value,
474 "s",
475 &type));
476 cs->type = str_to_type(type);
477 DBG("New type: %s %d", type, cs->type);
478 }
479 else if (!strcmp(prop_name, "Strength"))
480 {
481 uint8_t strength;
482 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value,
483 "y",
484 &strength));
485 cs->strength = strength;
486 DBG("New strength: %d", strength);
487 }
488 else if (!strcmp(prop_name, "Security"))
489 {
490 const char *s;
491 Eldbus_Message_Iter *itr_array;
492
493 DBG("Old security: %u", cs->security);
494 cs->security = WIRELESS_NETWORK_SECURITY_NONE;
495
496 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value, "as",
497 &itr_array));
498 while (eldbus_message_iter_get_and_next(itr_array, 's', &s))
499 cs->security |= str_to_security(s);
500 DBG("New security %u", cs->security);
501 }
502 else if (!strcmp(prop_name, "IPv4"))
503 {
504 Eldbus_Message_Iter *array, *dict;
505
506 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value, "a{sv}", &array));
507 while (eldbus_message_iter_get_and_next(array, 'e', &dict))
508 {
509 Eldbus_Message_Iter *var;
510 const char *name, *val;
511
512 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(dict, "sv", &name, &var));
513 if (!strcmp(name, "Method"))
514 {
515 cs->method = WIRELESS_NETWORK_IPV4_METHOD_OFF;
516 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
517 if (!strcmp(val, "off"))
518 cs->method = WIRELESS_NETWORK_IPV4_METHOD_OFF;
519 else if (!strcmp(val, "dhcp"))
520 cs->method = WIRELESS_NETWORK_IPV4_METHOD_DHCP;
521 else if (!strcmp(val, "manual"))
522 cs->method = WIRELESS_NETWORK_IPV4_METHOD_MANUAL;
523 else if (!strcmp(val, "fixed"))
524 cs->method = WIRELESS_NETWORK_IPV4_METHOD_FIXED;
525 }
526 else if (!strcmp(name, "Address"))
527 {
528 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
529 eina_stringshare_replace(&cs->address, val);
530 }
531 else if (!strcmp(name, "Netmask"))
532 {
533 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
534 eina_stringshare_replace(&cs->ip.v4.netmask, val);
535 }
536 else if (!strcmp(name, "Gateway"))
537 {
538 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
539 eina_stringshare_replace(&cs->gateway, val);
540 }
541 }
542 }
543 else if (!strcmp(prop_name, "IPv6"))
544 {
545 Eldbus_Message_Iter *array, *dict;
546
547 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value, "a{sv}", &array));
548 while (eldbus_message_iter_get_and_next(array, 'e', &dict))
549 {
550 Eldbus_Message_Iter *var;
551 const char *name, *val;
552
553 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(dict, "sv", &name, &var));
554 if (!strcmp(name, "Method"))
555 {
556 cs->method = WIRELESS_NETWORK_IPV6_METHOD_OFF;
557 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
558 if (!strcmp(val, "auto"))
559 cs->method = WIRELESS_NETWORK_IPV6_METHOD_AUTO;
560 else if (!strcmp(val, "manual"))
561 cs->method = WIRELESS_NETWORK_IPV6_METHOD_MANUAL;
562 else if (!strcmp(val, "6to4"))
563 cs->method = WIRELESS_NETWORK_IPV6_METHOD_6TO4;
564 else if (!strcmp(val, "fixed"))
565 cs->method = WIRELESS_NETWORK_IPV6_METHOD_FIXED;
566 }
567 else if (!strcmp(name, "Privacy"))
568 {
569 cs->ip.v6.privacy = WIRELESS_NETWORK_IPV6_PRIVACY_DISABLED;
570 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
571 if (!strcmp(val, "disabled"))
572 cs->ip.v6.privacy = WIRELESS_NETWORK_IPV6_PRIVACY_DISABLED;
573 else if (!strcmp(val, "enabled"))
574 cs->ip.v6.privacy = WIRELESS_NETWORK_IPV6_PRIVACY_ENABLED;
575 else if (!strcmp(val, "preferred"))
576 cs->ip.v6.privacy = WIRELESS_NETWORK_IPV6_PRIVACY_PREFERRED;
577 }
578 else if (!strcmp(name, "Address"))
579 {
580 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
581 eina_stringshare_replace(&cs->address, val);
582 }
583 else if (!strcmp(name, "PrefixLength"))
584 {
585 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
586 eina_stringshare_replace(&cs->ip.v6.prefixlength, val);
587 }
588 else if (!strcmp(name, "Gateway"))
589 {
590 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
591 eina_stringshare_replace(&cs->gateway, val);
592 }
593 }
594 }
595 else if (!strcmp(prop_name, "Proxy"))
596 {
597 Eldbus_Message_Iter *array, *dict;
598
599 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(value, "a{sv}", &array));
600 while (eldbus_message_iter_get_and_next(array, 'e', &dict))
601 {
602 Eldbus_Message_Iter *var;
603 const char *name, *val;
604
605 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(dict, "sv", &name, &var));
606 if (!strcmp(name, "Method"))
607 {
608 cs->proxy_type = WIRELESS_PROXY_TYPE_DIRECT;
609 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
610 if (!strcmp(val, "manual"))
611 cs->proxy_type = WIRELESS_PROXY_TYPE_MANUAL;
612 else if (!strcmp(val, "auto"))
613 cs->proxy_type = WIRELESS_PROXY_TYPE_AUTO;
614 }
615 else if (!strcmp(name, "URL"))
616 {
617 EINA_SAFETY_ON_FALSE_RETURN(eldbus_message_iter_arguments_get(var, "s", &val));
618 eina_stringshare_replace(&cs->proxy_url, val);
619 }
620 else if (!strcmp(name, "Servers"))
621 _connman_service_parse_stringarray(value, &cs->proxy_servers);
622 else if (!strcmp(name, "Excludes"))
623 _connman_service_parse_stringarray(value, &cs->proxy_excludes);
624 }
625 }
626 else if (!strcmp(prop_name, "Nameservers"))
627 _connman_service_parse_stringarray(value, &cs->name_servers);
628 else if (!strcmp(prop_name, "Timeservers"))
629 _connman_service_parse_stringarray(value, &cs->time_servers);
630 else if (!strcmp(prop_name, "Domains"))
631 _connman_service_parse_stringarray(value, &cs->domain_servers);
632}
633
634static Eina_Bool
635_connman_service_prop_dict_changed(Connman_Service *cs, Eldbus_Message_Iter *props)
636{
637 Eldbus_Message_Iter *dict;
638
639 while (eldbus_message_iter_get_and_next(props, 'e', &dict))
640 {
641 char *name;
642 Eldbus_Message_Iter *var;
643
644 if (eldbus_message_iter_arguments_get(dict, "sv", &name, &var))
645 _connman_service_parse_prop_changed(cs, name, var);
646 }
647 if ((cs->type <= CONNMAN_SERVICE_TYPE_NONE) ||
648 (cs->type >= CONNMAN_SERVICE_TYPE_LAST))
649 return EINA_FALSE;
650 else
651 {
652 if (_connman_service_is_connected(cs))
653 _connman_update_current_network(cs, cs->type);
654 }
655 return EINA_TRUE;
656}
657
658static void
659_connman_service_property(void *data, const Eldbus_Message *msg)
660{
661 Connman_Service *cs = data;
662 Eldbus_Message_Iter *var;
663 const char *name;
664
665 if (eldbus_message_arguments_get(msg, "sv", &name, &var))
666 _connman_service_parse_prop_changed(cs, name, var);
667 if (_connman_service_is_connected(cs))
668 _connman_update_current_network(cs, cs->type);
669}
670
671static Connman_Service *
672_connman_service_new(const char *path, Eldbus_Message_Iter *props)
673{
674 Connman_Service *cs;
675 Eldbus_Object *obj;
676
677 cs = calloc(1, sizeof(Connman_Service));
678 cs->path = eina_stringshare_add(path);
679
680 obj = eldbus_object_get(dbus_conn, CONNMAN_BUS_NAME, path);
681 cs->proxy = eldbus_proxy_get(obj, CONNMAN_SERVICE_IFACE);
682 cs->handler = eldbus_proxy_signal_handler_add(cs->proxy, "PropertyChanged",
683 _connman_service_property, cs);
684
685 if (!_connman_service_prop_dict_changed(cs, props))
686 {
687 ERR("Service added of invalid type");
688 _connman_service_free(cs);
689 return NULL;
690 }
691 connman_services_list[cs->type] = eina_inlist_append(connman_services_list[cs->type], EINA_INLIST_GET(cs));
692 eina_hash_add(connman_services[cs->type], cs->path, cs);
693 DBG("Added service: %p %s || proxy %p", cs, path, cs->proxy);
694 return cs;
695}
696
697static void
698_connman_manager_agent_register(void *data EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED)
699{
700 /* FIXME: should this do something? */
701}
702
703static Eina_Bool
704_connman_technology_parse_prop_changed(Connman_Technology *ct, const char *name, Eldbus_Message_Iter *value)
705{
706 Eina_Bool val;
707 const char *str;
708 Eina_Bool ret = EINA_FALSE;
709
710 if (!strcmp(name, "Powered"))
711 {
712 if (!eldbus_message_iter_arguments_get(value, "b", &val)) goto exit;
713
714 val = !!val;
715 if (val != ct->powered) ret = EINA_TRUE;
716 ct->powered = !!val;
717 }
718 else if (!strcmp(name, "Connected"))
719 {
720 if (!eldbus_message_iter_arguments_get(value, "b", &val)) goto exit;
721 ct->connected = !!val;
722 }
723 else if (!strcmp(name, "Tethering"))
724 {
725 if (!eldbus_message_iter_arguments_get(value, "b", &val)) goto exit;
726 ct->tethering = !!val;
727 }
728 else if (!strcmp(name, "TetheringIdentifier"))
729 {
730 if (!eldbus_message_iter_arguments_get(value, "b", &str)) goto exit;
731 ct->tethering_ssid = eina_stringshare_add(str);
732 }
733 else if (!strcmp(name, "TetheringPassphrase"))
734 {
735 if (!eldbus_message_iter_arguments_get(value, "b", &str)) goto exit;
736 ct->tethering_passwd = eina_stringshare_add(str);
737 }
738 exit:
739 return ret;
740}
741
742static void
743_connman_technology_event_property(void *data, const Eldbus_Message *msg)
744{
745 Eldbus_Message_Iter *var;
746 const char *name;
747 Connman_Technology *ct = NULL;
748 int i;
749
750 CONNMAN_SERVICE_TYPE_ITER(i)
751 if (data == connman_technology[i].proxy)
752 {
753 ct = &connman_technology[i];
754 break;
755 }
756 if (!ct) return;
757
758 if (!eldbus_message_arguments_get(msg, "sv", &name, &var))
759 ERR("Could not parse message %p", msg);
760 else if (_connman_technology_parse_prop_changed(ct, name, var))
761 _connman_update_enabled_technologies();
762}
763
764static Eina_Bool
765_connman_manager_parse_prop_changed(const char *name, Eldbus_Message_Iter *value)
766{
767 if (!strcmp(name, "State"))
768 {
769 const char *state;
770
771 if (!eldbus_message_iter_arguments_get(value, "s", &state))
772 return EINA_FALSE;
773 DBG("New state: %s", state);
774 //_connman_update_state(str_to_state(state));
775 }
776 else if (!strcmp(name, "OfflineMode"))
777 {
778 Eina_Bool offline;
779 if (!eldbus_message_iter_arguments_get(value, "b", &offline))
780 return EINA_FALSE;
781 _connman_update_airplane_mode(offline);
782 }
783 else
784 return EINA_FALSE;
785
786 return EINA_TRUE;
787}
788
789static void
790_connman_manager_getproperties(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
791{
792 Eldbus_Message_Iter *array, *dict;
793 const char *name, *text;
794
795 pending_getproperties_manager = NULL;
796 if (eldbus_message_error_get(msg, &name, &text))
797 {
798 ERR("Could not get properties. %s: %s", name, text);
799 return;
800 }
801
802 if (!eldbus_message_arguments_get(msg, "a{sv}", &array))
803 {
804 ERR("Error getting arguments.");
805 return;
806 }
807
808 while (eldbus_message_iter_get_and_next(array, 'e', &dict))
809 {
810 const char *key;
811 Eldbus_Message_Iter *var;
812
813 if (eldbus_message_iter_arguments_get(dict, "sv", &key, &var))
814 _connman_manager_parse_prop_changed(key, var);
815 }
816}
817
818static void
819_connman_manager_getservices(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
820{
821 Eldbus_Message_Iter *array, *s;
822 const char *name, *text;
823 int i;
824 Eina_Bool update[CONNMAN_SERVICE_TYPE_LAST] = {0};
825
826 pending_getservices = NULL;
827 CONNMAN_SERVICE_TYPE_ITER(i)
828 eina_hash_free_buckets(connman_services[i]);
829 if (eldbus_message_error_get(msg, &name, &text))
830 {
831 ERR("Could not get services. %s: %s", name, text);
832 return;
833 }
834
835 if (!eldbus_message_arguments_get(msg, "a(oa{sv})", &array))
836 {
837 ERR("Error getting array");
838 return;
839 }
840
841 while (eldbus_message_iter_get_and_next(array, 'r', &s))
842 {
843 const char *path;
844 Eldbus_Message_Iter *inner_array;
845 Connman_Service *cs;
846
847 if (!eldbus_message_iter_arguments_get(s, "oa{sv}", &path, &inner_array))
848 continue;
849
850 cs = _connman_service_new(path, inner_array);
851 if (cs) update[cs->type] = 1;
852 }
853 CONNMAN_SERVICE_TYPE_ITER(i)
854 if (update[i]) _connman_update_networks(i);
855}
856
857static void
858_connman_manager_gettechnologies(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
859{
860 Eldbus_Message_Iter *array, *s;
861 const char *name, *text;
862
863 pending_gettechnologies = NULL;
864 if (eldbus_message_error_get(msg, &name, &text))
865 {
866 ERR("Could not get technologies. %s: %s", name, text);
867 return;
868 }
869
870 if (!eldbus_message_arguments_get(msg, "a(oa{sv})", &array))
871 {
872 ERR("Error getting array");
873 return;
874 }
875
876 while (eldbus_message_iter_get_and_next(array, 'r', &s))
877 {
878 const char *path;
879 Eldbus_Message_Iter *inner_array, *dict;
880 Connman_Technology *ct = NULL;
881 Eldbus_Object *obj;
882 int i;
883 const char *paths[] =
884 {
885 CONNMAN_TECHNOLOGY_PATH_ETHERNET,
886 CONNMAN_TECHNOLOGY_PATH_WIFI,
887 CONNMAN_TECHNOLOGY_PATH_BT,
888 CONNMAN_TECHNOLOGY_PATH_CELLULAR,
889 };
890
891 if (!eldbus_message_iter_arguments_get(s, "oa{sv}", &path, &inner_array))
892 continue;
893 CONNMAN_SERVICE_TYPE_ITER(i)
894 {
895 if (strcmp(path, paths[i])) continue;
896 ct = &connman_technology[i];
897 ct->type = i;
898
899 obj = eldbus_object_get(dbus_conn, CONNMAN_BUS_NAME, paths[i]);
900 ct->proxy = eldbus_proxy_get(obj, CONNMAN_TECHNOLOGY_IFACE);
901 signal_handlers = eina_list_append(signal_handlers,
902 eldbus_proxy_signal_handler_add(ct->proxy, "PropertyChanged",
903 _connman_technology_event_property, ct->proxy));
904 }
905 if (!ct)
906 {
907 ERR("No handler for technology: %s", path);
908 continue;
909 }
910 while (eldbus_message_iter_get_and_next(inner_array, 'e', &dict))
911 {
912 Eldbus_Message_Iter *var;
913
914 if (eldbus_message_iter_arguments_get(dict, "sv", &name, &var))
915 _connman_technology_parse_prop_changed(ct, name, var);
916 }
917 }
918 /* scan not supported on bluetooth */
919 if (connman_technology[CONNMAN_SERVICE_TYPE_BLUETOOTH].proxy)
920 pending_getservices = eldbus_proxy_call(proxy_manager, "GetServices", _connman_manager_getservices,
921 NULL, -1, "");
922 else if (connman_technology[CONNMAN_SERVICE_TYPE_WIFI].proxy)
923 eldbus_proxy_call(connman_technology[CONNMAN_SERVICE_TYPE_WIFI].proxy, "Scan", NULL, NULL, -1, "");
924 _connman_update_technologies();
925 _connman_update_enabled_technologies();
926}
927
928static void
929_connman_manager_event_services(void *data EINA_UNUSED, const Eldbus_Message *msg)
930{
931 Eldbus_Message_Iter *changed, *removed, *s;
932 const char *path;
933 int i;
934 Eina_Bool update[CONNMAN_SERVICE_TYPE_LAST] = {0};
935
936 if (pending_getservices) return;
937
938 if (!eldbus_message_arguments_get(msg, "a(oa{sv})ao", &changed, &removed))
939 {
940 ERR("Error getting arguments");
941 return;
942 }
943
944 while (eldbus_message_iter_get_and_next(removed, 'o', &path))
945 {
946 CONNMAN_SERVICE_TYPE_ITER(i)
947 {
948 if (!eina_hash_del_by_key(connman_services[i], path)) continue;
949 DBG("Removed service: %s", path);
950 update[i] = 1;
951 break;
952 }
953 }
954
955 while (eldbus_message_iter_get_and_next(changed, 'r', &s))
956 {
957 Connman_Service *cs;
958 Eldbus_Message_Iter *array;
959 Eina_Bool found = EINA_FALSE;
960
961 if (!eldbus_message_iter_arguments_get(s, "oa{sv}", &path, &array))
962 continue;
963
964 CONNMAN_SERVICE_TYPE_ITER(i)
965 {
966 cs = eina_hash_find(connman_services[i], path);
967 if (!cs) continue;
968 if (!_connman_service_prop_dict_changed(cs, array))
969 {
970 ERR("Service became an invalid type");
971 cs->type = i;
972 _connman_service_free(cs);
973 continue;
974 }
975 found = update[cs->type] = 1;
976 DBG("Changed service: %p %s", cs, path);
977 break;
978 }
979 if (!found)
980 {
981 cs = _connman_service_new(path, array);
982 if (cs) update[cs->type] = 1;
983 }
984 }
985 CONNMAN_SERVICE_TYPE_ITER(i)
986 if (update[i]) _connman_update_networks(i);
987}
988
989static void
990_connman_manager_event_property(void *data EINA_UNUSED, const Eldbus_Message *msg)
991{
992 Eldbus_Message_Iter *var;
993 const char *name;
994
995 if (pending_getproperties_manager) return;
996 if (!eldbus_message_arguments_get(msg, "sv", &name, &var))
997 {
998 ERR("Could not parse message %p", msg);
999 return;
1000 }
1001
1002 _connman_manager_parse_prop_changed(name, var);
1003}
1004
1005static Eldbus_Message *
1006_connman_agent_release(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
1007{
1008 DBG("Agent released");
1009 wireless_authenticate_cancel();
1010 return eldbus_message_method_return_new(msg);
1011}
1012
1013static Eldbus_Message *
1014_connman_agent_report_error(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED)
1015{
1016 const char *path, *err;
1017 //E_Notification_Notify n;
1018
1019 if (!eldbus_message_arguments_get(msg, "ss", &path, &err))
1020 {
1021 ERR("Could not parse message %p", msg);
1022 return NULL;
1023 }
1024 /* TODO: need a generic "sticky" gadget popup */
1025 /*memset(&n, 0, sizeof(E_Notification_Notify));
1026 n.timeout = 3000;
1027 n.summary = _("Connection Error");
1028 n.body = err;
1029 n.urgency = E_NOTIFICATION_NOTIFY_URGENCY_NORMAL;
1030 e_notification_client_send(&n, NULL, NULL);*/
1031
1032 return NULL;
1033}
1034
1035static Eldbus_Message *
1036_connman_agent_request_browser(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
1037{
1038 const char *path, *url;
1039 int i;
1040 Connman_Service *cs;
1041 Wireless_Network *wn;
1042
1043 if (!eldbus_message_arguments_get(msg, "ss", &path, &url))
1044 {
1045 ERR("Could not parse message %p", msg);
1046 return NULL;
1047 }
1048
1049 CONNMAN_SERVICE_TYPE_ITER(i)
1050 {
1051 cs = eina_hash_find(connman_services[i], path);
1052 if (cs) break;
1053 }
1054 if (!cs) return NULL;
1055 wn = eina_hash_find(connman_services_map[i], &cs);
1056 EINA_SAFETY_ON_NULL_RETURN_VAL(wn, NULL);
1057 wireless_authenticate_external(wn, url);
1058 return NULL;
1059}
1060
1061static Eina_Bool
1062_connman_field_parse_value(Connman_Field *field, const char *key, Eldbus_Message_Iter *value, const char *signature)
1063{
1064 if (!strcmp(key, "Type"))
1065 {
1066 EINA_SAFETY_ON_FALSE_RETURN_VAL(signature[0] == 's', EINA_FALSE);
1067 eldbus_message_iter_basic_get(value, &field->type);
1068 return EINA_TRUE;
1069 }
1070
1071 if (!strcmp(key, "Requirement"))
1072 {
1073 const char *req;
1074 const char *types[] =
1075 {
1076 [CONNMAN_FIELD_STATE_MANDATORY] = "mandatory",
1077 [CONNMAN_FIELD_STATE_OPTIONAL] = "optional",
1078 [CONNMAN_FIELD_STATE_ALTERNATE] = "alternate",
1079 [CONNMAN_FIELD_STATE_INFO] = "informational",
1080 };
1081 int i;
1082 EINA_SAFETY_ON_FALSE_RETURN_VAL(signature[0] == 's', EINA_FALSE);
1083 eldbus_message_iter_basic_get(value, &req);
1084 for (i = 0; i <= CONNMAN_FIELD_STATE_INFO; i++)
1085 if (!strcmp(req, types[i]))
1086 {
1087 field->requirement = i;
1088 break;
1089 }
1090 return EINA_TRUE;
1091 }
1092
1093 if (!strcmp(key, "Alternates"))
1094 {
1095 EINA_SAFETY_ON_FALSE_RETURN_VAL(signature[0] == 'a', EINA_FALSE);
1096 /* ignore alternates */
1097 return EINA_TRUE;
1098 }
1099
1100 if (!strcmp(key, "Value"))
1101 {
1102 EINA_SAFETY_ON_FALSE_RETURN_VAL(signature[0] == 's', EINA_FALSE);
1103 eldbus_message_iter_basic_get(value, &field->value);
1104 return EINA_TRUE;
1105 }
1106
1107 DBG("Ignored unknown argument: %s", key);
1108 return EINA_FALSE;
1109}
1110
1111static Eina_Bool
1112_connman_field_parse(Connman_Field *field, Eldbus_Message_Iter *value, const char *signature EINA_UNUSED)
1113{
1114 Eldbus_Message_Iter *array, *dict;
1115
1116 eldbus_message_iter_arguments_get(value, "a{sv}", &array);
1117 EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
1118
1119 while (eldbus_message_iter_get_and_next(array, 'e', &dict))
1120 {
1121 Eldbus_Message_Iter *var;
1122 const char *key;
1123 char *sig2;
1124
1125 if (!eldbus_message_iter_arguments_get(dict, "sv", &key, &var))
1126 return EINA_FALSE;
1127 sig2 = eldbus_message_iter_signature_get(var);
1128 if (!sig2)
1129 return EINA_FALSE;
1130
1131 if (!_connman_field_parse_value(field, key, var, sig2))
1132 {
1133 free(sig2);
1134 return EINA_FALSE;
1135 }
1136 free(sig2);
1137 }
1138
1139 return EINA_TRUE;
1140}
1141
1142static void
1143_connman_dbus_dict_append_array(Eldbus_Message_Iter *array, const char *key, Eina_Array *val)
1144{
1145 Eldbus_Message_Iter *dict, *variant, *array2;
1146 Eina_Stringshare *str;
1147 unsigned int i;
1148 Eina_Array_Iterator it;
1149
1150 eldbus_message_iter_arguments_append(array, "{sv}", &dict);
1151 eldbus_message_iter_basic_append(dict, 's', key);
1152 variant = eldbus_message_iter_container_new(dict, 'v', "as");
1153 array2 = eldbus_message_iter_container_new(variant, 'a', "s");
1154 EINA_ARRAY_ITER_NEXT(val, i, str, it)
1155 eldbus_message_iter_basic_append(array2, 's', str);
1156 eldbus_message_iter_container_close(variant, array2);
1157 eldbus_message_iter_container_close(dict, variant);
1158 eldbus_message_iter_container_close(array, dict);
1159}
1160
1161static void
1162_connman_dbus_dict_append_string(Eldbus_Message_Iter *array, const char *key, const char *val)
1163{
1164 Eldbus_Message_Iter *dict, *variant;
1165
1166 eldbus_message_iter_arguments_append(array, "{sv}", &dict);
1167 eldbus_message_iter_basic_append(dict, 's', key);
1168 variant = eldbus_message_iter_container_new(dict, 'v', "s");
1169 eldbus_message_iter_basic_append(variant, 's', val ?: "");
1170 eldbus_message_iter_container_close(dict, variant);
1171 eldbus_message_iter_container_close(array, dict);
1172}
1173
1174static void
1175_connman_dbus_dict_append_bool(Eldbus_Message_Iter *array, const char *key, Eina_Bool val)
1176{
1177 Eldbus_Message_Iter *dict, *variant;
1178
1179 eldbus_message_iter_arguments_append(array, "{sv}", &dict);
1180 eldbus_message_iter_basic_append(dict, 's', key);
1181 variant = eldbus_message_iter_container_new(dict, 'v', "b");
1182 eldbus_message_iter_basic_append(variant, 'b', !!val);
1183 eldbus_message_iter_container_close(dict, variant);
1184 eldbus_message_iter_container_close(array, dict);
1185}
1186
1187static void
1188_connman_agent_auth_send(void *data, const Eina_Array *fields)
1189{
1190 Eldbus_Message *reply;
1191 Eldbus_Message_Iter *iter, *array;
1192 const char *f, *fprev;
1193 unsigned int i;
1194 Eina_Array_Iterator it;
1195
1196 if (!fields)
1197 {
1198 reply = eldbus_message_error_new(data,
1199 "net.connman.Agent.Error.Canceled",
1200 "User canceled dialog");
1201 eldbus_connection_send(dbus_conn, reply, NULL, NULL, -1);
1202 return;
1203 }
1204 reply = eldbus_message_method_return_new(data);
1205 iter = eldbus_message_iter_get(reply);
1206 eldbus_message_iter_arguments_append(iter, "a{sv}", &array);
1207
1208 EINA_ARRAY_ITER_NEXT(fields, i, f, it)
1209 {
1210 if (i % 2)
1211 _connman_dbus_dict_append_string(array, fprev, f);
1212 else
1213 fprev = f;
1214 }
1215 eldbus_message_iter_container_close(iter, array);
1216
1217 eldbus_connection_send(dbus_conn, reply, NULL, NULL, -1);
1218}
1219
1220static Eldbus_Message *
1221_connman_agent_request_input(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
1222{
1223 Eldbus_Message_Iter *array, *dict;
1224 const char *path;
1225 Eina_Array *arr = NULL;
1226
1227 if (!eldbus_message_arguments_get(msg, "oa{sv}", &path, &array))
1228 return eldbus_message_method_return_new(msg);
1229
1230 /* FIXME: WISPr - net.connman.Agent.Error.LaunchBrowser */
1231 while (eldbus_message_iter_get_and_next(array, 'e', &dict))
1232 {
1233 Eldbus_Message_Iter *var;
1234 char *signature;
1235 Connman_Field field = { NULL };
1236
1237 if (!eldbus_message_iter_arguments_get(dict, "sv", &field.name, &var))
1238 goto err;
1239 signature = eldbus_message_iter_signature_get(var);
1240 if (!signature) goto err;
1241
1242 if (!_connman_field_parse(&field, var, signature))
1243 {
1244 free(signature);
1245 goto err;
1246 }
1247 free(signature);
1248
1249 DBG("AGENT Got field:\n"
1250 "\tName: %s\n"
1251 "\tType: %s\n"
1252 "\tRequirement: %d\n"
1253 "\tAlternates: (omit array)\n"
1254 "\tValue: %s",
1255 field.name, field.type, field.requirement, field.value);
1256
1257 if (field.requirement != CONNMAN_FIELD_STATE_MANDATORY) continue;
1258 if (!arr) arr = eina_array_new(1);
1259 eina_array_push(arr, eina_stringshare_add(field.name));
1260 }
1261 wireless_authenticate(arr, _connman_agent_auth_send, eldbus_message_ref((Eldbus_Message *)msg));
1262 array_clear(arr);
1263 return NULL;
1264
1265err:
1266 eina_array_free(arr);
1267 WRN("Failed to parse msg");
1268 return eldbus_message_method_return_new(msg);
1269}
1270
1271static Eldbus_Message *
1272_connman_agent_cancel(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
1273{
1274 Eldbus_Message *reply = eldbus_message_method_return_new(msg);
1275
1276 DBG("Agent canceled");
1277 wireless_authenticate_cancel();
1278
1279 return reply;
1280}
1281
1282static const Eldbus_Method methods[] = {
1283 { "Release", NULL, NULL, _connman_agent_release, 0 },
1284 {
1285 "ReportError", ELDBUS_ARGS({"o", "service"}, {"s", "error"}), NULL,
1286 _connman_agent_report_error, 0
1287 },
1288 //{
1289 //"ReportPeerError", ELDBUS_ARGS({"o", "peer"}, {"s", "error"}), NULL,
1290 //_connman_agent_report_peer_error, 0
1291 //},
1292 {
1293 "RequestBrowser", ELDBUS_ARGS({"o", "service"}, {"s", "url"}), NULL,
1294 _connman_agent_request_browser, 0
1295 },
1296 {
1297 "RequestInput", ELDBUS_ARGS({"o", "service"}, {"a{sv}", "fields"}),
1298 ELDBUS_ARGS({"a{sv}", ""}), _connman_agent_request_input, 0
1299 },
1300 //{
1301 //"RequestPeerAuthorization", ELDBUS_ARGS({"o", "peer"}, {"a{sv}", "fields"}),
1302 //ELDBUS_ARGS({"a{sv}", ""}), _connman_agent_request_peer_auth, 0
1303 //},
1304 { "Cancel", NULL, NULL, _connman_agent_cancel, 0 },
1305 { NULL, NULL, NULL, NULL, 0 }
1306};
1307
1308static const Eldbus_Service_Interface_Desc desc = {
1309 CONNMAN_AGENT_IFACE, methods, NULL, NULL, NULL, NULL
1310};
1311
1312static void
1313_connman_start(void)
1314{
1315 Eldbus_Object *obj;
1316 int i;
1317
1318 CONNMAN_SERVICE_TYPE_ITER(i)
1319 connman_services[i] = eina_hash_string_superfast_new((Eina_Free_Cb)_connman_service_free);
1320
1321 obj = eldbus_object_get(dbus_conn, CONNMAN_BUS_NAME, "/");
1322 proxy_manager = eldbus_proxy_get(obj, CONNMAN_MANAGER_IFACE);
1323
1324 signal_handlers = eina_list_append(signal_handlers,
1325 eldbus_proxy_signal_handler_add(proxy_manager, "PropertyChanged",
1326 _connman_manager_event_property, NULL));
1327 signal_handlers = eina_list_append(signal_handlers,
1328 eldbus_proxy_signal_handler_add(proxy_manager, "ServicesChanged",
1329 _connman_manager_event_services, NULL));
1330
1331 pending_gettechnologies = eldbus_proxy_call(proxy_manager, "GetTechnologies", _connman_manager_gettechnologies,
1332 NULL, -1, "");
1333 pending_getproperties_manager = eldbus_proxy_call(proxy_manager, "GetProperties", _connman_manager_getproperties,
1334 NULL, -1, "");
1335
1336 agent_iface = eldbus_service_interface_register(dbus_conn, CONNMAN_AGENT_PATH, &desc);
1337 eldbus_proxy_call(proxy_manager, "RegisterAgent",
1338 _connman_manager_agent_register, NULL, -1, "o", CONNMAN_AGENT_PATH);
1339}
1340
1341static void
1342_connman_end(void)
1343{
1344 int i;
1345
1346 if (!proxy_manager) return;
1347 eldbus_proxy_call(proxy_manager, "UnregisterAgent", NULL, NULL, -1, "o", CONNMAN_AGENT_PATH);
1348
1349 CONNMAN_SERVICE_TYPE_ITER(i)
1350 {
1351 eina_hash_free(connman_services[i]);
1352 connman_services[i] = NULL;
1353 if (!connman_technology[i].proxy) continue;
1354 _eldbus_proxy_del(connman_technology[i].proxy);
1355 connman_technology[i].proxy = NULL;
1356 }
1357 eldbus_pending_cancel(pending_getservices);
1358 pending_getservices = NULL;
1359 eldbus_pending_cancel(pending_getproperties_manager);
1360 pending_getproperties_manager = NULL;
1361 signal_handlers = eina_list_free(signal_handlers);
1362
1363 _eldbus_proxy_del(proxy_manager);
1364 proxy_manager = NULL;
1365 eldbus_service_object_unregister(agent_iface);
1366 agent_iface = NULL;
1367}
1368
1369static void
1370_connman_name_owner_changed(void *data EINA_UNUSED, const char *bus EINA_UNUSED, const char *from EINA_UNUSED, const char *to)
1371{
1372 if (to[0])
1373 _connman_start();
1374 else
1375 _connman_end();
1376}
1377
1378void
1379connman_init(void)
1380{
1381 int i;
1382
1383 if (_connman_log_dom > -1) return;
1384 CONNMAN_SERVICE_TYPE_ITER(i)
1385 connman_technology[i].type = -1;
1386 eldbus_name_owner_changed_callback_add(dbus_conn, CONNMAN_BUS_NAME,
1387 _connman_name_owner_changed,
1388 NULL, EINA_TRUE);
1389 _connman_log_dom = eina_log_domain_register("wireless.connman", EINA_COLOR_ORANGE);
1390}
1391
1392void
1393connman_shutdown(void)
1394{
1395 int i;
1396 CONNMAN_SERVICE_TYPE_ITER(i)
1397 {
1398 eina_hash_free(connman_services_map[i]);
1399 connman_services_map[i] = NULL;
1400 free(connman_current_connection[i]);
1401 connman_current_connection[i] = NULL;
1402 connman_current_service[i] = NULL;
1403 }
1404 _connman_end();
1405 eldbus_name_owner_changed_callback_del(dbus_conn, CONNMAN_BUS_NAME, _connman_name_owner_changed, NULL);
1406 eina_log_domain_unregister(_connman_log_dom);
1407 _connman_log_dom = -1;
1408}
1409
1410void
1411connman_technology_enabled_set(Wireless_Service_Type type, Eina_Bool state)
1412{
1413 Eldbus_Message_Iter *main_iter, *var;
1414 Eldbus_Message *msg;
1415
1416 EINA_SAFETY_ON_NULL_RETURN(connman_technology[type].proxy);
1417 msg = eldbus_proxy_method_call_new(connman_technology[type].proxy, "SetProperty");
1418 main_iter = eldbus_message_iter_get(msg);
1419 eldbus_message_iter_basic_append(main_iter, 's', "Powered");
1420 var = eldbus_message_iter_container_new(main_iter, 'v', "b");
1421 eldbus_message_iter_basic_append(var, 'b', state);
1422 eldbus_message_iter_container_close(main_iter, var);
1423
1424 eldbus_proxy_send(connman_technology[type].proxy, msg, NULL, NULL, -1);
1425}
1426
1427static void
1428_connman_service_edit_timeservers_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
1429{
1430 const char *name, *text;
1431 /* FIXME */
1432 if (eldbus_message_error_get(msg, &name, &text))
1433 {
1434 ERR("Could not set properties. %s: %s", name, text);
1435 }
1436}
1437
1438static void
1439_connman_service_edit_nameservers_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
1440{
1441 const char *name, *text;
1442 /* FIXME */
1443 if (eldbus_message_error_get(msg, &name, &text))
1444 {
1445 ERR("Could not set properties. %s: %s", name, text);
1446 }
1447}
1448
1449static void
1450_connman_service_edit_domains_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
1451{
1452 const char *name, *text;
1453 /* FIXME */
1454 if (eldbus_message_error_get(msg, &name, &text))
1455 {
1456 ERR("Could not set properties. %s: %s", name, text);
1457 }
1458}
1459
1460static void
1461_connman_service_edit_proxy_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
1462{
1463 const char *name, *text;
1464 /* FIXME */
1465 if (eldbus_message_error_get(msg, &name, &text))
1466 {
1467 ERR("Could not set properties. %s: %s", name, text);
1468 }
1469}
1470
1471static void
1472_connman_service_edit_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
1473{
1474 const char *name, *text;
1475 /* FIXME */
1476 if (eldbus_message_error_get(msg, &name, &text))
1477 {
1478 ERR("Could not set properties. %s: %s", name, text);
1479 }
1480}
1481
1482static void
1483_connman_service_remove_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
1484{
1485 const char *name, *text;
1486
1487 if (eldbus_message_error_get(msg, &name, &text))
1488 ERR("Could not remove service. %s: %s", name, text);
1489}
1490
1491void
1492connman_service_edit(const char *path, Wireless_Connection *wc)
1493{
1494 int i;
1495 Eldbus_Message *msg;
1496 Eldbus_Message_Iter *iter, *variant, *array;
1497 Connman_Service *cs = NULL;
1498 const char *prop[] =
1499 {
1500 "IPv4.Configuration",
1501 "IPv6.Configuration",
1502 };
1503 const char *method[] =
1504 {
1505 "off",
1506 "manual",
1507 "dhcp",
1508 "fixed",
1509 };
1510
1511 CONNMAN_SERVICE_TYPE_ITER(i)
1512 {
1513 cs = eina_hash_find(connman_services[i], path);
1514 if (cs) break;
1515 }
1516 EINA_SAFETY_ON_NULL_RETURN(cs);
1517
1518 msg = eldbus_proxy_method_call_new(cs->proxy, "SetProperty");
1519 iter = eldbus_message_iter_get(msg);
1520 eldbus_message_iter_basic_append(iter, 's', prop[cs->ipv6]);
1521 variant = eldbus_message_iter_container_new(iter, 'v', "a{sv}");
1522 eldbus_message_iter_arguments_append(variant, "a{sv}", &array);
1523 _connman_dbus_dict_append_string(array, "Method", method[wc->method]);
1524 _connman_dbus_dict_append_string(array, "Address", wc->address);
1525 _connman_dbus_dict_append_string(array, "Gateway", wc->gateway);
1526 if (wc->ipv6)
1527 {
1528 const char *privacy[] =
1529 {
1530 [WIRELESS_NETWORK_IPV6_PRIVACY_DISABLED] = "disabled",
1531 [WIRELESS_NETWORK_IPV6_PRIVACY_ENABLED] = "enabled",
1532 [WIRELESS_NETWORK_IPV6_PRIVACY_PREFERRED] = "preferred",
1533 };
1534 _connman_dbus_dict_append_string(array, "PrefixLength", wc->ip.v6.prefixlength);
1535 if (wc->method == WIRELESS_NETWORK_IPV6_METHOD_AUTO)
1536 _connman_dbus_dict_append_string(array, "Privacy", privacy[wc->ip.v6.privacy]);
1537 }
1538 else
1539 _connman_dbus_dict_append_string(array, "Netmask", wc->ip.v4.netmask);
1540 eldbus_message_iter_container_close(variant, array);
1541 eldbus_message_iter_container_close(iter, variant);
1542
1543 eldbus_proxy_send(cs->proxy, msg, _connman_service_edit_cb, NULL, -1);
1544}
1545
1546void
1547connman_service_edit_proxy(const char *path, Wireless_Connection *wc)
1548{
1549 int i;
1550 Eldbus_Message *msg;
1551 Eldbus_Message_Iter *iter, *variant, *array;
1552 Connman_Service *cs = NULL;
1553 const char *method[] =
1554 {
1555 "direct",
1556 "manual",
1557 "auto",
1558 };
1559
1560 CONNMAN_SERVICE_TYPE_ITER(i)
1561 {
1562 cs = eina_hash_find(connman_services[i], path);
1563 if (cs) break;
1564 }
1565 EINA_SAFETY_ON_NULL_RETURN(cs);
1566
1567 msg = eldbus_proxy_method_call_new(cs->proxy, "SetProperty");
1568 iter = eldbus_message_iter_get(msg);
1569 eldbus_message_iter_basic_append(iter, 's', "Proxy");
1570 variant = eldbus_message_iter_container_new(iter, 'v', "a{sv}");
1571 eldbus_message_iter_arguments_append(variant, "a{sv}", &array);
1572 _connman_dbus_dict_append_string(array, "Method", method[wc->proxy_type]);
1573 switch (wc->proxy_type)
1574 {
1575 case WIRELESS_PROXY_TYPE_DIRECT: break;
1576 case WIRELESS_PROXY_TYPE_MANUAL:
1577 _connman_dbus_dict_append_array(array, "Servers", wc->proxy_servers);
1578 _connman_dbus_dict_append_array(array, "Excludes", wc->proxy_excludes);
1579 break;
1580 case WIRELESS_PROXY_TYPE_AUTO:
1581 _connman_dbus_dict_append_string(array, "Address", wc->proxy_url);
1582 break;
1583 }
1584 eldbus_message_iter_container_close(variant, array);
1585 eldbus_message_iter_container_close(iter, variant);
1586
1587 eldbus_proxy_send(cs->proxy, msg, _connman_service_edit_proxy_cb, NULL, -1);
1588}
1589
1590void
1591connman_service_edit_domains(const char *path, Wireless_Connection *wc)
1592{
1593 int i;
1594 Eldbus_Message *msg;
1595 Eldbus_Message_Iter *iter;
1596 Connman_Service *cs = NULL;
1597
1598 CONNMAN_SERVICE_TYPE_ITER(i)
1599 {
1600 cs = eina_hash_find(connman_services[i], path);
1601 if (cs) break;
1602 }
1603 EINA_SAFETY_ON_NULL_RETURN(cs);
1604
1605 msg = eldbus_proxy_method_call_new(cs->proxy, "SetProperty");
1606 iter = eldbus_message_iter_get(msg);
1607 _connman_dbus_dict_append_array(iter, "Domains.Configuration", wc->domain_servers);
1608
1609 eldbus_proxy_send(cs->proxy, msg, _connman_service_edit_domains_cb, NULL, -1);
1610}
1611
1612void
1613connman_service_edit_nameservers(const char *path, Wireless_Connection *wc)
1614{
1615 int i;
1616 Eldbus_Message *msg;
1617 Eldbus_Message_Iter *iter;
1618 Connman_Service *cs = NULL;
1619
1620 CONNMAN_SERVICE_TYPE_ITER(i)
1621 {
1622 cs = eina_hash_find(connman_services[i], path);
1623 if (cs) break;
1624 }
1625 EINA_SAFETY_ON_NULL_RETURN(cs);
1626
1627 msg = eldbus_proxy_method_call_new(cs->proxy, "SetProperty");
1628 iter = eldbus_message_iter_get(msg);
1629 _connman_dbus_dict_append_array(iter, "Nameservers.Configuration", wc->name_servers);
1630
1631 eldbus_proxy_send(cs->proxy, msg, _connman_service_edit_nameservers_cb, NULL, -1);
1632}
1633
1634void
1635connman_service_edit_timeservers(const char *path, Wireless_Connection *wc)
1636{
1637 int i;
1638 Eldbus_Message *msg;
1639 Eldbus_Message_Iter *iter;
1640 Connman_Service *cs = NULL;
1641
1642 CONNMAN_SERVICE_TYPE_ITER(i)
1643 {
1644 cs = eina_hash_find(connman_services[i], path);
1645 if (cs) break;
1646 }
1647 EINA_SAFETY_ON_NULL_RETURN(cs);
1648
1649 msg = eldbus_proxy_method_call_new(cs->proxy, "SetProperty");
1650 iter = eldbus_message_iter_get(msg);
1651 _connman_dbus_dict_append_array(iter, "Timeservers.Configuration", wc->time_servers);
1652
1653 eldbus_proxy_send(cs->proxy, msg, _connman_service_edit_timeservers_cb, NULL, -1);
1654}
1655
1656void
1657connman_service_remove(const char *path)
1658{
1659 int i;
1660 Eldbus_Message *msg;
1661 Connman_Service *cs = NULL;
1662
1663 CONNMAN_SERVICE_TYPE_ITER(i)
1664 {
1665 cs = eina_hash_find(connman_services[i], path);
1666 if (cs) break;
1667 }
1668 EINA_SAFETY_ON_NULL_RETURN(cs);
1669
1670 msg = eldbus_proxy_method_call_new(cs->proxy, "Remove");
1671 eldbus_proxy_send(cs->proxy, msg, _connman_service_remove_cb, NULL, -1);
1672}
1673
1674void
1675connman_airplane_mode_set(Eina_Bool set)
1676{
1677 Eldbus_Message *msg;
1678 Eldbus_Message_Iter *iter;
1679
1680 msg = eldbus_proxy_method_call_new(proxy_manager, "SetProperty");
1681 iter = eldbus_message_iter_get(msg);
1682 _connman_dbus_dict_append_bool(iter, "OfflineMode", set);
1683 eldbus_proxy_send(proxy_manager, msg, NULL, NULL, -1);
1684}
diff --git a/src/wireless.c b/src/wireless.c
new file mode 100644
index 0000000..811acd3
--- /dev/null
+++ b/src/wireless.c
@@ -0,0 +1,1676 @@
1#include "wireless.h"
2
3
4/* FIXME */
5void connman_technology_enabled_set(Wireless_Service_Type type, Eina_Bool state);
6
7static const char *wireless_theme_groups[] =
8{
9 [WIRELESS_SERVICE_TYPE_ETHERNET] = "wireless/ethernet",
10 [WIRELESS_SERVICE_TYPE_WIFI] = "wireless/wifi",
11 [WIRELESS_SERVICE_TYPE_BLUETOOTH] = "wireless/bluetooth",
12 [WIRELESS_SERVICE_TYPE_CELLULAR] = "wireless/cellular",
13};
14
15static const char *wireless_ipv4_methods[] =
16{
17 N_("Disabled"),
18 N_("Manual"),
19 "DHCP",
20 N_("Fixed"),
21};
22
23static const char *wireless_ipv6_methods[] =
24{
25 N_("Off"),
26 N_("Manual"),
27 N_("Auto"),
28 "6to4",
29 N_("Fixed"),
30};
31
32static const char *wireless_proxy_methods[] =
33{
34 N_("Direct"),
35 N_("Manual"),
36 N_("Auto"),
37};
38
39typedef struct Instance
40{
41 int id;
42 E_Gadget_Site_Orient orient;
43 Evas_Object *win;
44 Evas_Object *box;
45 Evas_Object *icon[WIRELESS_SERVICE_TYPE_LAST];
46
47 Eina_Bool popup;
48
49 struct
50 {
51 Evas_Object *error;
52 Evas_Object *address;
53 Evas_Object *method;
54 Evas_Object *signal;
55 Wireless_Service_Type type;
56 } tooltip;
57} Instance;
58
59typedef struct Wireless_Auth_Popup
60{
61 Evas_Object *popup;
62 Wireless_Auth_Cb cb;
63 void *data;
64 Eina_Bool sent : 1;
65} Wireless_Auth_Popup;
66
67void connman_init(void);
68void connman_shutdown(void);
69Eldbus_Connection *dbus_conn;
70Wireless_Config *wireless_config;
71
72static Eina_Array *wireless_networks;
73static Wireless_Connection *wireless_current[WIRELESS_SERVICE_TYPE_LAST];
74static Eina_Bool wireless_type_enabled[WIRELESS_SERVICE_TYPE_LAST];
75static Eina_Bool wireless_type_available[WIRELESS_SERVICE_TYPE_LAST];
76static Eina_List *wireless_auth_pending;
77static Wireless_Auth_Popup *wireless_auth_popup;
78static Eina_Bool wireless_offline;
79static Evas_Object *wireless_edit_popup;
80static Wireless_Connection *wireless_edit[2];
81static Instance *inst;
82static unsigned int wireless_network_count[WIRELESS_SERVICE_TYPE_LAST];
83
84static struct
85{
86 Evas_Object *popup;
87 Evas_Object *box;
88 Evas_Object *content;
89 Eina_Stringshare *name_servers;
90 Eina_Stringshare *time_servers;
91 Eina_Stringshare *domain_servers;
92 Eina_Stringshare *proxy_servers;
93 Eina_Stringshare *proxy_excludes;
94 Eina_Hash *items;
95 Eina_List *entries;
96 Wireless_Service_Type type;
97} wireless_popup;
98
99static Eina_Bool auth_popup;
100
101#undef DBG
102#undef INF
103#undef WRN
104#undef ERR
105
106#define DBG(...) EINA_LOG_DOM_DBG(_wireless_gadget_log_dom, __VA_ARGS__)
107#define INF(...) EINA_LOG_DOM_INFO(_wireless_gadget_log_dom, __VA_ARGS__)
108#define WRN(...) EINA_LOG_DOM_WARN(_wireless_gadget_log_dom, __VA_ARGS__)
109#define ERR(...) EINA_LOG_DOM_ERR(_wireless_gadget_log_dom, __VA_ARGS__)
110static int _wireless_gadget_log_dom = -1;
111
112static void _wireless_gadget_refresh();
113
114static void
115_wifi_icon_signal(Evas_Object *icon, int state, int strength)
116{
117 Edje_Message_Int_Set *msg;
118
119 DBG("icon msg: %d %d%%", state, strength);
120 msg = alloca(sizeof(Edje_Message_Int_Set) + sizeof(int));
121 msg->count = 2;
122 msg->val[0] = state;
123 msg->val[1] = strength;
124 edje_object_message_send(elm_layout_edje_get(icon), EDJE_MESSAGE_INT_SET, 1, msg);
125}
126
127static void
128_wifi_icon_init(Evas_Object *icon, Wireless_Network *wn, int type)
129{
130 int state = 0, strength = 0;
131
132 if (wn)
133 {
134 state = wn->state;
135 strength = wn->strength;
136 }
137 _wifi_icon_signal(icon, state, strength);
138
139 if (!wn)
140 {
141 if (wireless_type_available[type])
142 elm_object_signal_emit(icon, "wireless,state,default", "wireless");
143 else
144 elm_object_signal_emit(icon, "wireless,state,error", "wireless");
145 elm_object_signal_emit(icon, "wireless,state,unsecured", "wireless");
146 return;
147 }
148 if (wn->state == WIRELESS_NETWORK_STATE_FAILURE)
149 {
150 elm_object_signal_emit(icon, "wireless,state,error", "wireless");
151 return;
152 }
153 elm_object_signal_emit(icon, "wireless,state,default", "wireless");
154 switch (wn->type)
155 {
156 case WIRELESS_SERVICE_TYPE_WIFI:
157 if (wn->security > WIRELESS_NETWORK_SECURITY_WEP)
158 elm_object_signal_emit(icon, "wireless,state,secure", "wireless");
159 else if (wn->security == WIRELESS_NETWORK_SECURITY_WEP)
160 elm_object_signal_emit(icon, "wireless,state,insecure", "wireless");
161 else if (!wn->security)
162 elm_object_signal_emit(icon, "wireless,state,unsecured", "wireless");
163 break;
164 default: break;
165 }
166}
167
168static void
169_wireless_popup_toggle(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
170{
171 connman_technology_enabled_set(wireless_popup.type, elm_check_state_get(obj));
172}
173
174static void
175_wireless_popup_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
176{
177 inst->popup = 0;
178 eina_hash_free(wireless_popup.items);
179 eina_list_free(wireless_popup.entries);
180 wireless_popup.items = NULL;
181 wireless_popup.entries = NULL;
182 eina_stringshare_replace(&wireless_popup.proxy_servers, NULL);
183 eina_stringshare_replace(&wireless_popup.proxy_excludes, NULL);
184 eina_stringshare_replace(&wireless_popup.name_servers, NULL);
185 eina_stringshare_replace(&wireless_popup.time_servers, NULL);
186 eina_stringshare_replace(&wireless_popup.domain_servers, NULL);
187 wireless_popup.box = NULL;
188 wireless_popup.content = NULL;
189 wireless_popup.popup = NULL;
190 wireless_popup.type = -1;
191}
192
193static void
194_wireless_edit_basic_entries_update(void)
195{
196 Eina_List *l;
197 Evas_Object *ent;
198 Eina_Bool disabled;
199
200 if (wireless_edit[1]->ipv6)
201 disabled = wireless_edit[1]->method != WIRELESS_NETWORK_IPV6_METHOD_MANUAL;
202 else
203 disabled = wireless_edit[1]->method != WIRELESS_NETWORK_IPV4_METHOD_MANUAL;
204 EINA_LIST_FOREACH(wireless_popup.entries, l, ent)
205 elm_object_disabled_set(ent, disabled);
206}
207
208static Evas_Object *
209_wireless_popup_table_entry_row(Evas_Object *tb, const char *name, Evas_Smart_Cb cb, void *data, int *row)
210{
211 Evas_Object *fr, *entry;
212
213 fr = elm_frame_add(tb);
214 evas_object_show(fr);
215 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 evas_object_size_hint_fill_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
217 elm_object_text_set(fr, name);
218 elm_table_pack(tb, fr, 0, *row, 2, 2);
219 *row += 2;
220
221 entry = elm_entry_add(tb);
222 evas_object_show(entry);
223 elm_entry_single_line_set(entry, 1);
224 elm_entry_scrollable_set(entry, 1);
225 evas_object_data_set(entry, "table", tb);
226 evas_object_smart_callback_add(entry, "activated", cb, data);
227 elm_object_content_set(fr, entry);
228 return entry;
229}
230
231static void
232_wireless_edit_entry_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
233{
234 Eina_Stringshare **str = data;
235
236 eina_stringshare_replace(str, elm_entry_entry_get(obj));
237}
238
239static void
240_wireless_gadget_edit_array_entry(Eina_Array *arr, Eina_Stringshare **ptr)
241{
242 Eina_Stringshare *str;
243 unsigned int i;
244 Eina_Array_Iterator it;
245 Eina_Strbuf *buf;
246
247 if (!arr) return;
248 buf = eina_strbuf_new();
249 EINA_ARRAY_ITER_NEXT(arr, i, str, it)
250 {
251 if (eina_strbuf_length_get(buf)) eina_strbuf_append(buf, ", ");
252 eina_strbuf_append(buf, str);
253 }
254 eina_stringshare_replace(ptr, eina_strbuf_string_get(buf));
255 eina_strbuf_free(buf);
256}
257
258static void
259_wireless_gadget_edit_proxy_method_update(void)
260{
261 Evas_Object *ent, *tb = wireless_popup.content;
262 int row = 1;
263 Wireless_Connection *wc = wireless_edit[1];
264
265 evas_object_del(elm_table_child_get(wireless_popup.content, 0, 1));
266 evas_object_del(elm_table_child_get(wireless_popup.content, 0, 3));
267 evas_object_del(elm_table_child_get(wireless_popup.content, 0, 5));
268 switch (wc->proxy_type)
269 {
270 case WIRELESS_PROXY_TYPE_DIRECT:
271 _wireless_popup_table_entry_row(tb, NULL, NULL, NULL, &row);
272 evas_object_hide(elm_table_child_get(wireless_popup.content, 0, 1));
273 _wireless_popup_table_entry_row(tb, NULL, NULL, NULL, &row);
274 evas_object_hide(elm_table_child_get(wireless_popup.content, 0, 3));
275 _wireless_popup_table_entry_row(tb, NULL, NULL, NULL, &row);
276 evas_object_hide(elm_table_child_get(wireless_popup.content, 0, 5));
277 break;
278 case WIRELESS_PROXY_TYPE_MANUAL:
279 ent = _wireless_popup_table_entry_row(tb, _("Proxy Servers"), NULL, NULL, &row);
280 elm_entry_entry_set(ent, wireless_popup.proxy_servers);
281 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_popup.proxy_servers);
282 ent = _wireless_popup_table_entry_row(tb, _("Proxy Excludes"), NULL, NULL, &row);
283 elm_entry_entry_set(ent, wireless_popup.proxy_excludes);
284 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_popup.proxy_excludes);
285 _wireless_popup_table_entry_row(tb, NULL, NULL, NULL, &row);
286 evas_object_hide(elm_table_child_get(wireless_popup.content, 0, 5));
287 break;
288 case WIRELESS_PROXY_TYPE_AUTO:
289 ent = _wireless_popup_table_entry_row(tb, _("Proxy Address"), NULL, NULL, &row);
290 elm_entry_entry_set(ent, wc->proxy_url);
291 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->address);
292 _wireless_popup_table_entry_row(tb, NULL, NULL, NULL, &row);
293 evas_object_hide(elm_table_child_get(wireless_popup.content, 0, 3));
294 _wireless_popup_table_entry_row(tb, NULL, NULL, NULL, &row);
295 evas_object_hide(elm_table_child_get(wireless_popup.content, 0, 5));
296 break;
297 }
298}
299
300static void
301_wireless_gadget_edit_proxy_method(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
302{
303 wireless_edit[1]->proxy_type = (intptr_t)elm_object_item_data_get(event_info);
304 _wireless_gadget_edit_proxy_method_update();
305}
306
307static void
308_wireless_gadget_edit_method(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
309{
310 wireless_edit[1]->method = (intptr_t)elm_object_item_data_get(event_info);
311 _wireless_edit_basic_entries_update();
312}
313
314static void
315_wireless_gadget_edit_method_open(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
316{
317 int i, fixed;
318 const char **methods;
319
320 elm_hoversel_clear(obj);
321 if (wireless_edit[1]->ipv6)
322 {
323 fixed = WIRELESS_NETWORK_IPV6_METHOD_FIXED;
324 methods = wireless_ipv6_methods;
325 }
326 else
327 {
328 fixed = WIRELESS_NETWORK_IPV6_METHOD_FIXED;
329 methods = wireless_ipv4_methods;
330 }
331 for (i = 0; i < fixed; i++)
332 {
333 if ((int)wireless_edit[1]->method != i)
334 elm_hoversel_item_add(obj, methods[i], NULL, ELM_ICON_NONE, NULL, (intptr_t*)(long)i);
335 }
336}
337
338static void
339_wireless_edit_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
340{
341 int i;
342
343 wireless_popup.entries = eina_list_free(wireless_popup.entries);
344 eina_stringshare_del(wireless_edit[0]->wn->path);
345 free(wireless_edit[0]->wn);
346 for (i = 0; i <= 1; i++)
347 {
348 eina_stringshare_del(wireless_edit[i]->address);
349 eina_stringshare_del(wireless_edit[i]->gateway);
350 if (wireless_edit[i]->ipv6)
351 eina_stringshare_del(wireless_edit[i]->ip.v6.prefixlength);
352 else
353 eina_stringshare_del(wireless_edit[i]->ip.v4.netmask);
354 eina_stringshare_del(wireless_edit[i]->proxy_url);
355 array_clear(wireless_edit[i]->proxy_excludes);
356 array_clear(wireless_edit[i]->proxy_servers);
357 free(wireless_edit[i]);
358 wireless_edit[i] = NULL;
359 }
360 wireless_popup.popup = NULL;
361 wireless_edit_popup = NULL;
362}
363
364static Eina_Array *
365string_to_array(const char *str)
366{
367 const char *p = str;
368 Eina_Array *arr;
369
370 arr = eina_array_new(1);
371 do
372 {
373 const char *start, *end;
374
375 start = p;
376 p = strchr(p, ',');
377 if (!p) break;
378 end = p - 1;
379 while (isspace(start[0])) start++;
380 while (isspace(end[0])) end--;
381 end++;
382
383 if (start == end) break;
384 eina_array_push(arr, eina_stringshare_add_length(start, end - start));
385 p++;
386 } while (p[0]);
387 return arr;
388}
389
390static Eina_Bool
391_wireless_array_notequal(Eina_Array *a, Eina_Array *b)
392{
393 unsigned int i;
394
395 if ((!!a) != (!!b)) return EINA_TRUE;
396 if ((!a) && (!b)) return EINA_FALSE;
397 if (eina_array_count(a) != eina_array_count(b)) return EINA_TRUE;
398 for (i = 0; i < eina_array_count(a); i++)
399 if (eina_array_data_get(a, i) != eina_array_data_get(b, i)) return EINA_TRUE;
400 return EINA_FALSE;
401}
402
403static void
404_wireless_edit_send()
405{
406 Eina_Bool basic = EINA_FALSE, proxy = EINA_FALSE;
407
408 void connman_service_edit(const char *path, Wireless_Connection *wc);
409 void connman_service_edit_proxy(const char *path, Wireless_Connection *wc);
410 void connman_service_edit_domains(const char *path, Wireless_Connection *wc);
411 void connman_service_edit_nameservers(const char *path, Wireless_Connection *wc);
412 void connman_service_edit_timeservers(const char *path, Wireless_Connection *wc);
413
414 if (wireless_edit[0]->method == wireless_edit[1]->method)
415 {
416 if (wireless_edit[1]->ipv6)
417 switch (wireless_edit[1]->method)
418 {
419 case WIRELESS_NETWORK_IPV6_METHOD_AUTO:
420 basic = wireless_edit[0]->ip.v6.privacy != wireless_edit[1]->ip.v6.privacy;
421 break;
422 case WIRELESS_NETWORK_IPV6_METHOD_MANUAL:
423 basic = wireless_edit[0]->address != wireless_edit[1]->address;
424 if (basic) break;
425 basic = wireless_edit[0]->gateway != wireless_edit[1]->gateway;
426 if (basic) break;
427 basic = wireless_edit[0]->ip.v6.prefixlength != wireless_edit[1]->ip.v6.prefixlength;
428 break;
429 default: break;
430 }
431 else
432 switch (wireless_edit[1]->method)
433 {
434 case WIRELESS_NETWORK_IPV4_METHOD_MANUAL:
435 basic = wireless_edit[0]->address != wireless_edit[1]->address;
436 if (basic) break;
437 basic = wireless_edit[0]->gateway != wireless_edit[1]->gateway;
438 if (basic) break;
439 basic = wireless_edit[0]->ip.v4.netmask != wireless_edit[1]->ip.v4.netmask;
440 break;
441 default: break;
442 }
443 }
444 else
445 basic = EINA_TRUE;
446
447 if (basic)
448 connman_service_edit(wireless_edit[1]->wn->path, wireless_edit[1]);
449
450 if (wireless_edit[1]->proxy_type == WIRELESS_PROXY_TYPE_MANUAL)
451 {
452 array_clear(wireless_edit[1]->proxy_servers);
453 array_clear(wireless_edit[1]->proxy_excludes);
454 if (wireless_popup.proxy_servers)
455 wireless_edit[1]->proxy_servers = string_to_array(wireless_popup.proxy_servers);
456 if (wireless_popup.proxy_excludes)
457 wireless_edit[1]->proxy_excludes = string_to_array(wireless_popup.proxy_excludes);
458 }
459 if (wireless_edit[0]->proxy_type == wireless_edit[1]->proxy_type)
460 {
461 switch (wireless_edit[0]->proxy_type)
462 {
463 case WIRELESS_PROXY_TYPE_MANUAL:
464 proxy = _wireless_array_notequal(wireless_edit[0]->proxy_servers,
465 wireless_edit[1]->proxy_servers);
466 if (proxy) break;
467 proxy = _wireless_array_notequal(wireless_edit[0]->proxy_excludes,
468 wireless_edit[1]->proxy_excludes);
469 break;
470 case WIRELESS_PROXY_TYPE_AUTO:
471 proxy = wireless_edit[0]->proxy_url != wireless_edit[1]->proxy_url;
472 break;
473 break;
474 default: break;
475 }
476
477 }
478 else
479 proxy = EINA_TRUE;
480 if (proxy)
481 connman_service_edit_proxy(wireless_edit[1]->wn->path, wireless_edit[1]);
482
483 array_clear(wireless_edit[1]->domain_servers);
484 if (wireless_popup.domain_servers)
485 wireless_edit[1]->domain_servers = string_to_array(wireless_popup.domain_servers);
486 array_clear(wireless_edit[1]->name_servers);
487 if (wireless_popup.name_servers)
488 wireless_edit[1]->name_servers = string_to_array(wireless_popup.name_servers);
489 array_clear(wireless_edit[1]->name_servers);
490 if (wireless_popup.name_servers)
491 wireless_edit[1]->name_servers = string_to_array(wireless_popup.name_servers);
492
493 if (_wireless_array_notequal(wireless_edit[0]->domain_servers, wireless_edit[1]->domain_servers))
494 connman_service_edit_domains(wireless_edit[1]->wn->path, wireless_edit[1]);
495 if (_wireless_array_notequal(wireless_edit[0]->name_servers, wireless_edit[1]->name_servers))
496 connman_service_edit_nameservers(wireless_edit[1]->wn->path, wireless_edit[1]);
497 if (_wireless_array_notequal(wireless_edit[0]->time_servers, wireless_edit[1]->time_servers))
498 connman_service_edit_timeservers(wireless_edit[1]->wn->path, wireless_edit[1]);
499}
500
501static void
502_wireless_edit_send_button()
503{
504 evas_object_hide(wireless_edit_popup);
505 evas_object_del(wireless_edit_popup);
506 _wireless_edit_send();
507}
508
509static void
510_wireless_edit_remove()
511{
512 void connman_service_remove(const char *path);
513 evas_object_hide(wireless_edit_popup);
514 evas_object_del(wireless_edit_popup);
515 connman_service_remove(wireless_edit[1]->wn->path);
516}
517
518static void
519_wireless_edit_key(void *d EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data)
520{
521 Evas_Event_Key_Up *ev = event_data;
522
523 if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
524 {
525 _wireless_edit_send();
526 evas_object_hide(obj);
527 evas_object_del(obj);
528 }
529 if (!strcmp(ev->key, "Escape"))
530 {
531 evas_object_hide(obj);
532 evas_object_del(obj);
533 }
534}
535
536static void
537_wireless_gadget_edit_proxy_method_open(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
538{
539 int i;
540
541 elm_hoversel_clear(obj);
542 for (i = 0; i <= WIRELESS_PROXY_TYPE_AUTO; i++)
543 {
544 if ((int)wireless_edit[1]->proxy_type != i)
545 elm_hoversel_item_add(obj, wireless_proxy_methods[i], NULL, ELM_ICON_NONE, NULL, (intptr_t*)(long)i);
546 }
547}
548
549static void
550_wireless_gadget_edit_proxy(void)
551{
552 Evas_Object *tb, *fr, *hoversel;
553 int row = 0;
554 Wireless_Connection *wc = wireless_edit[1];
555
556 wireless_popup.content = tb = elm_table_add(wireless_popup.popup);
557 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
558 evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
559 evas_object_show(tb);
560 elm_box_pack_end(wireless_popup.box, tb);
561
562 fr = elm_frame_add(tb);
563 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
564 evas_object_size_hint_fill_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
565 evas_object_show(fr);
566 elm_object_text_set(fr, _("Proxy Type"));
567 elm_table_pack(tb, fr, 0, row++, 2, 1);
568
569 hoversel = elm_hoversel_add(tb);
570 elm_hoversel_hover_parent_set(hoversel, wireless_popup.popup);
571 elm_hoversel_auto_update_set(hoversel, 1);
572 evas_object_show(hoversel);
573 elm_object_content_set(fr, hoversel);
574 evas_object_smart_callback_add(hoversel, "selected", _wireless_gadget_edit_proxy_method, NULL);
575 evas_object_smart_callback_add(hoversel, "clicked", _wireless_gadget_edit_proxy_method_open, NULL);
576 elm_object_text_set(hoversel, wireless_proxy_methods[wc->proxy_type]);
577 _wireless_gadget_edit_proxy_method_update();
578}
579
580static void
581_wireless_gadget_edit_dnstime(void)
582{
583 Evas_Object *tb, *ent;
584 int row = 0;
585
586 wireless_popup.content = tb = elm_table_add(wireless_popup.popup);
587 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
588 evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
589 evas_object_show(tb);
590 elm_box_pack_end(wireless_popup.box, tb);
591
592 ent = _wireless_popup_table_entry_row(tb, _("Nameservers"), NULL, NULL, &row);
593 elm_entry_entry_set(ent, wireless_popup.name_servers);
594 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_popup.name_servers);
595
596 ent = _wireless_popup_table_entry_row(tb, _("Timeservers"), NULL, NULL, &row);
597 elm_entry_entry_set(ent, wireless_popup.time_servers);
598 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_popup.time_servers);
599
600 ent = _wireless_popup_table_entry_row(tb, _("Search Domains"), NULL, NULL, &row);
601 elm_entry_entry_set(ent, wireless_popup.domain_servers);
602 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_popup.domain_servers);
603
604 _wireless_popup_table_entry_row(tb, NULL, NULL, NULL, &row);
605 evas_object_hide(elm_table_child_get(tb, 0, 6));
606}
607
608static void
609_wireless_gadget_edit_services_type(Evas_Object *obj, Wireless_Service_Type type)
610{
611 Eina_Bool state = elm_check_state_get(obj);
612
613 if (state)
614 wireless_config->disabled_types |= (1 << type);
615 else
616 wireless_config->disabled_types &= ~(1 << type);
617 //Currently not used due to e internals
618 //e_config_save_queue();
619 _wireless_gadget_refresh();
620}
621
622static void
623_wireless_gadget_edit_services_wifi(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
624{
625 _wireless_gadget_edit_services_type(obj, WIRELESS_SERVICE_TYPE_WIFI);
626}
627
628static void
629_wireless_gadget_edit_services_bluetooth(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
630{
631 _wireless_gadget_edit_services_type(obj, WIRELESS_SERVICE_TYPE_BLUETOOTH);
632}
633
634static void
635_wireless_gadget_edit_services_cellular(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
636{
637 _wireless_gadget_edit_services_type(obj, WIRELESS_SERVICE_TYPE_CELLULAR);
638}
639
640static void
641_wireless_gadget_edit_services(void)
642{
643 Evas_Object *tb, *bx, *ck, *fr, *r;
644 int row = 0;
645
646 wireless_popup.content = tb = elm_table_add(wireless_popup.popup);
647 elm_table_homogeneous_set(tb, 1);
648 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
649 evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
650 evas_object_show(tb);
651 elm_box_pack_end(wireless_popup.box, tb);
652
653 fr = elm_frame_add(tb);
654 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
655 evas_object_size_hint_fill_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
656 evas_object_show(fr);
657 elm_object_text_set(fr, _("Hide Service Types"));
658 elm_table_pack(tb, fr, 0, row++, 2, 1);
659
660 bx = elm_box_add(fr);
661 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
662 evas_object_size_hint_fill_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
663 evas_object_show(bx);
664 elm_object_content_set(fr, bx);
665
666 ck = elm_check_add(tb);
667 evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
668 evas_object_size_hint_fill_set(ck, EVAS_HINT_FILL, EVAS_HINT_FILL);
669 elm_object_text_set(ck, _("Hide Wifi"));
670 elm_check_state_set(ck, (wireless_config->disabled_types &
671 (1 << WIRELESS_SERVICE_TYPE_WIFI)) == (1 << WIRELESS_SERVICE_TYPE_WIFI));
672 evas_object_smart_callback_add(ck, "changed", _wireless_gadget_edit_services_wifi, NULL);
673 if ((!wireless_current[WIRELESS_SERVICE_TYPE_WIFI]) || (!wireless_current[WIRELESS_SERVICE_TYPE_WIFI]->wn) ||
674 (wireless_current[WIRELESS_SERVICE_TYPE_WIFI]->wn->state != WIRELESS_NETWORK_STATE_ONLINE))
675 evas_object_show(ck);
676 elm_box_pack_end(bx, ck);
677
678 ck = elm_check_add(tb);
679 evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
680 evas_object_size_hint_fill_set(ck, EVAS_HINT_FILL, EVAS_HINT_FILL);
681 elm_object_text_set(ck, _("Hide Bluetooth"));
682 elm_check_state_set(ck, (wireless_config->disabled_types &
683 (1 << WIRELESS_SERVICE_TYPE_BLUETOOTH)) == (1 << WIRELESS_SERVICE_TYPE_BLUETOOTH));
684 evas_object_smart_callback_add(ck, "changed", _wireless_gadget_edit_services_bluetooth, NULL);
685 if ((!wireless_current[WIRELESS_SERVICE_TYPE_BLUETOOTH]) || (!wireless_current[WIRELESS_SERVICE_TYPE_BLUETOOTH]->wn) ||
686 (wireless_current[WIRELESS_SERVICE_TYPE_BLUETOOTH]->wn->state != WIRELESS_NETWORK_STATE_ONLINE))
687 evas_object_show(ck);
688 elm_box_pack_end(bx, ck);
689
690 ck = elm_check_add(tb);
691 evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
692 evas_object_size_hint_fill_set(ck, EVAS_HINT_FILL, EVAS_HINT_FILL);
693 elm_object_text_set(ck, _("Hide Cellular"));
694 elm_check_state_set(ck, (wireless_config->disabled_types &
695 (1 << WIRELESS_SERVICE_TYPE_CELLULAR)) == (1 << WIRELESS_SERVICE_TYPE_CELLULAR));
696 evas_object_smart_callback_add(ck, "changed", _wireless_gadget_edit_services_cellular, NULL);
697 if ((!wireless_current[WIRELESS_SERVICE_TYPE_CELLULAR]) || (!wireless_current[WIRELESS_SERVICE_TYPE_CELLULAR]->wn) ||
698 (wireless_current[WIRELESS_SERVICE_TYPE_CELLULAR]->wn->state != WIRELESS_NETWORK_STATE_ONLINE))
699 evas_object_show(ck);
700 elm_box_pack_end(bx, ck);
701
702 r = evas_object_rectangle_add(evas_object_evas_get(tb));
703 elm_table_pack(tb, r, 0, row++, 2, 1);
704}
705
706static Evas_Object *
707_wireless_gadget_edit_basic(void)
708{
709 Evas_Object *tb, *fr, *hoversel, *ent, *entry;
710 Eina_Bool disabled;
711 int row = 0, fixed;
712 const char **methods;
713 Wireless_Connection *wc = wireless_edit[1];
714
715 wireless_popup.content = tb = elm_table_add(wireless_popup.box);
716 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
717 evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
718 evas_object_show(tb);
719 elm_box_pack_end(wireless_popup.box, tb);
720
721 fr = elm_frame_add(tb);
722 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
723 evas_object_size_hint_fill_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
724 evas_object_show(fr);
725 elm_object_text_set(fr, _("Method"));
726 elm_table_pack(tb, fr, 0, row++, 2, 1);
727
728 hoversel = elm_hoversel_add(tb);
729 elm_hoversel_hover_parent_set(hoversel, wireless_popup.popup);
730 elm_hoversel_auto_update_set(hoversel, 1);
731 evas_object_show(hoversel);
732 elm_object_content_set(fr, hoversel);
733 evas_object_smart_callback_add(hoversel, "selected", _wireless_gadget_edit_method, NULL);
734 if (wc->ipv6)
735 {
736 fixed = WIRELESS_NETWORK_IPV6_METHOD_FIXED;
737 methods = wireless_ipv6_methods;
738 }
739 else
740 {
741 fixed = WIRELESS_NETWORK_IPV6_METHOD_FIXED;
742 methods = wireless_ipv4_methods;
743 }
744 disabled = (int)wc->method == fixed;
745 elm_object_disabled_set(hoversel, disabled);
746 if (disabled)
747 elm_hoversel_item_add(hoversel, _("Fixed"), NULL, ELM_ICON_NONE, NULL, NULL);
748 else
749 {
750 elm_object_text_set(hoversel, methods[wc->method]);
751 evas_object_smart_callback_add(hoversel, "clicked", _wireless_gadget_edit_method_open, NULL);
752 }
753
754 ent = entry = _wireless_popup_table_entry_row(tb, _("Address"), NULL, NULL, &row);
755 elm_object_disabled_set(ent, disabled);
756 wireless_popup.entries = eina_list_append(wireless_popup.entries, ent);
757 elm_entry_entry_set(ent, wc->address);
758 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->address);
759 if (wc->ipv6)
760 {
761 ent = _wireless_popup_table_entry_row(tb, _("PrefixLength"), NULL, NULL, &row);
762 elm_entry_entry_set(ent, wc->ip.v6.prefixlength);
763 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->ip.v6.prefixlength);
764 }
765 else
766 {
767 ent = _wireless_popup_table_entry_row(tb, _("Netmask"), NULL, NULL, &row);
768 elm_entry_entry_set(ent, wc->ip.v4.netmask);
769 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->ip.v4.netmask);
770 }
771 elm_object_disabled_set(ent, disabled);
772 wireless_popup.entries = eina_list_append(wireless_popup.entries, ent);
773 ent = _wireless_popup_table_entry_row(tb, _("Gateway"), NULL, NULL, &row);
774 elm_entry_entry_set(ent, wc->gateway);
775 elm_object_disabled_set(ent, disabled);
776 evas_object_smart_callback_add(ent, "changed,user", _wireless_edit_entry_changed, &wireless_edit[1]->gateway);
777 wireless_popup.entries = eina_list_append(wireless_popup.entries, ent);
778 _wireless_edit_basic_entries_update();
779
780 return entry;
781}
782
783static void
784_wireless_gadget_edit_select_pre(void)
785{
786 elm_box_unpack(wireless_popup.box, wireless_popup.content);
787 evas_object_del(wireless_popup.content);
788 wireless_popup.entries = eina_list_free(wireless_popup.entries);
789}
790
791static void
792_wireless_gadget_edit_select_basic(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
793{
794 _wireless_gadget_edit_select_pre();
795 _wireless_gadget_edit_basic();
796}
797
798static void
799_wireless_gadget_edit_select_proxy(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
800{
801 _wireless_gadget_edit_select_pre();
802 _wireless_gadget_edit_proxy();
803}
804
805static void
806_wireless_gadget_edit_select_dnstime(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
807{
808 _wireless_gadget_edit_select_pre();
809 _wireless_gadget_edit_dnstime();
810}
811
812static void
813_wireless_gadget_edit_select_services(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
814{
815 _wireless_gadget_edit_select_pre();
816 _wireless_gadget_edit_services();
817}
818
819static void
820_wireless_gadget_edit(int type)
821{
822 Evas_Object *popup, *entry, *box1, *box, *list, *lbl, *bt;
823 Elm_Object_Item *it;
824 Eina_Bool disabled;
825 int i;
826 char buf[1024] = {0};
827 Wireless_Connection *wc = wireless_current[type];
828 Wireless_Network *wn;
829
830 if (!wc) return;
831 if (wireless_popup.popup)
832 {
833 evas_object_hide(wireless_popup.popup);
834 evas_object_del(wireless_popup.popup);
835 }
836 wireless_edit[0] = calloc(1, sizeof(Wireless_Connection));
837 wireless_edit[1] = calloc(1, sizeof(Wireless_Connection));
838 wn = calloc(1, sizeof(Wireless_Network));
839 wn->path = eina_stringshare_ref(wc->wn->path);
840 for (i = 0; i <= 1; i++)
841 {
842 Eina_Array *arrays[] =
843 { wc->domain_servers, wc->name_servers, wc->time_servers, wc->proxy_servers,
844 wc->proxy_excludes, NULL };
845 Eina_Array **arrays2[] =
846 { &wireless_edit[i]->domain_servers, &wireless_edit[i]->name_servers,
847 &wireless_edit[i]->time_servers, &wireless_edit[i]->proxy_servers,
848 &wireless_edit[i]->proxy_excludes, NULL };
849 unsigned int ii;
850
851 wireless_edit[i]->wn = wn;
852 wireless_edit[i]->method = wc->method;
853 wireless_edit[i]->address = eina_stringshare_ref(wc->address);
854 wireless_edit[i]->gateway = eina_stringshare_ref(wc->gateway);
855 wireless_edit[i]->ipv6 = wc->ipv6;
856 if (wc->ipv6)
857 {
858 wireless_edit[i]->ip.v6.prefixlength = eina_stringshare_ref(wc->ip.v6.prefixlength);
859 wireless_edit[i]->ip.v6.privacy = wc->ip.v6.privacy;
860 }
861 else
862 wireless_edit[i]->ip.v4.netmask = eina_stringshare_ref(wc->ip.v4.netmask);
863 wireless_edit[i]->proxy_type = wc->proxy_type;
864 wireless_edit[i]->proxy_url = eina_stringshare_ref(wc->proxy_url);
865 /* fuuuuck thiiiiiiis */
866 for (ii = 0; ii < EINA_C_ARRAY_LENGTH(arrays); ii++)
867 {
868 unsigned int iii;
869 Eina_Stringshare *str;
870 Eina_Array_Iterator itr;
871
872 if (!arrays[ii]) continue;
873 *arrays2[ii] = eina_array_new(eina_array_count(arrays[ii]));
874 EINA_ARRAY_ITER_NEXT(arrays[ii], iii, str, itr)
875 eina_array_push(*arrays2[ii], eina_stringshare_ref(str));
876 }
877 }
878 _wireless_gadget_edit_array_entry(wc->domain_servers, &wireless_popup.domain_servers);
879 _wireless_gadget_edit_array_entry(wc->name_servers, &wireless_popup.name_servers);
880 _wireless_gadget_edit_array_entry(wc->time_servers, &wireless_popup.time_servers);
881 _wireless_gadget_edit_array_entry(wc->proxy_servers, &wireless_popup.proxy_servers);
882 _wireless_gadget_edit_array_entry(wc->proxy_excludes, &wireless_popup.proxy_excludes);
883
884 wireless_popup.popup = popup = elm_win_add(inst->win, "win", ELM_WIN_BASIC);
885 elm_win_alpha_set(popup, 1);
886
887 box = elm_box_add(popup);
888 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
889 evas_object_size_hint_fill_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
890 evas_object_show(box);
891 elm_win_resize_object_add(popup, box);
892
893 lbl = elm_label_add(box);
894 elm_object_style_set(lbl, "marker");
895 evas_object_show(lbl);
896 if (wireless_popup.type == WIRELESS_SERVICE_TYPE_ETHERNET)
897 strncpy(buf, _("Edit Connection Details: <b>Ethernet</b>"), sizeof(buf) - 1);
898 else
899 snprintf(buf, sizeof(buf), "%s: <hilight>%s</hilight>", _("Edit Connection Details"), wc->wn->name);
900 elm_object_text_set(lbl, buf);
901 elm_box_pack_end(box, lbl);
902
903 wireless_popup.box = box1 = elm_box_add(popup);
904 evas_object_size_hint_weight_set(box1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
905 evas_object_size_hint_fill_set(box1, EVAS_HINT_FILL, EVAS_HINT_FILL);
906 elm_box_horizontal_set(box1, 1);
907 evas_object_show(box1);
908 elm_box_pack_end(box, box1);
909
910 list = elm_list_add(box1);
911 evas_object_size_hint_weight_set(list, 0, EVAS_HINT_EXPAND);
912 evas_object_size_hint_fill_set(list, 0, EVAS_HINT_FILL);
913 elm_box_pack_end(box1, list);
914 elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
915 elm_scroller_content_min_limit(list, 1, 1);
916
917 entry = _wireless_gadget_edit_basic();
918 it = elm_list_item_append(list, _("Basic"), NULL, NULL, _wireless_gadget_edit_select_basic, NULL);
919 elm_list_item_selected_set(it, 1);
920 elm_list_item_append(list, _("Proxy"), NULL, NULL, _wireless_gadget_edit_select_proxy, NULL);
921 elm_list_item_append(list, _("DNS/Time"), NULL, NULL, _wireless_gadget_edit_select_dnstime, NULL);
922 elm_list_item_append(list, _("Services"), NULL, NULL, _wireless_gadget_edit_select_services, NULL);
923 elm_list_go(list);
924 evas_object_show(list);
925
926 if (wc->ipv6)
927 disabled = wc->method == WIRELESS_NETWORK_IPV4_METHOD_FIXED;
928 else
929 disabled = wc->method == WIRELESS_NETWORK_IPV6_METHOD_FIXED;
930 if (!disabled)
931 {
932 bt = elm_button_add(box);
933 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
934 evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
935 evas_object_show(bt);
936 elm_object_text_set(bt, _("Deal with it"));
937 evas_object_smart_callback_add(bt, "clicked", _wireless_edit_send_button, NULL);
938 elm_box_pack_end(box, bt);
939
940 bt = elm_button_add(box);
941 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
942 evas_object_size_hint_fill_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
943 evas_object_show(bt);
944 elm_object_text_set(bt, _("Forget Network"));
945 evas_object_smart_callback_add(bt, "clicked", _wireless_edit_remove, NULL);
946 elm_box_pack_end(box, bt);
947 }
948 wireless_edit_popup = popup;
949 evas_object_size_hint_fill_set(box, 0.5, 0.5);
950 evas_object_show(wireless_edit_popup);
951 evas_object_event_callback_add(wireless_edit_popup, EVAS_CALLBACK_KEY_UP, _wireless_edit_key, NULL);
952 evas_object_event_callback_add(wireless_edit_popup, EVAS_CALLBACK_DEL, _wireless_edit_del, NULL);
953 elm_object_focus_set(entry, 1);
954}
955
956static void
957_wireless_popup_network_click(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
958{
959 Wireless_Network *wn = data;
960
961 if ((wn->state == WIRELESS_NETWORK_STATE_CONNECTED) || (wn->state == WIRELESS_NETWORK_STATE_ONLINE))
962 {
963 int type = wireless_popup.type;
964
965 evas_object_hide(wireless_popup.popup);
966 evas_object_del(wireless_popup.popup);
967 _wireless_gadget_edit(type);
968 }
969 else
970 {
971 /* FIXME */
972 if (!wn->connect_cb(wn))
973 {}
974 }
975}
976
977static void
978_wireless_popup_list_populate(void)
979{
980 Eina_Iterator *it;
981 Wireless_Network *wn;
982
983 if (!wireless_networks) return;
984 it = eina_array_iterator_new(wireless_networks);
985 EINA_ITERATOR_FOREACH(it, wn)
986 {
987 Evas_Object *icon;
988 Elm_Object_Item *item;
989 const char *name = wn->name;
990
991 if (wn->type != wireless_popup.type) continue;
992 icon = elm_layout_add(wireless_popup.content);
993 elm_layout_file_set(icon, elm_theme_group_path_find(NULL, wireless_theme_groups[wireless_popup.type]),
994 wireless_theme_groups[wireless_popup.type]);
995 _wifi_icon_init(icon, wn, wn->type);
996 if (!name)
997 name = _("<SSID hidden>");
998 item = elm_list_item_append(wireless_popup.content, name, icon, NULL, _wireless_popup_network_click, wn);
999 eina_hash_add(wireless_popup.items, &wn, item);
1000 }
1001 eina_iterator_free(it);
1002}
1003
1004static void
1005_wireless_gadget_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info)
1006{
1007 Evas_Event_Mouse_Down *ev = event_info;
1008 Evas_Object *ctx, *tb, *list, *toggle;
1009 Evas_Coord px, py;
1010 int type;
1011 const char *names[] =
1012 {
1013 _("Ethernet"),
1014 _("Wifi"),
1015 _("Bluetooth"),
1016 _("Cellular"),
1017 };
1018
1019 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1020 //Internal Enlightenment Function
1021 //if (e_desklock_state_get()) return;
1022 if (auth_popup) return;
1023 for (type = 0; type < WIRELESS_SERVICE_TYPE_LAST; type++)
1024 if (obj == inst->icon[type])
1025 break;
1026 if (ev->button == 2) connman_technology_enabled_set(type, !wireless_type_enabled[type]);
1027 if (ev->button == 3)
1028 {
1029 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1030 _wireless_gadget_edit(type);
1031 }
1032 if (ev->button != 1) return;
1033 if (wireless_popup.popup)
1034 {
1035 evas_object_hide(wireless_popup.popup);
1036 evas_object_del(wireless_popup.popup);
1037 wireless_popup.popup = NULL;
1038 return;
1039 }
1040 inst->popup = 1;
1041 wireless_popup.type = type;
1042 wireless_popup.items = eina_hash_pointer_new(NULL);
1043
1044 ctx = elm_win_add(inst->win, "win", ELM_WIN_POPUP_MENU);
1045
1046 tb = elm_table_add(ctx);
1047 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1048 evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
1049
1050 wireless_popup.content = list = elm_list_add(ctx);
1051 elm_list_mode_set(list, ELM_LIST_EXPAND);
1052 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1053 evas_object_size_hint_fill_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1054 _wireless_popup_list_populate();
1055 elm_list_go(list);
1056 evas_object_show(list);
1057 elm_table_pack(tb, list, 0, 0, 2, 1);
1058 toggle = elm_check_add(ctx);
1059 evas_object_show(toggle);
1060 elm_object_style_set(toggle, "toggle");
1061 elm_object_text_set(toggle, names[type]);
1062 elm_object_part_text_set(toggle, "on", _("On"));
1063 elm_object_part_text_set(toggle, "off", _("Off"));
1064 elm_check_state_set(toggle, wireless_type_enabled[type]);
1065 evas_object_smart_callback_add(toggle, "changed", _wireless_popup_toggle, inst);
1066 elm_table_pack(tb, toggle, 0, 1, 2, 1);
1067 wireless_popup.popup = ctx;
1068
1069 //Currently not used due to e internals
1070 /*{
1071 Evas_Object *r = evas_object_rectangle_add(e_comp->evas);
1072 e_comp_object_util_del_list_append(list, r);
1073 elm_table_pack(tb, r, 2, 0, 1, 1);
1074 zone = e_zone_current_get();
1075 evas_object_size_hint_min_set(r, 1, zone->h / 3);
1076
1077 r = evas_object_rectangle_add(e_comp->evas);
1078 e_comp_object_util_del_list_append(list, r);
1079 elm_table_pack(tb, r, 0, 2, 2, 1);
1080 evas_object_size_hint_min_set(r, zone->w / 5, 1);
1081 }*/
1082
1083 evas_pointer_canvas_xy_get(evas_object_evas_get(inst->win), &px, &py);
1084 evas_object_move(ctx, px, py);
1085 evas_object_size_hint_fill_set(tb, 0.5, 0.5);
1086 elm_win_resize_object_add(ctx, tb);
1087 evas_object_show(tb);
1088 evas_object_show(wireless_popup.popup);
1089 evas_object_event_callback_add(wireless_popup.popup, EVAS_CALLBACK_DEL, _wireless_popup_del, inst);
1090}
1091
1092static Evas_Object *
1093_wireless_tooltip_row(Evas_Object *tb, const char *label, const char *value, int row)
1094{
1095 Evas_Object *lbl;
1096
1097 lbl = elm_label_add(tb);
1098 evas_object_show(lbl);
1099 evas_object_size_hint_align_set(lbl, 0, 0.5);
1100 elm_object_text_set(lbl, label);
1101 elm_table_pack(tb, lbl, 0, row, 1, 1);
1102
1103 lbl = elm_label_add(tb);
1104 evas_object_show(lbl);
1105 evas_object_size_hint_align_set(lbl, 0, 0.5);
1106 elm_object_text_set(lbl, value);
1107 elm_table_pack(tb, lbl, 1, row, 1, 1);
1108 return lbl;
1109}
1110
1111static const char *
1112_wireless_tooltip_method_name(void)
1113{
1114 if (wireless_current[WIRELESS_SERVICE_TYPE_WIFI]->ipv6)
1115 return wireless_ipv6_methods[wireless_current[WIRELESS_SERVICE_TYPE_WIFI]->method];
1116 return wireless_ipv4_methods[wireless_current[WIRELESS_SERVICE_TYPE_WIFI]->method];
1117}
1118
1119static void
1120_wireless_tooltip_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1121{
1122 inst->tooltip.error = inst->tooltip.address =
1123 inst->tooltip.method = inst->tooltip.signal = NULL;
1124 inst->tooltip.type = -1;
1125}
1126
1127static Evas_Object *
1128_wireless_tooltip(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *tooltip)
1129{
1130 Evas_Object *tb;
1131 int row = 0;
1132 char buf[1024];
1133 int type = WIRELESS_SERVICE_TYPE_WIFI;
1134
1135 if (!wireless_current[type])
1136 {
1137 if (!wireless_type_available[type])//connman not found
1138 {
1139 inst->tooltip.error = elm_label_add(tooltip);
1140 elm_object_text_set(inst->tooltip.error, _("Error: Connman not detected!"));
1141 evas_object_event_callback_add(inst->tooltip.error, EVAS_CALLBACK_DEL, _wireless_tooltip_del, inst);
1142 return inst->tooltip.error;
1143 }
1144 return NULL;
1145 }
1146 tb = elm_table_add(tooltip);
1147 elm_table_padding_set(tb, 5, 1);
1148
1149 _wireless_tooltip_row(tb, _("Name:"), wireless_current[type]->wn->name, row++);
1150 inst->tooltip.method = _wireless_tooltip_row(tb, _("Method:"), _wireless_tooltip_method_name(), row++);
1151
1152 inst->tooltip.address = _wireless_tooltip_row(tb, _("Address:"), wireless_current[type]->address, row++);
1153 snprintf(buf, sizeof(buf), "%u%%", wireless_current[type]->wn->strength);
1154 inst->tooltip.signal = _wireless_tooltip_row(tb, _("Signal:"), buf, row++);
1155
1156 evas_object_event_callback_add(tb, EVAS_CALLBACK_DEL, _wireless_tooltip_del, inst);
1157 return tb;
1158}
1159
1160static void
1161wireless_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1162{
1163 if (inst->popup)
1164 {
1165 evas_object_hide(wireless_popup.popup);
1166 evas_object_del(wireless_popup.popup);
1167 }
1168
1169 evas_object_hide(wireless_popup.popup);
1170 evas_object_del(wireless_popup.popup);
1171 free(inst);
1172 free(wireless_config);
1173
1174 connman_shutdown();
1175 eldbus_connection_unref(dbus_conn);
1176 eina_log_domain_unregister(_wireless_gadget_log_dom);
1177 _wireless_gadget_log_dom = -1;
1178 ecore_main_loop_quit();
1179}
1180
1181static void
1182_wireless_gadget_icon_add(int type)
1183{
1184 if (!inst->icon[type])
1185 {
1186 Evas_Object *g;
1187
1188 inst->icon[type] = g = elm_layout_add(inst->box);
1189 evas_object_size_hint_weight_set(g, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1190 evas_object_size_hint_fill_set(g, EVAS_HINT_FILL, EVAS_HINT_FILL);
1191 elm_layout_file_set(g, elm_theme_group_path_find(NULL, wireless_theme_groups[type]),
1192 wireless_theme_groups[type]);
1193 elm_object_tooltip_content_cb_set(g, _wireless_tooltip, inst, NULL);
1194 evas_object_event_callback_add(g, EVAS_CALLBACK_MOUSE_DOWN, _wireless_gadget_mouse_down, inst);
1195 }
1196 DBG("Updating icon for %d", type);
1197 _wifi_icon_init(inst->icon[type], wireless_current[type] ? wireless_current[type]->wn : NULL, type);
1198 evas_object_hide(inst->icon[type]);
1199}
1200
1201static void
1202_wireless_gadget_refresh()
1203{
1204 int type;
1205 int avail = 0;
1206
1207 if (inst->id < 0) return;
1208 for (type = 0; type < WIRELESS_SERVICE_TYPE_LAST; type++)
1209 {
1210 if (wireless_type_available[type])
1211 _wireless_gadget_icon_add(type);
1212 else
1213 {
1214 if (inst->tooltip.type == type)
1215 elm_object_tooltip_hide(inst->icon[type]);
1216 if (wireless_popup.type == type)
1217 {
1218 evas_object_hide(wireless_popup.popup);
1219 evas_object_del(wireless_popup.popup);
1220 }
1221 evas_object_del(inst->icon[type]);
1222 inst->icon[type] = NULL;
1223 }
1224 }
1225 elm_box_unpack_all(inst->box);
1226 type = WIRELESS_SERVICE_TYPE_ETHERNET;
1227 if (inst->icon[type])
1228 {
1229 /* only show ethernet if it's connected or there's no wifi available */
1230 if ((!inst->icon[WIRELESS_SERVICE_TYPE_WIFI]) ||
1231 wireless_network_count[WIRELESS_SERVICE_TYPE_ETHERNET] ||
1232 (wireless_current[type] &&
1233 wireless_current[type]->wn &&
1234 (wireless_current[type]->wn->state == WIRELESS_NETWORK_STATE_ONLINE)))
1235 {
1236 elm_box_pack_end(inst->box, inst->icon[type]);
1237 evas_object_show(inst->icon[type]);
1238 avail++;
1239 }
1240 }
1241 if (!avail)
1242 {
1243 for (type = WIRELESS_SERVICE_TYPE_WIFI; type < WIRELESS_SERVICE_TYPE_LAST; type++)
1244 {
1245 if (!inst->icon[type]) continue;
1246 if ((wireless_config->disabled_types & (1U << type)) == (1U << type)) continue;
1247 if (wireless_type_enabled[type] && (!wireless_network_count[type])) continue;
1248
1249 elm_box_pack_end(inst->box, inst->icon[type]);
1250 evas_object_show(inst->icon[type]);
1251 avail++;
1252 }
1253 }
1254 if (!avail)
1255 {
1256 type = WIRELESS_SERVICE_TYPE_ETHERNET;
1257 _wireless_gadget_icon_add(type);
1258 elm_box_pack_end(inst->box, inst->icon[type]);
1259 evas_object_show(inst->icon[type]);
1260 avail++;
1261 }
1262 if (inst->orient == E_GADGET_SITE_ORIENT_VERTICAL)
1263 evas_object_size_hint_aspect_set(inst->win, EVAS_ASPECT_CONTROL_BOTH, 1, avail);
1264 else
1265 evas_object_size_hint_aspect_set(inst->win, EVAS_ASPECT_CONTROL_BOTH, avail, 1);
1266}
1267
1268static void
1269_orient_change(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1270{
1271 inst->orient = (uintptr_t)event_info;
1272 elm_box_horizontal_set(inst->box, inst->orient != E_GADGET_SITE_ORIENT_VERTICAL);
1273 _wireless_gadget_refresh();
1274}
1275
1276int
1277main(int argc, char *argv[])
1278{
1279 Evas_Object *g;
1280 char id[15];
1281
1282 elm_init(argc, (char **)argv);
1283 elm_theme_extension_add(NULL, THEMEDIR "/wireless.edj");
1284 _wireless_gadget_log_dom = eina_log_domain_register("wireless", EINA_COLOR_CYAN);
1285 dbus_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM);
1286 connman_init();
1287
1288 wireless_config = calloc(1, sizeof(Wireless_Config));
1289 inst = calloc(1, sizeof(Instance));
1290 snprintf(id, sizeof(id), "%s", getenv("E_GADGET_ID"));
1291 inst->id = atoi(id);
1292 inst->orient = E_GADGET_SITE_ORIENT_NONE;
1293 wireless_popup.type = inst->tooltip.type = -1;
1294
1295 inst->win = elm_win_add(NULL, "wireless", ELM_WIN_BASIC);
1296 evas_object_size_hint_min_set(inst->win, 100, 100);
1297 evas_object_size_hint_aspect_set(inst->win, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
1298 evas_object_smart_callback_add(inst->win, "gadget_site_anchor", _orient_change, NULL);
1299 evas_object_smart_callback_add(inst->win, "gadget_site_orient", _orient_change, NULL);
1300 elm_win_autodel_set(inst->win, 1);
1301 elm_win_alpha_set(inst->win, 1);
1302
1303 inst->box = elm_box_add(inst->win);
1304 elm_box_horizontal_set(inst->box, inst->orient != E_GADGET_SITE_ORIENT_VERTICAL);
1305 elm_box_homogeneous_set(inst->box, 1);
1306 evas_object_size_hint_weight_set(inst->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1307 evas_object_size_hint_fill_set(inst->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
1308 evas_object_event_callback_add(inst->box, EVAS_CALLBACK_DEL, wireless_del, inst);
1309 evas_object_show(inst->box);
1310
1311 if (inst->id < 0)
1312 {
1313 inst->icon[WIRELESS_SERVICE_TYPE_WIFI] = g = elm_layout_add(inst->box);
1314 evas_object_size_hint_weight_set(g, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1315 evas_object_size_hint_fill_set(g, EVAS_HINT_FILL, EVAS_HINT_FILL);
1316 elm_layout_file_set(g, elm_theme_group_path_find(NULL, "wireless/wifi"),
1317 "wireless/wifi");
1318 elm_object_signal_emit(g, "wireless,state,default", "wireless");
1319 _wifi_icon_signal(g, WIRELESS_NETWORK_STATE_ONLINE, 100);
1320 evas_object_show(g);
1321 elm_box_pack_end(inst->box, g);
1322 evas_object_size_hint_aspect_set(inst->box, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
1323 }
1324 else
1325 _wireless_gadget_refresh();
1326
1327 elm_win_resize_object_add(inst->win, inst->box);
1328 evas_object_show(inst->win);
1329 ecore_main_loop_begin();
1330
1331 return 0;
1332}
1333
1334//Currently not used due to e internals
1335/*static Eina_Bool
1336_wireless_mode_change()
1337{
1338 void connman_airplane_mode_set(Eina_Bool set);
1339
1340 if (wireless_offline != e_config->mode.offline)
1341 connman_airplane_mode_set(e_config->mode.offline);
1342 return ECORE_CALLBACK_RENEW;
1343}*/
1344
1345void
1346wireless_service_type_available_set(Eina_Bool *avail)
1347{
1348 if (!memcmp(avail, &wireless_type_available, sizeof(wireless_type_available))) return;
1349 memcpy(&wireless_type_available, avail, WIRELESS_SERVICE_TYPE_LAST * sizeof(Eina_Bool));
1350 _wireless_gadget_refresh();
1351}
1352
1353void
1354wireless_service_type_enabled_set(Eina_Bool *avail)
1355{
1356 if (!memcmp(avail, &wireless_type_enabled, sizeof(wireless_type_enabled))) return;
1357 memcpy(&wireless_type_enabled, avail, WIRELESS_SERVICE_TYPE_LAST * sizeof(Eina_Bool));
1358 _wireless_gadget_refresh();
1359}
1360
1361void
1362wireless_wifi_current_networks_set(Wireless_Connection **current)
1363{
1364 Wireless_Connection *prev[WIRELESS_SERVICE_TYPE_LAST] = {NULL};
1365 int type;
1366
1367 memcpy(&prev, &wireless_current, WIRELESS_SERVICE_TYPE_LAST * sizeof(void*));
1368 memcpy(&wireless_current, current, WIRELESS_SERVICE_TYPE_LAST * sizeof(void*));
1369 type = wireless_popup.type;
1370 if ((type > -1) && wireless_popup.items)
1371 {
1372 Elm_Object_Item *it;
1373 Evas_Object *icon;
1374
1375 if (wireless_current[type])
1376 {
1377 it = eina_hash_find(wireless_popup.items, &wireless_current[type]->wn);
1378 icon = elm_object_item_content_get(it);
1379 _wifi_icon_init(icon, wireless_current[type]->wn, type);
1380 }
1381 if (prev[type])
1382 {
1383 it = eina_hash_find(wireless_popup.items, &prev[type]->wn);
1384 if (it)
1385 {
1386 icon = elm_object_item_content_get(it);
1387 _wifi_icon_init(icon, prev[type]->wn, type);
1388 }
1389 }
1390 }
1391 else if ((type > -1) && wireless_popup.popup && (!wireless_current[type]))
1392 {
1393 evas_object_hide(wireless_popup.popup);
1394 evas_object_del(wireless_popup.popup);
1395 }
1396 _wireless_gadget_refresh();
1397 type = inst->tooltip.type;
1398 if (type < 0) return;
1399 if (prev[type] &&
1400 ((!wireless_current[type]) ||
1401 ((wireless_current[type] != prev[type]) && (!eina_streq(wireless_current[type]->wn->name, prev[type]->wn->name)))))
1402 {
1403 elm_object_tooltip_hide(inst->icon[type]);
1404 return;
1405 }
1406 if (inst->tooltip.method)
1407 elm_object_text_set(inst->tooltip.method, _wireless_tooltip_method_name());
1408 if (inst->tooltip.address)
1409 elm_object_text_set(inst->tooltip.address, wireless_current[type]->address);
1410 if (inst->tooltip.signal)
1411 {
1412 char buf[32];
1413 snprintf(buf, sizeof(buf), "%u%%", wireless_current[type]->wn->strength);
1414 elm_object_text_set(inst->tooltip.signal, buf);
1415 }
1416}
1417
1418static Eina_Bool
1419_wireless_networks_count(const void *cont EINA_UNUSED, void *data, void *fdata EINA_UNUSED)
1420{
1421 Wireless_Network *wn = data;
1422
1423 wireless_network_count[wn->type]++;
1424 return EINA_TRUE;
1425}
1426
1427Eina_Array *
1428wireless_networks_set(Eina_Array *networks)
1429{
1430 Eina_Array *prev = wireless_networks;
1431
1432 wireless_networks = networks;
1433 memset(&wireless_network_count, 0, sizeof(wireless_network_count));
1434 eina_array_foreach(networks, _wireless_networks_count, NULL);
1435 if (wireless_popup.popup && wireless_popup.items)
1436 {
1437 elm_list_clear(wireless_popup.content);
1438 eina_hash_free_buckets(wireless_popup.items);
1439 _wireless_popup_list_populate();
1440 }
1441
1442 return prev;
1443}
1444
1445void
1446wireless_airplane_mode_set(Eina_Bool enabled)
1447{
1448 wireless_offline = enabled;
1449 //Currently not used due to E internals
1450 /*if (enabled == e_config->mode.offline) return;
1451 e_config->mode.offline = !!enabled;
1452 e_config_mode_changed();
1453 e_config_save_queue();*/
1454}
1455
1456static void
1457_wireless_auth_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1458{
1459 Wireless_Auth_Popup *p = data;
1460 Evas_Object *popup = p->popup;
1461
1462 if (!p->sent)
1463 p->cb(p->data, NULL);
1464 free(p);
1465 wireless_auth_popup = NULL;
1466 evas_object_hide(popup);
1467 evas_object_del(popup);
1468 if (!wireless_auth_pending) return;
1469 wireless_auth_popup = eina_list_data_get(wireless_auth_pending);
1470 wireless_auth_pending = eina_list_remove_list(wireless_auth_pending, wireless_auth_pending);
1471 evas_object_show(wireless_auth_popup->popup);
1472 evas_object_event_callback_add(wireless_auth_popup->popup, EVAS_CALLBACK_DEL,
1473 _wireless_auth_del, wireless_auth_popup);
1474}
1475
1476static void
1477_wireless_auth_send(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
1478{
1479 Wireless_Auth_Popup *p = data;
1480 Eina_Array *arr = NULL;
1481 Evas_Object *tb, *o;
1482 unsigned int row = 1;
1483
1484 tb = evas_object_data_get(obj, "table");
1485 do
1486 {
1487 const char *txt;
1488
1489 o = elm_table_child_get(tb, 0, row);
1490 if (!o) break;
1491 if (!arr) arr = eina_array_new(2);
1492 txt = elm_object_text_get(o);
1493 eina_array_push(arr, txt);
1494 o = elm_object_content_get(o);
1495 /* skip checkboxes */
1496 if (!strncmp(txt, "Pass", 4)) row++;
1497 eina_array_push(arr, elm_object_text_get(o));
1498 row += 2;
1499 } while (1);
1500 p->cb(p->data, arr);
1501 p->sent = 1;
1502 eina_array_free(arr);
1503 evas_object_hide(p->popup);
1504 evas_object_del(p->popup);
1505}
1506
1507static void
1508_wireless_auth_key(void *d EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_data)
1509{
1510 Evas_Event_Key_Up *ev = event_data;
1511
1512 if (!strcmp(ev->key, "Escape"))
1513 {
1514 evas_object_hide(obj);
1515 evas_object_del(obj);
1516 }
1517}
1518
1519static void
1520_wireless_auth_password_toggle(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1521{
1522 elm_entry_password_set(data, !elm_entry_password_get(data));
1523}
1524
1525void
1526wireless_authenticate(const Eina_Array *fields, Wireless_Auth_Cb cb, void *data)
1527{
1528 Evas_Object *popup, *tb, *lbl, *entry = NULL;
1529 Eina_Iterator *it;
1530 const char *f;
1531 Wireless_Auth_Popup *p;
1532 int row = 0;
1533
1534 p = calloc(1, sizeof(Wireless_Auth_Popup));
1535 p->cb = cb;
1536 p->data = data;
1537 if (wireless_popup.popup)
1538 {
1539 evas_object_hide(wireless_popup.popup);
1540 evas_object_del(wireless_popup.popup);
1541 }
1542
1543 popup = elm_win_add(inst->win, "win", ELM_WIN_BASIC);
1544 elm_win_alpha_set(popup, 1);
1545 evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_UP, _wireless_auth_key, NULL);
1546 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _wireless_auth_del, NULL);
1547
1548 tb = elm_table_add(popup);
1549 evas_object_show(tb);
1550 elm_win_resize_object_add(popup, tb);
1551
1552 lbl = elm_label_add(popup);
1553 evas_object_show(lbl);
1554 elm_object_text_set(lbl, _("Authentication Required"));
1555 elm_table_pack(tb, lbl, 0, row++, 2, 1);
1556
1557 it = eina_array_iterator_new(fields);
1558 EINA_ITERATOR_FOREACH(it, f)
1559 {
1560 Evas_Object *o;
1561 char buf[1024];
1562 Evas_Object *ck;
1563
1564 o = _wireless_popup_table_entry_row(tb, f, _wireless_auth_send, p, &row);
1565 if (strncmp(f, "Pass", 4)) continue;
1566 if (!entry) entry = o;
1567 elm_entry_password_set(o, 1);
1568
1569 ck = elm_check_add(tb);
1570 evas_object_show(ck);
1571 evas_object_size_hint_align_set(ck, 0, -1);
1572 snprintf(buf, sizeof(buf), _("Show %s"), f);
1573 evas_object_smart_callback_add(ck, "changed", _wireless_auth_password_toggle, o);
1574 elm_object_text_set(ck, buf);
1575 elm_table_pack(tb, ck, 0, row++, 2, 1);
1576 }
1577 p->popup = popup;
1578 evas_object_size_hint_fill_set(tb, 0.5, 0.5);
1579 if (wireless_auth_popup)
1580 wireless_auth_pending = eina_list_append(wireless_auth_pending, p);
1581 else
1582 {
1583 wireless_auth_popup = p;
1584 evas_object_show(popup);
1585 elm_object_focus_set(entry, 1);
1586 }
1587}
1588
1589void
1590wireless_authenticate_cancel(void)
1591{
1592 if (!wireless_auth_popup) return;
1593 evas_object_hide(wireless_auth_popup->popup);
1594 evas_object_del(wireless_auth_popup->popup);
1595}
1596
1597static void
1598_wireless_auth_external_deny(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1599{
1600 // FIXME
1601 free(data);
1602 auth_popup = 0;
1603}
1604
1605static void
1606_wireless_auth_external_allow(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1607{
1608 char *uri = data;
1609 Ecore_Exe_Flags flags = ECORE_EXE_NONE;
1610
1611#if (ECORE_VERSION_MAJOR >= 1) && (ECORE_VERSION_MINOR >= 21)
1612 flags |= ECORE_EXE_ISOLATE_IO;
1613#else
1614 flags |= 1024;
1615#endif
1616 ecore_exe_pipe_run(uri, flags, NULL);
1617
1618 DBG("launched uri: %s", uri);