Ejemplo n.º 1
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
        /// <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);
        }
Ejemplo n.º 2
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
        /// <summary>
        /// Clean up the state when the session has completed to avoid resource
        /// leaks. This object CANNOT be reused for another session since some
        /// recently cancelled threads may still reference the object and try
        /// to modify its state.
        /// </summary>
        private void Terminate()
        {
            Status = VncSessionStatus.Completed;
            AppVnc.SessionPresentFlag = false;
            App.LocalSession          = null;

            if (Overlay != null)
            {
                Overlay.Terminate();
                Overlay = null;
            }

            if (TicketQuery != null)
            {
                TicketQuery.Terminate();
                TicketQuery = null;
            }

            if (Tunnel != null)
            {
                Tunnel.Terminate();
                Tunnel = null;
            }

            if (TunnelThread != null)
            {
                TunnelThread.RequestCancellation();
                TunnelThread = null;
            }

            if (MainProcess != null)
            {
                MainProcess.Terminate();
                MainProcess = null;
            }

            if (DummyProcess != null)
            {
                DummyProcess.Terminate();
                DummyProcess = null;
            }

            if (Timer != null)
            {
                Timer.WakeMeUp(-1);
                Timer = null;
            }

            if (InactivityMonitor != null)
            {
                InactivityMonitor.Enabled = false;
                InactivityMonitor.Dispose();
                InactivityMonitor = null;
            }
        }
Ejemplo n.º 3
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
        /// <summary>
        /// Request a ticket to the server.
        /// </summary>
        private void RequestTicket()
        {
            Status = VncSessionStatus.Ticket;
            UInt32 t = ServerSessionFlag ? KAnp.KANP_CMD_VNC_START_TICKET : KAnp.KANP_CMD_VNC_CONNECT_TICKET;
            AnpMsg m = Kws.NewKcdCmd(t);

            if (!ServerSessionFlag)
            {
                m.AddUInt64(SessionID);
            }
            TicketQuery = Kws.PostKcdCmd(m, OnTicketReply);
        }
Ejemplo n.º 4
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
        /// <summary>
        /// Start the main process.
        /// </summary>
        private void StartMainProcess()
        {
            Status = VncSessionStatus.MainProcess;

            // Handle server session miscellaneous actions.
            if (ServerSessionFlag)
            {
                // Set the support mode.
                SetSupportSessionMode(SupportSessionFlag);

                // If a window is being shared (not the desktop), set it
                // visible and in foreground.
                if (WindowHandle != 0)
                {
                    IntPtr hWnd = new IntPtr(WindowHandle);
                    if (KSyscalls.IsIconic(hWnd))
                    {
                        KSyscalls.ShowWindowAsync(hWnd, (int)KSyscalls.WindowStatus.SW_RESTORE);
                    }
                    KSyscalls.SetForegroundWindow(hWnd);
                }
            }

            // Remove any indication of previous server's listening port.
            RegistryKey key = null;

            try
            {
                key = KwmReg.GetKwmCURegKey();
                key.DeleteValue(m_portRegItem, false);
                key.DeleteValue(m_portRegItemWritten, false);
            }

            finally
            {
                if (key != null)
                {
                    key.Close();
                }
            }

            // Start the process.
            StartProcess(true);
        }
Ejemplo n.º 5
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
 /// <summary>
 /// Open the tunnel used by the VNC process.
 /// </summary>
 private void OpenTunnel()
 {
     Status       = VncSessionStatus.Tunnel;
     TunnelThread = new VncTunnelThread(this);
     TunnelThread.Start();
 }
Ejemplo n.º 6
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
 /// <summary>
 /// Start the dummy process.
 /// </summary>
 private void StartDummyProcess()
 {
     Status = VncSessionStatus.DummyProcess;
     StartProcess(false);
 }
Ejemplo n.º 7
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
        /// <summary>
        /// Clean up the state when the session has completed to avoid resource
        /// leaks. This object CANNOT be reused for another session since some
        /// recently cancelled threads may still reference the object and try
        /// to modify its state.
        /// </summary>
        private void Terminate()
        {
            Status = VncSessionStatus.Completed;
            AppVnc.SessionPresentFlag = false;
            App.LocalSession = null;

            if (Overlay != null)
            {
                Overlay.Terminate();
                Overlay = null;
            }

            if (TicketQuery != null)
            {
                TicketQuery.Terminate();
                TicketQuery = null;
            }

            if (Tunnel != null)
            {
                Tunnel.Terminate();
                Tunnel = null;
            }

            if (TunnelThread != null)
            {
                TunnelThread.RequestCancellation();
                TunnelThread = null;
            }

            if (MainProcess != null)
            {
                MainProcess.Terminate();
                MainProcess = null;
            }

            if (DummyProcess != null)
            {
                DummyProcess.Terminate();
                DummyProcess = null;
            }

            if (Timer != null)
            {
                Timer.WakeMeUp(-1);
                Timer = null;
            }

            if (InactivityMonitor != null)
            {
                InactivityMonitor.Enabled = false;
                InactivityMonitor.Dispose();
                InactivityMonitor = null;
            }
        }
Ejemplo n.º 8
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
        /// <summary>
        /// Start the main process.
        /// </summary>
        private void StartMainProcess()
        {
            Status = VncSessionStatus.MainProcess;

            // Handle server session miscellaneous actions.
            if (ServerSessionFlag)
            {
                // Set the support mode.
                SetSupportSessionMode(SupportSessionFlag);

                // If a window is being shared (not the desktop), set it
                // visible and in foreground.
                if (WindowHandle != 0)
                {
                    IntPtr hWnd = new IntPtr(WindowHandle);
                    if (KSyscalls.IsIconic(hWnd))
                        KSyscalls.ShowWindowAsync(hWnd, (int)KSyscalls.WindowStatus.SW_RESTORE);
                    KSyscalls.SetForegroundWindow(hWnd);
                }
            }

            // Remove any indication of previous server's listening port.
            RegistryKey key = null;

            try
            {
                key = KwmReg.GetKwmCURegKey();
                key.DeleteValue(m_portRegItem, false);
                key.DeleteValue(m_portRegItemWritten, false);
            }

            finally
            {
                if (key != null) key.Close();
            }

            // Start the process.
            StartProcess(true);
        }
Ejemplo n.º 9
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
 /// <summary>
 /// Start the dummy process.
 /// </summary>
 private void StartDummyProcess()
 {
     Status = VncSessionStatus.DummyProcess;
     StartProcess(false);
 }
Ejemplo n.º 10
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
 /// <summary>
 /// Request a ticket to the server.
 /// </summary>
 private void RequestTicket()
 {
     Status = VncSessionStatus.Ticket;
     UInt32 t = ServerSessionFlag ? KAnp.KANP_CMD_VNC_START_TICKET : KAnp.KANP_CMD_VNC_CONNECT_TICKET;
     AnpMsg m = Kws.NewKcdCmd(t);
     if (!ServerSessionFlag) m.AddUInt64(SessionID);
     TicketQuery = Kws.PostKcdCmd(m, OnTicketReply);
 }
Ejemplo n.º 11
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
 /// <summary>
 /// Open the tunnel used by the VNC process.
 /// </summary>
 private void OpenTunnel()
 {
     Status = VncSessionStatus.Tunnel;
     TunnelThread = new VncTunnelThread(this);
     TunnelThread.Start();
 }
Ejemplo n.º 12
0
Archivo: Vnc.cs Proyecto: tmbx/kwm-ng
        /// <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);
        }