Add WiFiAP to AP class 93/282793/1
authorcheoleun moon <chleun.moon@samsung.com>
Tue, 11 Oct 2022 13:19:12 +0000 (22:19 +0900)
committercheoleun moon <chleun.moon@samsung.com>
Tue, 11 Oct 2022 13:19:20 +0000 (22:19 +0900)
Change-Id: I3b327b5c60b37878c52786344c2d3c6a2c24ecf0

SettingWiFi/SettingWiFi/Logger.cs [new file with mode: 0644]
SettingWiFi/SettingWiFi/controller/WiFi.cs
SettingWiFi/SettingWiFi/model/AP.cs [new file with mode: 0755]
SettingWiFi/SettingWiFi/view/AP.cs [deleted file]
SettingWiFi/SettingWiFi/view/APSource.cs [new file with mode: 0755]
SettingWiFi/SettingWiFi/view/ConnectPage.cs
SettingWiFi/SettingWiFi/view/Logger.cs [deleted file]

diff --git a/SettingWiFi/SettingWiFi/Logger.cs b/SettingWiFi/SettingWiFi/Logger.cs
new file mode 100644 (file)
index 0000000..9b58722
--- /dev/null
@@ -0,0 +1,24 @@
+using Tizen;
+
+namespace SettingWiFi
+{
+    internal class Logger
+    {
+        internal static readonly string LogTag = "SettingWiFi.App";
+
+        internal static void Debug(string msg)
+        {
+            Log.Debug(LogTag, msg);
+        }
+
+        internal static void Info(string msg)
+        {
+            Log.Info(LogTag, msg);
+        }
+
+        internal static void Error(string msg)
+        {
+            Log.Error(LogTag, msg);
+        }
+    }
+}
\ No newline at end of file
index 03f454e8a4e8b0e254c552975c52f2f719bc447a..d37f74a9f98e022f3ec820c3a779e9850df4168c 100755 (executable)
@@ -61,24 +61,25 @@ namespace SettingWiFi
             return null;\r
         }\r
 \r
-        public async Task Connect(string essid, string password)\r
+        public async Task Connect(AP ap, string password)\r
         {\r
             Debug("WiFi.Connect");\r
-            WiFiAP ap = FindAP(essid);\r
+\r
             if (ap == null)\r
             {\r
-                Debug("Cannet find " + essid);\r
+                Debug("Cannot find AP");\r
                 return;\r
             }\r
 \r
+            WiFiAP apHandle = ap.ApHandle;\r
             if (password.Length > 0)\r
             {\r
-                ap.SecurityInformation.SetPassphrase(password);\r
+                apHandle.SecurityInformation.SetPassphrase(password);\r
             }\r
 \r
             try\r
             {\r
-                await ap.ConnectAsync();\r
+                await apHandle.ConnectAsync();\r
             }\r
             catch (Exception e)\r
             {\r
@@ -159,7 +160,7 @@ namespace SettingWiFi
 \r
                 if (item.NetworkInformation.ConnectionState.ToString().Equals(Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS))\r
                 {\r
-                    apInfoList.Add(new AP(item.NetworkInformation.Essid, Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS, securityType, isWpsSupported));\r
+                    apInfoList.Add(new AP(item, item.NetworkInformation.Essid, Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS, securityType, isWpsSupported));\r
                     continue;\r
                 }\r
                 string text = "";\r
@@ -181,7 +182,7 @@ namespace SettingWiFi
                     text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY;\r
                 }\r
 \r
-                apInfoList.Add(new AP(item.NetworkInformation.Essid, text, securityType, isWpsSupported));\r
+                apInfoList.Add(new AP(item, item.NetworkInformation.Essid, text, securityType, isWpsSupported));\r
             }\r
 \r
             return apInfoList;\r
diff --git a/SettingWiFi/SettingWiFi/model/AP.cs b/SettingWiFi/SettingWiFi/model/AP.cs
new file mode 100755 (executable)
index 0000000..9a743d0
--- /dev/null
@@ -0,0 +1,97 @@
+using System;\r
+using System.ComponentModel;\r
+using System.Collections.Generic;\r
+using System.Collections.ObjectModel;\r
+using Tizen;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI.Components;\r
+using Tizen.NUI.Binding;\r
+using Tizen.Network.WiFi;\r
+using SettingWiFi.res.locale;\r
+using static SettingWiFi.Logger;\r
+\r
+\r
+namespace SettingWiFi\r
+{\r
+    public class AP : INotifyPropertyChanged\r
+    {\r
+        string iconDir = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "icon.png";\r
+        private string essid;\r
+        private string state;\r
+        private string secType;\r
+        private bool isWps;\r
+\r
+        public event PropertyChangedEventHandler PropertyChanged;\r
+\r
+        private void OnPropertyChanged(string propertyName)\r
+        {\r
+            Debug("OnPropertyChanged");\r
+            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));\r
+        }\r
+\r
+        public AP(WiFiAP apHandle, string apEssid, string apState, string apSecType, bool apIsWps)\r
+        {\r
+            ApHandle = apHandle;\r
+            essid = apEssid;\r
+            state = apState;\r
+            secType = apSecType;\r
+            isWps = apIsWps;\r
+        }\r
+\r
+        public WiFiAP ApHandle\r
+        {\r
+            get;\r
+            set;\r
+        }\r
+\r
+        public string Essid\r
+        {\r
+            get\r
+            {\r
+                return essid;\r
+            }\r
+            set\r
+            {\r
+                essid = value;\r
+                OnPropertyChanged("Essid");\r
+            }\r
+        }\r
+\r
+        public string ImageUrl\r
+        {\r
+            get\r
+            {\r
+                return iconDir;\r
+            }\r
+        }\r
+\r
+        public string State\r
+        {\r
+            get\r
+            {\r
+                return state;\r
+            }\r
+            set\r
+            {\r
+                state = value;\r
+                OnPropertyChanged("State");\r
+            }\r
+        }\r
+\r
+        public string SecType\r
+        {\r
+            get\r
+            {\r
+                return secType;\r
+            }\r
+        }\r
+\r
+        public bool IsWps\r
+        {\r
+            get\r
+            {\r
+                return isWps;\r
+            }\r
+        }\r
+    };\r
+}
\ No newline at end of file
diff --git a/SettingWiFi/SettingWiFi/view/AP.cs b/SettingWiFi/SettingWiFi/view/AP.cs
deleted file mode 100755 (executable)
index d335009..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-using System;\r
-using System.ComponentModel;\r
-using System.Collections.Generic;\r
-using System.Collections.ObjectModel;\r
-using Tizen;\r
-using Tizen.NUI.BaseComponents;\r
-using Tizen.NUI.Components;\r
-using Tizen.NUI.Binding;\r
-using Tizen.Network.WiFi;\r
-using SettingWiFi.res.locale;\r
-using static SettingWiFi.Logger;\r
-\r
-\r
-namespace SettingWiFi\r
-{\r
-    public class AP : INotifyPropertyChanged\r
-    {\r
-        string iconDir = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "icon.png";\r
-        private string essid;\r
-        private string state;\r
-        private string secType;\r
-        private bool isWps;\r
-\r
-        public event PropertyChangedEventHandler PropertyChanged;\r
-\r
-        private void OnPropertyChanged(string propertyName)\r
-        {\r
-            Debug("OnPropertyChanged");\r
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));\r
-        }\r
-\r
-        public AP(string apEssid, string apState, string apSecType, bool apIsWps)\r
-        {\r
-            essid = apEssid;\r
-            state = apState;\r
-            secType = apSecType;\r
-            isWps = apIsWps;\r
-        }\r
-\r
-        public string Essid\r
-        {\r
-            get\r
-            {\r
-                return essid;\r
-            }\r
-            set\r
-            {\r
-                essid = value;\r
-                OnPropertyChanged("Essid");\r
-            }\r
-        }\r
-\r
-        public string ImageUrl\r
-        {\r
-            get\r
-            {\r
-                return iconDir;\r
-            }\r
-        }\r
-\r
-        public string State\r
-        {\r
-            get\r
-            {\r
-                return state;\r
-            }\r
-            set\r
-            {\r
-                state = value;\r
-                OnPropertyChanged("State");\r
-            }\r
-        }\r
-\r
-        public string SecType\r
-        {\r
-            get\r
-            {\r
-                return secType;\r
-            }\r
-        }\r
-\r
-        public bool IsWps\r
-        {\r
-            get\r
-            {\r
-                return isWps;\r
-            }\r
-        }\r
-    };\r
-\r
-    public class DeviceCollection : ObservableCollection<AP>\r
-    {\r
-        private string title;\r
-\r
-        public DeviceCollection(string groupTitle)\r
-        {\r
-            title = groupTitle;\r
-            this.UpdateScanList(null);\r
-        }\r
-\r
-        public string Title\r
-        {\r
-            get\r
-            {\r
-                return title;\r
-            }\r
-            set\r
-            {\r
-                title = value;\r
-                OnPropertyChanged(new PropertyChangedEventArgs("Title"));\r
-            }\r
-        }\r
-\r
-        public void UpdateScanList(List<AP> apList)\r
-        {\r
-            if (apList == null)\r
-            {\r
-                Debug("apList is null");\r
-                this.Add(new AP("", "", "", false));\r
-                return;\r
-            }\r
-            // Clear method have some issue about asynchronous actions,\r
-            // so call Remove for all item is recommanded.\r
-            while (this.Count > 0)\r
-            {\r
-                this.RemoveAt(this.Count - 1);\r
-            }\r
-\r
-            foreach (var item in apList)\r
-            {\r
-                this.Add(new AP(item.Essid, item.State, item.SecType, item.IsWps));\r
-            }\r
-        }\r
-\r
-        public void RemoveScanList()\r
-        {\r
-            while (this.Count > 0)\r
-            {\r
-                this.RemoveAt(this.Count - 1);\r
-            }\r
-        }\r
-\r
-        public void UpdateState(AP ap)\r
-        {\r
-            string text = "";\r
-\r
-            if (ap.SecType.Equals(Resources.IDS_ST_BODY_NONE))\r
-            {\r
-                text = Resources.IDS_WIFI_POP_OPEN;\r
-            }\r
-            else if (ap.SecType.Equals(Resources.IDS_WIFI_BODY_EAP))\r
-            {\r
-                text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY + " (Eap)";\r
-            }\r
-            else if (ap.IsWps)\r
-            {\r
-                text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY + " (WPS available)";\r
-            }\r
-            else\r
-            {\r
-                text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY;\r
-            }\r
-\r
-            ap.State = text;\r
-        }\r
-    }\r
-\r
-    public class APSource : ObservableCollection<DeviceCollection>\r
-    {\r
-        private DeviceCollection available;\r
-        public APSource()\r
-        {\r
-            available = new DeviceCollection("Available networks");\r
-            this.Add(available);\r
-        }\r
-\r
-        public void UpdateScanList(List<AP> apList)\r
-        {\r
-            available.UpdateScanList(apList);\r
-        }\r
-\r
-        public void RemoveScanList()\r
-        {\r
-            available.RemoveScanList();\r
-        }\r
-\r
-        public void UpdateState(AP ap)\r
-        {\r
-            available.UpdateState(ap);\r
-        }\r
-    }\r
-}
\ No newline at end of file
diff --git a/SettingWiFi/SettingWiFi/view/APSource.cs b/SettingWiFi/SettingWiFi/view/APSource.cs
new file mode 100755 (executable)
index 0000000..a4076f2
--- /dev/null
@@ -0,0 +1,117 @@
+using System;\r
+using System.ComponentModel;\r
+using System.Collections.Generic;\r
+using System.Collections.ObjectModel;\r
+using Tizen;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI.Components;\r
+using Tizen.NUI.Binding;\r
+using Tizen.Network.WiFi;\r
+using SettingWiFi.res.locale;\r
+using static SettingWiFi.Logger;\r
+\r
+\r
+namespace SettingWiFi\r
+{\r
+    public class DeviceCollection : ObservableCollection<AP>\r
+    {\r
+        private string title;\r
+\r
+        public DeviceCollection(string groupTitle)\r
+        {\r
+            title = groupTitle;\r
+            this.UpdateScanList(null);\r
+        }\r
+\r
+        public string Title\r
+        {\r
+            get\r
+            {\r
+                return title;\r
+            }\r
+            set\r
+            {\r
+                title = value;\r
+                OnPropertyChanged(new PropertyChangedEventArgs("Title"));\r
+            }\r
+        }\r
+\r
+        public void UpdateScanList(List<AP> apList)\r
+        {\r
+            if (apList == null)\r
+            {\r
+                Debug("apList is null");\r
+                this.Add(new AP(null, "", "", "", false));\r
+                return;\r
+            }\r
+            // Clear method have some issue about asynchronous actions,\r
+            // so call Remove for all item is recommanded.\r
+            while (this.Count > 0)\r
+            {\r
+                this.RemoveAt(this.Count - 1);\r
+            }\r
+\r
+            foreach (var item in apList)\r
+            {\r
+                this.Add(new AP(item.ApHandle, item.Essid, item.State, item.SecType, item.IsWps));\r
+            }\r
+        }\r
+\r
+        public void RemoveScanList()\r
+        {\r
+            while (this.Count > 0)\r
+            {\r
+                this.RemoveAt(this.Count - 1);\r
+            }\r
+        }\r
+\r
+        public void UpdateState(AP ap)\r
+        {\r
+            string text = "";\r
+\r
+            if (ap.SecType.Equals(Resources.IDS_ST_BODY_NONE))\r
+            {\r
+                text = Resources.IDS_WIFI_POP_OPEN;\r
+            }\r
+            else if (ap.SecType.Equals(Resources.IDS_WIFI_BODY_EAP))\r
+            {\r
+                text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY + " (Eap)";\r
+            }\r
+            else if (ap.IsWps)\r
+            {\r
+                text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY + " (WPS available)";\r
+            }\r
+            else\r
+            {\r
+                text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY;\r
+            }\r
+\r
+            ap.State = text;\r
+        }\r
+    }\r
+\r
+    public class APSource : ObservableCollection<DeviceCollection>\r
+    {\r
+        private DeviceCollection available;\r
+        public APSource()\r
+        {\r
+            available = new DeviceCollection("Available networks");\r
+            this.Add(available);\r
+        }\r
+\r
+        public void UpdateScanList(List<AP> apList)\r
+        {\r
+            available.UpdateScanList(apList);\r
+        }\r
+\r
+        public void RemoveScanList()\r
+        {\r
+            available.RemoveScanList();\r
+        }\r
+\r
+        public void UpdateState(AP ap)\r
+        {\r
+            available.UpdateState(ap);\r
+        }\r
+    }\r
+}
\ No newline at end of file
index 80936515b8ae448524410ce158d0f1a910a6557a..df277e445dd34f8a065ffdd2e5b5d0b23664b29a 100644 (file)
@@ -82,15 +82,10 @@ namespace SettingWiFi
             Navigator.Pop();
         }
 
-        private async void Connect()
+        private void Connect()
         {
             mAp.State = Resources.IDS_WIFI_BODY_CONNECTING_ING;
-            await mWifi.Connect(mAp.Essid, "datanetwork");
-
-            if(mWifi.GetConnectedAP().Equals(mAp.Essid))
-            {
-                mAp.State = Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS;
-            }
+            mWifi.Connect(mAp, "datanetwork");
         }
     }
 }
\ No newline at end of file
diff --git a/SettingWiFi/SettingWiFi/view/Logger.cs b/SettingWiFi/SettingWiFi/view/Logger.cs
deleted file mode 100644 (file)
index 9b58722..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-using Tizen;
-
-namespace SettingWiFi
-{
-    internal class Logger
-    {
-        internal static readonly string LogTag = "SettingWiFi.App";
-
-        internal static void Debug(string msg)
-        {
-            Log.Debug(LogTag, msg);
-        }
-
-        internal static void Info(string msg)
-        {
-            Log.Info(LogTag, msg);
-        }
-
-        internal static void Error(string msg)
-        {
-            Log.Error(LogTag, msg);
-        }
-    }
-}
\ No newline at end of file