{\r
await apHandle.ConnectAsync();\r
}\r
+ catch (InvalidKeyException e)\r
+ {\r
+ Error("Failed to connect " + e.Message + " : " + e.Source);\r
+ throw new WrongPasswordEntered(e.Message);\r
+ }\r
catch (Exception e)\r
{\r
- Debug("Fail to connect" + e.ToString());\r
+ Error("Failed to connect " + e.ToString());\r
}\r
}\r
\r
private WiFi mWifi;
private TextField mPasswordField;
private Button mConnectButton;
+ private Window mWindow = NUIApplication.GetDefaultWindow();
internal ConnectPage(WiFi wifi)
{
private async void Connect()
{
Debug("Connect");
- //mAp.StateInfo = Resources.IDS_WIFI_BODY_CONNECTING_ING;
- await mWifi.Connect(mAp, mPasswordField.Text);
+ try
+ {
+ await mWifi.Connect(mAp, mPasswordField.Text);
- if(mWifi.GetConnectedAP().Equals(mAp.Essid))
+ if(mWifi.GetConnectedAP().Equals(mAp.Essid))
+ {
+ mAp.StateInfo = Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS;
+ }
+ }
+ catch (WrongPasswordEntered e)
+ {
+ Error("Connection failed due to wrong password " + e.Message);
+ mPasswordField.Text = "";
+ mWindow.GetDefaultNavigator().Push(this);
+ }
+ catch (Exception e)
{
- mAp.StateInfo = Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS;
+ Error("Error other than wrong password " + e.Message);
}
}
}
}
}
+
+ internal class WrongPasswordEntered : InvalidOperationException
+ {
+ public WrongPasswordEntered(string message) : base(message)
+ {
+ }
+ }
}