/// <summary> /// Start the session, if possible. /// </summary> private void HandleSessionStart() { // Check if the KCD has already sent us the end session event. if (SessionIDTree.ContainsKey(SessionID)) { HandleSessionTrouble(new Exception("the KCD closed the connection unexpectedly")); return; } // Clear the session ID tree. SessionIDTree.Clear(); // Show the overlay window. Overlay = new RunningOverlay(); Overlay.Relink(this); // Configure the inactivity monitor to timeout about 10 minutes. InactivityMonitor = MonitorCreator.CreateInstance(MonitorType.GlobalHookMonitor); InactivityMonitor.MonitorKeyboardEvents = true; InactivityMonitor.MonitorMouseEvents = true; InactivityMonitor.Interval = 600000; InactivityMonitor.Elapsed += delegate(Object sender, ElapsedEventArgs args) { KBase.ExecInUI(OnInactivity); }; InactivityMonitor.Enabled = true; // Start the session. Status = VncSessionStatus.Started; // Notify listeners. PostLocalVncSessionEvent(true, null); Kws.OnStateChange(WmStateChange.Transient); }
/// <summary> /// Helper method to start a session. /// </summary> private byte[] StartSession(bool serverSessionFlag, bool supportFlag, int windowHandle, String subject, UInt64 sessionID) { // Throw if we cannot open the session. if (AppVnc.SessionPresentFlag) { throw new Exception("a screen sharing session is already running"); } if (!IsOnlineCapable()) { throw new Exception("the " + KwmStrings.Kws + " is not connected to the server"); } // Remember that we have started a session. SessionPresentFlag = true; // Create the local session object. LocalSession = new VncLocalSession(this); LocalSession.ServerSessionFlag = serverSessionFlag; LocalSession.SupportSessionFlag = supportFlag; LocalSession.WindowHandle = windowHandle; LocalSession.Subject = subject; LocalSession.SessionID = sessionID; // Asynchronously start the session. KBase.ExecInUI(LocalSession.HandleNextSessionStep); Kws.OnStateChange(WmStateChange.Transient); return(LocalSession.SessionUuid); }
/// <summary> /// Request the state machine to run, if required. /// </summary> private void RequestRun() { if (WantToRunNow() && m_wakeUpMsg == null) { m_wakeUpMsg = new KmodBrokerWakeUpMsg(this); KBase.ExecInUI(new KBase.EmptyDelegate(m_wakeUpMsg.Run)); } }
/// <summary> /// Notify the WM that something occurred. Assume mutex is locked. /// </summary> private void NotifyWm() { if (m_wmWakeUpMsg == null) { m_wmWakeUpMsg = new KcdWmWakeUpMsg(this); KBase.ExecInUI(new KBase.EmptyDelegate(m_wmWakeUpMsg.Run)); } }
/// <summary> /// Called when the login fails with KANP_KWS_LOGIN_BAD_PWD_OR_TICKET. /// </summary> private void HandleBadPwdOrTicket(KwsConnectRes r) { // Remember that the workspace is secure and if a password is available. m_kws.Cd.Credentials.SecureFlag = r.SecureFlag; m_ks.PwdPresentFlag = r.PwdOnKcdFlag; m_kws.OnStateChange(WmStateChange.Permanent); // The cached step has failed. if (m_currentStep == KwsLoginStep.Cached) { // Only the cached step was allowed. We're done. if (m_loginType == KwsLoginType.Cached) { HandleLoginFailure(KwsLoginResult.BadSecurityCreds, new Exception("security credentials refused")); return; } // We can perform the ticket step. if (KwmCfg.Cur.CanLoginOnKps()) { HandleTicketLoginStep(); return; } } // The ticket step has failed. else if (m_currentStep == KwsLoginStep.Ticket) { // Log the ticket refusal string. KLogging.Log("Ticket refused: " + r.ErrMsg); } // There is no password on the KCD. if (!m_ks.PwdPresentFlag) { HandleLoginFailure(KwsLoginResult.BadSecurityCreds, new Exception("a password must be assigned to you")); return; } // The password provided is bad. if (m_currentStep == KwsLoginStep.Pwd) { // Execute that asynchronously since we want our state to be // predictable. if (OnSetLoginPwdRefused != null) { KBase.ExecInUI(OnSetLoginPwdRefused); } } // We need a password. HandlePwdLoginStep(); }
private static void Main(String[] args) { // Initialize our application. AppInit(); // Parse the command line. ParseCmdLine(args); // We can catch fatal errors here without risking an infinite KWM // spawn loop. WmUi.FatalErrorMsgOKFlag = true; // Execute the bootstrap method when the message loop is running. KBase.ExecInUI(new KBase.EmptyDelegate(Bootstrap)); // Run the message loop. Application.Run(); }
/// <summary> /// Queue the request to be executed. /// </summary> public void Queue() { KBase.ExecInUI(InternalQueue); }