Debian Codegraph @

plyer/platforms/win/wifi.py

raw symbols SCIP
1 import plyer.platforms.win.libs.wifi_defs as wifi_lib
2 from plyer.facades import Wifi
3
4
5 class WindowWifi(Wifi):
6
7 names = {}
8
9 def _is_enabled(self):
10 '''
11 TODO: Implement this in future
12 Couldn't find a nice implementation for this although
13 NetworkInformation class could be used but ctypes doesn't supports
14 class yet. It should look something like this.
15
16 for item in NetworkInformation.getConnectionProfiles():
17 if item.IsWlanConnectionProfile:
18 adapter_id = item.NetworkAdapter.NetworkAdapterId
19 for item in NetworkInformation.GetLanIdentifiers():
20 if item.NetworkAdapterId == adapter_id:
21 is_wifi_enabled = True
22 return True/False
23
24 Returning True for now to make it work.
25 '''
26 return True
27
28 def _get_network_info(self, name):
29 '''
30 Returns all the network information.
31 '''
32 return wifi_lib.get_network_info(name)
33
34 def _start_scanning(self):
35 '''
36 Starts scanning for available Wi-Fi networks and returns the available,
37 devices.
38 '''
39 if self._is_enabled():
40 self.names = wifi_lib.start_scanning()
41 else:
42 raise Exception('Wifi not Enabled.')
43
44 def _get_available_wifi(self):
45 '''
46 Returns the name of available networks.
47 '''
48 return wifi_lib.get_available_wifi()
49
50 def _connect(self, network, parameters):
51 '''
52 Expects 2 parameters:
53 - name/ssid of the network.
54 - parameters: dict type
55 - connection_mode:
56 `https://msdn.microsoft.com/en-us/library/windows/desktop/
57 ms706844(v=vs.85).aspx`
58
59 :between range [0, 5]
60 - wlan_connection_mode_profile,
61 wlan_connection_mode_temporary_profile,
62 wlan_connection_mode_discovery_secure,
63 wlan_connection_mode_discovery_unsecure,
64 wlan_connection_mode_auto,
65 wlan_connection_mode_invalid.
66 - profile:
67 if wlanConnectionMode = wlan_connection_mode_profile
68 then profile = ssid
69 if wlanConnectionMode = wlan_connection_mode_temporary_profile
70 then profile = XML representation of the profile used for the
71 connection
72 if wlanConnectionMode = wlan_connection_mode_discovery_secure
73 or
74 wlan_connection_mode_discovery_unsecure
75 then profile = None
76 - ssid: optional (as network name and ssid are same)
77 - bssidList
78 `https://msdn.microsoft.com/en-us/library/windows/desktop/
79 ms705996(v=vs.85).aspx`
80 - Header
81 structure that contains the type, version, and, size
82 information
83 of an NDIS structure.
84 - Type: NDSI_OBJECT_TYPE_DEFAULT
85 - Revision: DOT11_BSSID_LIST_REVISION_1
86 - Size: sizeof(DOT11_BSSID_LIST)
87 - uNumOfEntries
88 The number of entries in this structure.
89 - uTotalNumOfEntries
90 The total number of entries supported.
91 - BSSIDs
92 `https://msdn.microsoft.com/en-us/library/windows/desktop/
93 bb427397(v=vs.85).aspx`
94 A list of BSS identifiers.
95 - bssType
96 `https://msdn.microsoft.com/en-us/library/windows/desktop/
97 ms706001(v=vs.85).aspx`
98 Constants:
99 dot11_BSS_type_infrastructure = 1,
100 dot11_BSS_type_independent = 2,
101 dot11_BSS_type_any = 3
102 - flags
103 Constant: WLAN_CONNECTION_HIDDEN_NETWORK value: 0x00000001
104 Constant: WLAN_CONNECTION_ADHOC_JOIN_ONLY value: 0x00000002
105 Constant: WLAN_CONNECTION_IGNORE_PRIVACY_BIT value: 0x00000004
106 Constant: WLAN_CONNECTION_EAPOL_PASSTHROUGH value: 0x00000008
107 - password
108 '''
109 wifi_lib.connect(network, parameters)
110 return
111
112 def _disconnect(self):
113 '''
114 Disconnect from network.
115 '''
116 wifi_lib.disconnect()
117 return
118
119
120 def instance():
121 return WindowWifi()