Example #1
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);
        }
Example #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);
        }
Example #3
0
        /// <summary>
        /// Create a new KCD ANP command message having the minor version and
        /// type specified and a unique ID. The workspace ID is inserted as the
        /// first element of the command.
        /// </summary>
        public AnpMsg NewKcdCmd(UInt32 type)
        {
            AnpMsg msg = Wm.NewKcdCmd(Kcd.MinorVersion, type);

            msg.AddUInt64(Cd.Credentials.ExternalID);
            return(msg);
        }
Example #4
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);
 }
Example #5
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);
     }
 }
Example #6
0
File: Vnc.cs Project: 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);
        }
Example #7
0
File: Vnc.cs Project: 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);
        }
Example #8
0
File: Pb.cs Project: tmbx/kwm-ng
        private KwsAnpEventStatus HandleTriggerChatEvent(AnpMsg evt)
        {
            UInt64 date    = evt.Elements[1].UInt64;
            UInt64 reqID   = evt.Minor <= 2 ? evt.Elements[2].UInt32 : evt.Elements[2].UInt64;
            UInt32 userID  = evt.Elements[3].UInt32;
            String subject = evt.Elements[4].String;

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

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

            return(KwsAnpEventStatus.Processed);
        }
Example #9
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));
     }
 }
Example #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));
            }
        }
Example #11
0
File: Vnc.cs Project: 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);
        }
Example #12
0
 protected override void FormatSuccessReply(AnpMsg m)
 {
     m.Type = (uint)EAnpRes.CreateKws;
     m.AddUInt64(Kws.InternalID);
 }