Пример #1
0
Файл: Vnc.cs Проект: tmbx/kwm-ng
        /// <summary>
        /// This method should be called when an error occurs in the session.
        /// This is a no-op if the session has completed. 'ex' can be null if
        /// the session ended normally.
        /// </summary>
        public void HandleSessionTrouble(Exception ex)
        {
            if (Status == VncSessionStatus.Completed)
            {
                return;
            }

            // Determine whether we were starting the session.
            bool startFlag = (Status != VncSessionStatus.Started);

            // Convert the exception to an EAnp exception as needed. If we
            // failed to start, we always need an exception.
            EAnpException castedEx = null;

            if (ex != null)
            {
                castedEx = EAnpException.FromException(ex);
            }
            if (castedEx == null && startFlag)
            {
                castedEx = new EAnpExInterrupted();
            }

            // Terminate this session.
            Terminate();

            // Notify listeners. There are three cases:
            // - The session failed to start.
            // - The session ended normally.
            // - The session eneded abnormally.
            PostLocalVncSessionEvent(startFlag, castedEx);

            Kws.OnStateChange(WmStateChange.Transient);
        }
Пример #2
0
        /// <summary>
        /// "Import" a workspace that already exists in the KWM.
        /// </summary>
        private static void ImportExistingKws(Workspace kws, KwsCredentials creds)
        {
            KwsTask task = kws.Cd.CurrentTask;

            KLogging.Log("Import of existing workspace " + kws.InternalID + " with task " + task + " requested.");

            // We can only import workspaces that are stopped or working
            // offline.
            if (task != KwsTask.Stop && task != KwsTask.WorkOffline)
            {
                KLogging.Log("Skipping import due to incompatible task.");
                return;
            }

            // Update the credentials unless they were already accepted.
            if (kws.Cd.KcdState.LoginResult != KwsLoginResult.Accepted)
            {
                KLogging.Log("Updating workspace credentials.");
                creds.PublicFlag   = kws.Cd.Credentials.PublicFlag;
                kws.Cd.Credentials = creds;
            }

            // Make the workspace work online.
            kws.Sm.RequestTaskSwitch(KwsTask.WorkOnline);

            // The workspace state has changed.
            kws.OnStateChange(WmStateChange.Permanent);
        }
Пример #3
0
        private KwsAnpEventStatus HandleKwsCreatedEvent(AnpMsg msg)
        {
            KwsCredentials creds = m_kws.Cd.Credentials;

            // Add the creator to the user list.
            KwsUser user = new KwsUser();

            user.UserID         = msg.Elements[2].UInt32;
            user.InvitationDate = msg.Elements[1].UInt64;
            user.AdminName      = msg.Elements[3].String;
            user.EmailAddress   = msg.Elements[4].String;
            user.OrgName        = msg.Elements[msg.Minor <= 2 ? 7 : 5].String;
            user.AdminFlag      = true;
            user.ManagerFlag    = true;
            user.RegisterFlag   = true;
            m_kws.Cd.UserInfo.UserTree[user.UserID] = user;

            // Update the workspace data.
            if (msg.Minor <= 2)
            {
                creds.SecureFlag = true;
            }

            if (msg.Minor >= 3)
            {
                creds.KwsName     = msg.Elements[6].String;
                creds.Flags       = msg.Elements[7].UInt32;
                creds.KwmoAddress = msg.Elements[8].String;
            }

            m_kws.OnStateChange(WmStateChange.Permanent);
            return(KwsAnpEventStatus.Processed);
        }
Пример #4
0
 /// <summary>
 /// Switch the current task to the task specified. Don't call this
 /// outside RequestSwitchTask() unless you know what you are doing.
 /// The state machine will run ASAP to handle the new state.
 /// </summary>
 private void SwitchTask(KwsTask task, Exception ex)
 {
     // The order of the calls is important here.
     WmSm.LockNotif();
     Debug.Assert(m_taskSwitchFlag == false);
     m_taskSwitchFlag = true;
     m_cd.CurrentTask = task;
     StopAppIfNeeded(ex);
     DisconnectFromKcdIfNeeded();
     LogoutIfNeeded();
     StopRebuildIfNeeded();
     UpdateKcdEventUpToDateState();
     m_kws.OnStateChange(WmStateChange.Transient);
     RequestRun("task switch to " + task);
     m_taskSwitchFlag = false;
     WmSm.QueueNotif(new KwsSmNotifTaskSwitch(m_kws, task, ex));
     WmSm.UnlockNotif();
 }
Пример #5
0
        /// <summary>
        /// Set the login password. Return true if a login attempt will be made
        /// immmediately with the password provided.
        /// </summary>
        public bool SetLoginPwd(String pwd)
        {
            // Update the password.
            m_kws.Cd.Credentials.Pwd = pwd;
            m_kws.OnStateChange(WmStateChange.Internal);

            // We were not expecting a password.
            if (m_currentStep != KwsLoginStep.Pwd)
            {
                return(false);
            }

            // Send the login command.
            SendLoginCommand();
            return(true);
        }