Beispiel #1
0
 protected override void PrepareCmd(AnpMsg cmd)
 {
     cmd.Type = (uint)KAnp.KANP_CMD_PB_ACCEPT_CHAT;
     cmd.AddUInt64(RequestID);
     cmd.AddUInt32(UserID);
     cmd.AddUInt32(UserID);
 }
Beispiel #2
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);
        }
Beispiel #3
0
        /// <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);
        }
Beispiel #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));
     }
 }
Beispiel #5
0
        /// <summary>
        /// Send the select role command message.
        /// </summary>
        public void SendSelectRoleMsg()
        {
            AnpMsg msg = new AnpMsg();

            msg.Major = KAnp.Major;
            msg.Minor = KAnp.Minor;
            msg.ID    = 0;
            msg.Type  = KAnp.KANP_CMD_MGT_SELECT_ROLE;
            msg.AddUInt32(KAnp.KANP_KCD_ROLE_WORKSPACE);
            SafeSend(msg);
        }
Beispiel #6
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);
     }
 }
Beispiel #7
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);
        }
Beispiel #8
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);
     }
 }
Beispiel #9
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);
        }
Beispiel #10
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));
            }
        }
Beispiel #11
0
        /// <summary>
        /// Negociate the role.
        /// </summary>
        private void NegociateRole()
        {
            AnpMsg m = CreateAnpMsg(KAnp.KANP_CMD_MGT_SELECT_ROLE);

            m.AddUInt32(KAnp.KANP_KCD_ROLE_APP_SHARE);
            SendAnpMsg(m);
            m = GetAnpMsg();
            if (m.Type == KAnp.KANP_RES_FAIL)
            {
                throw EAnpException.FromKAnpReply(m);
            }
            if (m.Type != KAnp.KANP_RES_OK)
            {
                throw new Exception("expected RES_OK in role negociation");
            }
        }
Beispiel #12
0
 protected override void FormatSuccessReply(AnpMsg m)
 {
     m.Type = (uint)EAnpRes.RegisterKps;
     m.AddUInt32((uint)ResCode);
     m.AddString(ResMsg);
 }
Beispiel #13
0
 protected override void PrepareCmd(AnpMsg cmd)
 {
     cmd.Type = (uint)KAnp.KANP_CMD_CHAT_MSG;
     cmd.AddUInt32(ChannelID);
     cmd.AddString(Msg);
 }