Add security types for AP 45/282545/1
authorchaehee-hong <chaehee.hong@samsung.com>
Wed, 5 Oct 2022 08:53:31 +0000 (17:53 +0900)
committerchaehee-hong <chaehee.hong@samsung.com>
Wed, 5 Oct 2022 08:53:37 +0000 (17:53 +0900)
Change-Id: Ia2a149beed196bbd0f0d1f73c3bb0698719f715e

SettingWiFi/SettingWiFi/AP.cs
SettingWiFi/SettingWiFi/WiFi.cs
SettingWiFi/SettingWiFi/WidgetSettingWiFi.cs
packaging/org.tizen.cssetting-wifi-1.0.0.tpk

index 3a445c4fa0170a7dcbb6a529a940275dde817fb0..d3944064f63a03475fbb18004c48a39f313c03da 100755 (executable)
@@ -14,10 +14,9 @@ namespace SettingWiFi
     public class AP : INotifyPropertyChanged\r
     {\r
         string iconDir = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "icon.png";\r
-        string infoIconDir = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "icon.png";\r
         private string essid;\r
         private string state;\r
-        private string stateText;\r
+\r
         public event PropertyChangedEventHandler PropertyChanged;\r
 \r
         private void OnPropertyChanged(string propertyName)\r
@@ -29,7 +28,7 @@ namespace SettingWiFi
         public AP(string apEssid, string apState)\r
         {\r
             essid = apEssid;\r
-            stateText = apState;\r
+            state = apState;\r
         }\r
 \r
         public string Essid\r
@@ -65,30 +64,8 @@ namespace SettingWiFi
                 OnPropertyChanged("State");\r
             }\r
         }\r
-\r
-        public string StateText\r
-        {\r
-            get\r
-            {\r
-                return stateText;\r
-            }\r
-            set\r
-            {\r
-                stateText = value;\r
-                OnPropertyChanged("StateText");\r
-            }\r
-        }\r
-\r
-        public string Info\r
-        {\r
-            get\r
-            {\r
-                return infoIconDir;\r
-            }\r
-        }\r
     };\r
 \r
-\r
     public class DeviceCollection : ObservableCollection<AP>\r
     {\r
         private string title;\r
@@ -114,7 +91,6 @@ namespace SettingWiFi
 \r
         public void UpdateScanList(List<AP> apList)\r
         {\r
-            Log.Debug(Program.LogTag, "UpdateDevices");\r
             if (apList == null)\r
             {\r
                 Log.Debug(Program.LogTag, "apList is null");\r
@@ -130,7 +106,7 @@ namespace SettingWiFi
 \r
             foreach (var item in apList)\r
             {\r
-                this.Add(new AP(item.Essid, item.StateText));\r
+                this.Add(new AP(item.Essid, item.State));\r
             }\r
         }\r
 \r
@@ -153,7 +129,7 @@ namespace SettingWiFi
             this.Add(available);\r
             Log.Debug(Program.LogTag, "Add DeviceCollection");\r
         }\r
-        public void UpdateDevices(List<AP> apList)\r
+        public void UpdateScanList(List<AP> apList)\r
         {\r
             available.UpdateScanList(apList);\r
         }\r
index aa63a1b3339296448177f4c0e2e4105b3401cb65..b6e1a2b6b6a6443cb54d49d9d7e6dd8e0ca7ba6b 100755 (executable)
@@ -137,8 +137,38 @@ namespace SettingWiFi
             foreach (var item in apList)\r
             {\r
                 Log.Debug(Program.LogTag, "AP name: " + item.NetworkInformation.Essid);\r
-                //Log.Debug(LogTag, "Connection state: " + item.NetworkInformation.ConnectionState);\r
-                apInfoList.Add(new AP(item.NetworkInformation.Essid, item.NetworkInformation.ConnectionState.ToString()));\r
+                Log.Debug(Program.LogTag, "AP connection state: " + item.NetworkInformation.ConnectionState.ToString());\r
+\r
+                string connectionState = item.NetworkInformation.ConnectionState.ToString();\r
+                string securityType = item.SecurityInformation.SecurityType.ToString();\r
+                //bool isPassphraseRequired = item.SecurityInformation.IsPassphraseRequired;\r
+                bool isWpsSupported = item.SecurityInformation.IsWpsSupported;\r
+\r
+                if (item.NetworkInformation.ConnectionState.ToString().Equals("Connected"))\r
+                {\r
+                    apInfoList.Add(new AP(item.NetworkInformation.Essid, "Connected"));\r
+                    continue;\r
+                }\r
+                string text = "";\r
+\r
+                if (securityType.Equals("None"))\r
+                {\r
+                    text = "Open";\r
+                }\r
+                else if (securityType.Equals("Eap"))\r
+                {\r
+                    text = "Secured (Eap)";\r
+                }\r
+                else if (isWpsSupported)\r
+                {\r
+                    text = "Secured (WPS available)";\r
+                }\r
+                else\r
+                {\r
+                    text = "Secured";\r
+                }\r
+\r
+                apInfoList.Add(new AP(item.NetworkInformation.Essid, text));\r
             }\r
 \r
             return apInfoList;\r
index 37a04163f4884ba1d357173f9f928e8d3eeefabd..b9fedbaac0a50fe070615a1a6e6ac78f70422f96 100755 (executable)
@@ -126,18 +126,28 @@ namespace SettingWiFi
                 ItemsLayouter = new LinearLayouter(),\r
                 ItemTemplate = new DataTemplate(() =>\r
                 {\r
-                    DefaultLinearItem item = new DefaultLinearItem();\r
-                    item.WidthSpecification = LayoutParamPolicies.MatchParent;\r
+                    DefaultLinearItem item = new DefaultLinearItem() //itemÀÌ °¢ AP\r
+                    {\r
+                        WidthSpecification = LayoutParamPolicies.MatchParent,\r
+                    };\r
                     item.Label.SetBinding(TextLabel.TextProperty, "Essid");\r
-\r
                     item.Label.HorizontalAlignment = HorizontalAlignment.Begin;\r
-                    item.SubLabel.SetBinding(TextLabel.TextProperty, "StateText");\r
-\r
+                    item.SubLabel.SetBinding(TextLabel.TextProperty, "State");\r
                     item.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;\r
                     item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");\r
                     item.Icon.WidthSpecification = 40;\r
                     item.Icon.HeightSpecification = 40;\r
 \r
+                    var infoButton = new Button()\r
+                    {\r
+                        Text = "i",\r
+                        WidthSpecification = 40,\r
+                        HeightSpecification = 40,\r
+                    };\r
+                    //infoButton.Icon.SetBinding(ImageView.ResourceUrlProperty, "InfoImageUrl");\r
+                    infoButton.Clicked += OnInfoButtonClicked;\r
+                    item.Extra = infoButton;\r
+\r
                     return item;\r
                 }),\r
                 GroupHeaderTemplate = new DataTemplate(() =>\r
@@ -179,7 +189,7 @@ namespace SettingWiFi
             return page;\r
         }\r
 \r
-        private ContentPage CreateInfoPage()\r
+        private ContentPage CreateInfoPage(AP ap)\r
         {\r
             var appBar = new AppBar()\r
             {\r
@@ -211,7 +221,13 @@ namespace SettingWiFi
                 WidthSpecification = 300,\r
                 HeightSpecification = 80,\r
             };\r
-            forgetButton.Clicked += OnforgetButtonClicked;\r
+\r
+            forgetButton.Clicked += (object source, ClickedEventArgs args) =>\r
+            {\r
+                Log.Debug(Program.LogTag, "Forget " + ap.Essid);\r
+                wifi.Forget(ap.Essid);\r
+                ScanAP();\r
+            };\r
 \r
             infoView.Add(forgetButton);\r
             ContentPage page = new ContentPage()\r
@@ -265,7 +281,6 @@ namespace SettingWiFi
             apSource = new APSource();\r
 \r
             mainPage = CreateMainPage();\r
-            infoPage = CreateInfoPage();\r
             morePage = CreatemorePage();\r
 \r
             navigator.Push(mainPage);\r
@@ -299,10 +314,12 @@ namespace SettingWiFi
             ScanAP();\r
         }\r
 \r
-        private void OnforgetButtonClicked(object sender, ClickedEventArgs e)\r
+        private void OnInfoButtonClicked(object sender, ClickedEventArgs e)\r
         {\r
-            Log.Debug(Program.LogTag, "OnforgetButtonClicked");\r
-            //wifi.Forget(essid);\r
+            Log.Debug(Program.LogTag, "OnInfoButtonClicked");\r
+            Button button = (Button)sender;\r
+            infoPage = CreateInfoPage(button.BindingContext as AP);\r
+            navigator.Push(infoPage);\r
         }\r
 \r
         private bool IsWiFiActive()\r
@@ -316,21 +333,17 @@ namespace SettingWiFi
             {\r
                 await wifi.Scan();\r
                 List<AP> apList = wifi.GetScanResult();\r
-                apSource.UpdateDevices(apList);\r
+                apSource.UpdateScanList(apList);\r
             }\r
         }\r
 \r
         public async void OnScanListSelected(object sender, SelectionChangedEventArgs ev)\r
         {\r
-            /* TODO: disable to click the connected ap */\r
-\r
-\r
-\r
             //SingleSelection Only have 1 or nil object in the list.\r
             foreach (object item in ev.PreviousSelection)\r
             {\r
                 if (item == null) break;\r
-                if (item is AP device)\r
+                if (item is AP ap)\r
                 {\r
                     //Log.Debug(LogTag, "Disconnect ");\r
                     //await wifi.Disconnect(device.Essid);\r
@@ -342,21 +355,20 @@ namespace SettingWiFi
             foreach (object item in ev.CurrentSelection)\r
             {\r
                 if (item == null) break;\r
-                if (item is AP device)\r
+                if (item is AP ap)\r
                 {\r
-                    if (device.StateText.Equals("Connected"))\r
+                    if (ap.State.Equals("Connected"))\r
                     {\r
                         Log.Debug(Program.LogTag, "already connected");\r
                         return;\r
                     }\r
 \r
-                    Log.Debug(Program.LogTag, "new connect"); /* TODO: pop-up(password, cancel, connect) */\r
-                    device.StateText = "Connecting";\r
-                    await wifi.Connect(device.Essid, "datanetwork");\r
-                    if(wifi.GetConnectedAP().Equals(device.Essid))\r
+                    /* TODO: pop-up (password, cancel, connect) */\r
+                    ap.State = "Connecting";\r
+                    await wifi.Connect(ap.Essid, "datanetwork");\r
+                    if(wifi.GetConnectedAP().Equals(ap.Essid))\r
                     {\r
-                        device.StateText = "Connected";\r
-\r
+                        ap.State = "Connected";\r
                     }\r
                     //  device.Connected = true;\r
                     //  device.Registered = true;\r
index 4696b3254130a7f34690bdb6db2f29d1488916e5..419f78314271bd36d82101e00b70d42689fa2d23 100755 (executable)
Binary files a/packaging/org.tizen.cssetting-wifi-1.0.0.tpk and b/packaging/org.tizen.cssetting-wifi-1.0.0.tpk differ