Exemplo n.º 1
0
        /// <summary>
        /// Join a VNC session.
        /// </summary>
        private void HandleVncJoinSession(AnpMsg cmd, AnpMsg res)
        {
            int       i         = 0;
            UInt64    kwsID     = cmd.Elements[i++].UInt64;
            UInt64    sessionID = cmd.Elements[i++].UInt64;
            String    subject   = cmd.Elements[i++].String;
            Workspace kws       = Wm.GetKwsByInternalIDOrThrow(kwsID);

            byte[] sessionUuid = kws.Vnc.StartClientSession(sessionID, subject);
            res.Type = (uint)EAnpRes.VncSession;
            res.AddBin(sessionUuid);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a VNC session.
        /// </summary>
        private void HandleVncCreateSession(AnpMsg cmd, AnpMsg res)
        {
            int       i           = 0;
            UInt64    kwsID       = cmd.Elements[i++].UInt64;
            bool      supportFlag = cmd.Elements[i++].UInt32 > 0;
            String    subject     = cmd.Elements[i++].String;
            Workspace kws         = Wm.GetKwsByInternalIDOrThrow(kwsID);

            byte[] sessionUuid = kws.Vnc.StartServerSession(supportFlag, 0, subject);
            res.Type = (uint)EAnpRes.VncSession;
            res.AddBin(sessionUuid);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create an EAnp event having the parameters specified.
        /// </summary>
        private AnpMsg MakeEAnpEvent(EAnpEvt type, UInt64 date, UInt32 userID, UInt64 freshness)
        {
            AnpMsg m = new AnpMsg();

            m.Minor = 1;
            m.Type  = (UInt32)type;
            m.AddUInt64(InternalID);
            m.AddUInt64(date);
            m.AddUInt32(userID);
            m.AddUInt64(freshness);
            m.AddBin(Wm.MakeUuid());
            return(m);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Send a login command to the KCD.
        /// </summary>
        private void SendLoginCommand()
        {
            AnpMsg msg = m_kws.NewKcdCmd(KAnp.KANP_CMD_KWS_CONNECT_KWS);

            // Add the delete workspace flag.
            if (m_kws.Kcd.MinorVersion >= 4)
            {
                msg.AddUInt32(Convert.ToUInt32(m_kws.Cd.CurrentTask == KwsTask.DeleteRemotely));
            }

            // Add the last event information.
            AnpMsg lastEvent = m_kws.GetLastKAnpEventInDb();

            if (lastEvent == null)
            {
                msg.AddUInt64(0);
                msg.AddUInt64(0);
            }

            else
            {
                msg.AddUInt64(lastEvent.ID);
                msg.AddUInt64(lastEvent.Elements[1].UInt64);
            }

            // Add the credential information.
            msg.AddUInt32(m_kws.Cd.Credentials.UserID);
            msg.AddString(m_kws.Cd.Credentials.UserName);
            msg.AddString(m_kws.Cd.Credentials.UserEmailAddress);
            msg.AddString(m_kws.Cd.Credentials.EmailID);

            // Send a ticket only if we're at the cached or ticket steps.
            byte[] ticket = null;
            if (m_currentStep != KwsLoginStep.Pwd)
            {
                ticket = m_kws.Cd.Credentials.Ticket;
            }
            msg.AddBin(ticket);

            // Send a password only if we're at the cached or password steps.
            String pwd = "";

            if (m_currentStep != KwsLoginStep.Ticket)
            {
                pwd = m_kws.Cd.Credentials.Pwd;
            }
            msg.AddString(pwd);

            // Post the login query.
            m_kws.PostKcdCmd(msg, HandleConnectKwsReply);
        }
Exemplo n.º 5
0
Arquivo: Vnc.cs Projeto: tmbx/kwm-ng
        /// <summary>
        /// Negociate the session.
        /// </summary>
        private void NegociateSession()
        {
            AnpMsg m = null;

            if (m_session.ServerSessionFlag)
            {
                m = CreateAnpMsg(KAnp.KANP_CMD_VNC_START_SESSION);
                m.AddBin(m_session.Ticket);
                m.AddString(m_session.Subject);
            }

            else
            {
                m = CreateAnpMsg(KAnp.KANP_CMD_VNC_CONNECT_SESSION);
                m.AddBin(m_session.Ticket);
            }

            SendAnpMsg(m);
            m = GetAnpMsg();

            if (m_session.ServerSessionFlag)
            {
                if (m.Type != KAnp.KANP_RES_VNC_START_SESSION)
                {
                    throw EAnpException.FromKAnpReply(m);
                }
                m_session.SessionID = m.Elements[0].UInt64;
            }

            else
            {
                if (m.Type != KAnp.KANP_RES_OK)
                {
                    throw EAnpException.FromKAnpReply(m);
                }
            }
        }
Exemplo n.º 6
0
Arquivo: Vnc.cs Projeto: tmbx/kwm-ng
        /// <summary>
        /// Post a LocalVncSession event.
        /// </summary>
        private void PostLocalVncSessionEvent(bool startFlag, EAnpException ex)
        {
            AnpMsg m = Kws.MakeTransientEAnpEvent(EAnpEvt.LocalVncSession);

            m.AddBin(SessionUuid);
            m.AddUInt64(SessionID);
            m.AddUInt32(Convert.ToUInt32(ServerSessionFlag));
            m.AddUInt32(Convert.ToUInt32(startFlag));
            m.AddUInt32(Convert.ToUInt32(ex != null));
            if (ex != null)
            {
                ex.Serialize(m);
            }
            Kws.PostTransientEAnpEvent(m);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Fetch EAnp events.
        /// </summary>
        private void HandleFetchEvent(AnpMsg cmd, AnpMsg res)
        {
            int           i     = 0;
            UInt64        kwsID = cmd.Elements[i++].UInt64;
            UInt32        evtID = cmd.Elements[i++].UInt32;
            UInt32        limit = cmd.Elements[i++].UInt32;
            List <AnpMsg> l     = Wm.LocalDbBroker.FetchEAnpEvents(kwsID, evtID, limit);

            res.Type = (uint)EAnpRes.FetchEvent;
            res.AddUInt64(Wm.Cd.UpdateFreshnessTime());
            res.AddUInt32((uint)l.Count);
            foreach (AnpMsg evt in l)
            {
                res.AddBin(evt.ToByteArray(true));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Send the workspace creation command if we are ready to.
        /// </summary>
        private void SendCreateKwsCmdIfNeeded()
        {
            if (DoneFlag || m_step != OpStep.Connecting || Kws.Kcd.ConnStatus != KcdConnStatus.Connected)
            {
                return;
            }

            m_step = OpStep.CreateReply;
            AnpMsg cmd = Wm.NewKcdCmd(Kws.Kcd.MinorVersion, KAnp.KANP_CMD_MGT_CREATE_KWS);

            cmd.AddString(Creds.KwsName);
            cmd.AddBin(Creds.Ticket);
            cmd.AddUInt32(Convert.ToUInt32(Creds.PublicFlag));
            cmd.AddUInt32(Convert.ToUInt32(Creds.SecureFlag));
            if (cmd.Minor >= 4)
            {
                cmd.AddUInt32(Convert.ToUInt32(Creds.ThinKfsFlag));
            }
            m_kcdQuery = Kws.PostKcdCmd(cmd, HandleCreateKwsCmdResult);
        }