//public connector(string[] profiles) public connector() { //read config values _profiles = new string[] { _myConfig._profile1, _myConfig._profile2 }; _bcheckOnUndock = _myConfig._checkOnUndock; _bcheckOnResume = _myConfig._checkOnResume; _bswitchOnDisconnect = _myConfig._switchOnDisconnect; _iSwitchTimeout = _myConfig._switchTimeout; _benableLogging = _myConfig._enableLogging; #if DEBUG Logger.bEnableLogging = true; #else Logger.bEnableLogging = _benableLogging; #endif //_profiles = profiles; evtStopThreads.Reset(); // clear event OnConnectedMessage("connector initialized with profiles: "); try { _wifi = new wifi(); } catch (Exception) { throw new NotSupportedException("FUNK not active"); } //list profiles and disable all first, only one should be enabled //foreach (string s in _profiles) //{ // OnConnectedMessage("\t" + s); // _wifi.enableProfile(s, false); //} _wifi.setProfile(_profiles[0]); //enable primary profile _workThread = new Thread(new ThreadStart(myWorkerThread)); _workThread.Name = "myWorkerThread"; _workThread.Start(); _connectThread = new Thread(new ThreadStart(connectWatchThread)); _connectThread.Name = "connectWatchThread"; _connectThread.Start(); _timerThread = new Thread(new ThreadStart(timerThread)); _timerThread.Name = "timerThread"; _timerThread.Start(); _PowerSourceMessages = new PowerSourceChanges(); _PowerSourceMessages.powerChangedEvent += new PowerSourceChanges.powerChangeEventHandler(_powerSourceMessages_powerChangedEvent); _PowerMessages = new PowerMessages(); _PowerMessages.powerChangedEvent += new PowerMessages.powerChangeEventHandler(_PowerMessages_powerChangedEvent); OnConnectedMessage("connector started"); }
public Form1() { InitializeComponent(); //we have to wait for the Windows APIs being loaded... WinAPIReady winReady = new WinAPIReady(); int maxWait = 20; do { System.Threading.Thread.Sleep(1000); maxWait--; } while (winReady.ApiIsReay == false && maxWait > 0); winReady.Dispose(); try { _wifi = new wifi(); isFUNK = true; MobileConfiguration myConfig = new MobileConfiguration(); button1.Text = myConfig._profile1; button2.Text = myConfig._profile2; } catch (NotSupportedException ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (isFUNK) { btnStart.Enabled = true; _network = new network(); addLog("Network start: " + (network._getConnected() ? "connected" : "disconnected")); timerMinimize.Interval = 5000; timerMinimize.Tick += new EventHandler(timerMinimize_Tick); timerMinimize.Enabled = true; startConnector(); updateButtons(); } else { MessageBox.Show("Current security client is not supported"); Logger.WriteLine("Current security client is not supported"); } //_network.networkChangedEvent += new network.networkChangeEventHandler(_network_networkChangedEvent); }
void stopConnector() { if (_connector == null) { return; } addLog("STOP connector..."); _connector.Dispose(); _connector = null; if (_wifi != null) { _wifi.Dispose(); _wifi = null; } addLog("connector stopped."); }
public void Dispose() { if (backgroundThread != null) { _bStopThread = true; Thread.Sleep(1000); if (backgroundThread != null) { backgroundThread.Abort(); } } if (_wifi != null) { _wifi.Dispose(); _wifi = null; } }
public network() { _wifi = new wifi(); backgroundThread = new Thread(new ThreadStart(myThread)); backgroundThread.Start(); }