Exemplo n.º 1
0
 protected override void FormatSuccessReply(AnpMsg m)
 {
     m.Type = (uint)EAnpRes.LookupRecAddr;
     m.AddUInt32((uint)RecList.Count);
     foreach (Rec r in RecList)
     {
         m.AddString(r.Email);
         m.AddUInt64(r.KeyID);
         m.AddString(r.OrgName);
     }
 }
Exemplo n.º 2
0
 protected override void FormatSuccessReply(AnpMsg m)
 {
     m.Type = (uint)EAnpRes.InviteKws;
     m.AddString(Wleu);
     m.AddUInt32((uint)UserList.Count);
     foreach (User u in UserList)
     {
         m.AddString(u.EmailAddress);
         m.AddString(u.Url);
         m.AddString(u.Error);
     }
 }
Exemplo n.º 3
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.º 4
0
 protected override void PrepareCmd(AnpMsg cmd)
 {
     cmd.Type = (uint)KAnp.KANP_CMD_KWS_INVITE_KWS;
     cmd.AddString(InvitationMsg);
     cmd.AddUInt32((UInt32)UserList.Count);
     foreach (User u in UserList)
     {
         cmd.AddString(u.UserName);
         cmd.AddString(u.EmailAddress);
         cmd.AddUInt64(u.KeyID);
         cmd.AddString(u.OrgName);
         cmd.AddString(u.Pwd);
         cmd.AddUInt32(Convert.ToUInt32(KcdSendEmailFlag));
     }
 }
Exemplo n.º 5
0
Arquivo: Pb.cs Projeto: tmbx/kwm-ng
        private KwsAnpEventStatus HandleTriggerKwsEvent(AnpMsg evt)
        {
            UInt64 date    = evt.Elements[1].UInt64;
            UInt32 userID  = evt.Elements[3].UInt32;
            String subject = evt.Elements[4].String;

            AnpMsg etEvt = Kws.MakePermEAnpEvent(EAnpEvt.PbKwsRequested, date, userID);

            etEvt.AddString(subject);
            Kws.PostPermEAnpEvent(etEvt);

            return(KwsAnpEventStatus.Processed);
        }
Exemplo n.º 6
0
Arquivo: Vnc.cs Projeto: tmbx/kwm-ng
        public override KwsAnpEventStatus HandleAnpEvent(AnpMsg evt)
        {
            if (evt.Type == KAnp.KANP_EVT_VNC_START)
            {
                UInt64 date      = evt.Elements[1].UInt64;
                UInt32 userID    = evt.Elements[2].UInt32;
                UInt64 sessionID = evt.Elements[3].UInt64;
                String subject   = evt.Elements[4].String;

                AnpMsg etEvt = Kws.MakePermEAnpEvent(EAnpEvt.VncSessionStarted, date, userID);
                etEvt.AddUInt64(sessionID);
                etEvt.AddString(subject);
                Kws.PostPermEAnpEvent(etEvt);

                return(KwsAnpEventStatus.Processed);
            }

            else if (evt.Type == KAnp.KANP_EVT_VNC_END)
            {
                UInt64 date      = evt.Elements[1].UInt64;
                UInt32 userID    = evt.Elements[2].UInt32;
                UInt64 sessionID = evt.Elements[3].UInt64;

                AnpMsg etEvt = Kws.MakePermEAnpEvent(EAnpEvt.VncSessionEnded, date, userID);
                etEvt.AddUInt64(sessionID);
                Kws.PostPermEAnpEvent(etEvt);

                // If we have a local session, notify it about the event.
                if (LocalSession != null)
                {
                    EAnpException ex = null;
                    if (evt.Minor >= 5)
                    {
                        ex = EAnpException.FromKAnpFailure(evt, 4);
                    }
                    else
                    {
                        ex = new EAnpExGeneric("session closed");
                    }
                    LocalSession.OnSessionEndEventReceived(sessionID, ex);
                }

                return(KwsAnpEventStatus.Processed);
            }

            return(KwsAnpEventStatus.Unprocessed);
        }
Exemplo n.º 7
0
Arquivo: Chat.cs Projeto: tmbx/kwm-ng
        public override KwsAnpEventStatus HandleAnpEvent(AnpMsg evt)
        {
            // Incoming chat message.
            if (evt.Type == KAnp.KANP_EVT_CHAT_MSG)
            {
                UInt64 date    = evt.Elements[1].UInt64;
                UInt32 userID  = evt.Elements[3].UInt32;
                String userMsg = evt.Elements[4].String;

                AnpMsg etEvt = Kws.MakePermEAnpEvent(EAnpEvt.ChatMsgReceived, date, userID);
                etEvt.AddString(userMsg);
                Kws.PostPermEAnpEvent(etEvt);

                return(KwsAnpEventStatus.Processed);
            }

            return(KwsAnpEventStatus.Unprocessed);
        }
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);
        }
Exemplo n.º 9
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.º 10
0
 protected override void FormatSuccessReply(AnpMsg m)
 {
     m.Type = (uint)EAnpRes.RegisterKps;
     m.AddUInt32((uint)ResCode);
     m.AddString(ResMsg);
 }
Exemplo n.º 11
0
 protected override void PrepareCmd(AnpMsg cmd)
 {
     cmd.Type = (uint)KAnp.KANP_CMD_CHAT_MSG;
     cmd.AddUInt32(ChannelID);
     cmd.AddString(Msg);
 }