// License: BSD/LGPL // Copyright (C) 2011 Thomas d'Otreppe using System; using System.Collections.Generic; using System.Text; namespace WirelessPanda { public class Station : WirelessDevice, IEquatable { private AccessPoint _ap = null; /// /// Access point /// public AccessPoint AP { get { return this._ap; } // Only allow to do it inside the lib internal set { this._ap = value; } } /// /// Station MAC /// public string StationMAC { get { return (string)this.getDictValue("Station MAC"); } set { if (value != null) { this.setDictValue("Station MAC", value.Trim()); } else { this.setDictValue("Station MAC", value); } } } /// /// # Packets /// public ulong NbPackets { get { return (ulong)this.getDictValue("# Packets"); } set { this.setDictValue("# Packets", value); } } /// /// Probed ESSIDs (comma separated) /// public string ProbedESSIDs { get { return (string)this.getDictValue("Probed ESSIDs"); } set { this.setDictValue("Probed ESSIDs", value); // Update probe ESSID list this._probedESSIDsList.Clear(); if (string.IsNullOrEmpty(value)) { foreach (string s in value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (string.IsNullOrEmpty(s.Trim())) { continue; } // Add ESSID this._probedESSIDsList.Add(s); } } } } private List _probedESSIDsList = new List(); /// /// Probed ESSIDs List /// public string[] ProbedESSIDsList { get { return _probedESSIDsList.ToArray().Clone() as string[]; } set { this._probedESSIDsList.Clear(); this.setDictValue("Probed ESSIDs", string.Empty); if (value != null && value.Length > 0) { this._probedESSIDsList.AddRange(value); // Generate the string list of SSID StringBuilder sb = new StringBuilder(string.Empty); foreach (string s in value) { sb.AppendFormat("{0}, ", s); } string res = sb.ToString(); if (res.Length > 0) { res = res.Substring(0, res.Length - 2); } // And put it in the Probed ESSIDs dictionary item this.setDictValue("Probed ESSIDs", res); } } } /// /// Implements IEquatable /// /// Other Station to compare to /// true if equals, false if not public bool Equals(Station other) { try { if (this.StationMAC == other.StationMAC) { return true; } } catch { } return false; } } }