Esempio n. 1
0
        public void TestGetNetworkNames()
        {
            Assert.AreEqual(4, Netshell.GetNetworkNames(enGB_profiles).Count);
            Assert.AreEqual(2, Netshell.GetNetworkNames(frFR_profiles).Count);
            Assert.AreEqual(12, Netshell.GetNetworkNames(itIT_profiles).Count);

            // Don't dupe networks when there are multiple adapters!
            Assert.AreEqual(2, Netshell.GetNetworkNames(dupe_adapter_profiles).Count);
        }
Esempio n. 2
0
        /// <summary>
        ///     Get a full network based on the network name. Requires netshell access.
        /// </summary>
        /// <param name="name"></param>
        public WlanNetwork(string name)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("Name cannot be empty");
            }

            _name = name;
            string output = Netshell.NetshellCmd(PrepareCommand(CmdDetail));

            try
            {
                _interface = parseInterface(output);

                _allUsers = (String.Equals(getFieldFromOutput(output, "Applied"), "All User Profile",
                                           StringComparison.Ordinal));
                _version                 = Int32.Parse(getFieldFromOutput(output, "Version"));
                _profileType             = getFieldFromOutput(output, "Type");
                _name                    = getFieldFromOutput(output, "Name");
                _connectWithoutBroadcast = (!String.Equals(getFieldFromOutput(output, "Network broadcast"),
                                                           "Connect only if this network is broadcasting", StringComparison.Ordinal));
                _autoconnect = (String.Equals(getFieldFromOutput(output, "Connection mode"), "Connect automatically",
                                              StringComparison.Ordinal));
                _autoswitch = (String.Equals(getFieldFromOutput(output, "AutoSwitch"),
                                             "Switch to more preferred network if possible", StringComparison.Ordinal));
                _macRandomization = (String.Equals(getFieldFromOutput(output, "MAC Randomization"), "Enabled",
                                                   StringComparison.Ordinal));
                _ssidCount   = Int32.Parse(getFieldFromOutput(output, "Number of SSIDs"));
                _ssidName    = getFieldFromOutput(output, "SSID name");
                _networkType = getFieldFromOutput(output, "Network type");
                _radioType   = getFieldFromOutput(output, "Radio type");

                _authentication = getFieldFromOutput(output, "Authentication");
                _cipher         = getFieldFromOutput(output, "Cipher");
                _securityKey    = (String.Equals(getFieldFromOutput(output, "Security key"), "Present",
                                                 StringComparison.Ordinal));

                _cost = getFieldFromOutput(output, "Cost");

                _congested        = (getFieldFromOutput(output, "Congested") == "Yes");
                _approachingLimit = (getFieldFromOutput(output, "Approaching Data Limit") == "Yes");
                _overLimit        = (getFieldFromOutput(output, "Over Data Limit") == "Yes");
                _roaming          = (getFieldFromOutput(output, "Roaming") == "Yes");
                _costSource       = getFieldFromOutput(output, "Cost Source");
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    "The application encountered an unexpected error while parsing a network. You can continue using the app, but some profiles may be missing. Please report this error to the developer (\"http://github.com/Bertware/Wlan10/Issues\")\r\n" +
                    "Error details:\r\n" +
                    e.Message + "\r\n"
                    + e.StackTrace + "\r\n\r\n" +
                    output, "Unexpected error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 3
0
 /// <summary>
 ///     Forget this network
 /// </summary>
 public void ForgetNetwork()
 {
     Netshell.NetshellCmd(PrepareCommand(CmdDelete));
 }
Esempio n. 4
0
 /// <summary>
 ///     Set the priority for this network
 /// </summary>
 /// <param name="priority"></param>
 public void SetPriority(int priority)
 {
     Netshell.NetshellCmd(PrepareCommand(CmdUpdate).Replace("<priority>", priority.ToString()));
 }
Esempio n. 5
0
 /// <summary>
 ///     Set the network key (WEP/WPA/WPA2) for this network
 /// </summary>
 /// <param name="key"></param>
 public void SetKey(string key)
 {
     Netshell.NetshellCmd(PrepareCommand(CmdSetKey).Replace("<key>", key));
 }