Example #1
0
        /// <summary>
        /// Return the user having the ID specified, if any. Virtual users
        /// may be returned.
        /// </summary>
        public KwsUser GetUserByID(UInt32 ID)
        {
            if (ID == 0)
            {
                return(RootUser);
            }
            if (UserTree.ContainsKey(ID))
            {
                return(UserTree[ID]);
            }

            KwsCredentials creds = m_cd.Credentials;

            if (ID == creds.UserID)
            {
                KwsUser user = new KwsUser();
                user.UserID       = creds.UserID;
                user.AdminName    = creds.UserName;
                user.UserName     = creds.UserName;
                user.EmailAddress = creds.UserEmailAddress;
                user.VirtualFlag  = true;
                return(user);
            }

            return(null);
        }
Example #2
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);
        }
Example #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;
        }
Example #4
0
 public void Relink(KwsCoreData cd)
 {
     m_cd                  = cd;
     RootUser              = new KwsUser();
     RootUser.AdminFlag    = true;
     RootUser.ManagerFlag  = true;
     RootUser.RegisterFlag = true;
     RootUser.VirtualFlag  = true;
     RootUser.AdminName    = RootUser.UserName = "******";
 }
Example #5
0
        private KwsAnpEventStatus HandleKwsPropChange(AnpMsg msg)
        {
            KwsCredentials creds    = m_kws.Cd.Credentials;
            KwsUserInfo    userInfo = m_kws.Cd.UserInfo;

            int    i        = 3;
            UInt32 nbChange = msg.Elements[i++].UInt32;

            for (UInt32 j = 0; j < nbChange; j++)
            {
                UInt32 type = msg.Elements[i++].UInt32;

                if (type == KAnp.KANP_PROP_KWS_NAME)
                {
                    creds.KwsName = msg.Elements[i++].String;
                }

                else if (type == KAnp.KANP_PROP_KWS_FLAGS)
                {
                    creds.Flags = msg.Elements[i++].UInt32;
                }

                else
                {
                    KwsUser user = userInfo.GetNonVirtualUserByID(msg.Elements[i++].UInt32);
                    if (user == null)
                    {
                        throw new Exception("no such user");
                    }

                    if (type == KAnp.KANP_PROP_USER_NAME_ADMIN)
                    {
                        user.AdminName = msg.Elements[i++].String;
                    }

                    else if (type == KAnp.KANP_PROP_USER_NAME_USER)
                    {
                        user.UserName = msg.Elements[i++].String;
                    }

                    else if (type == KAnp.KANP_PROP_USER_FLAGS)
                    {
                        user.Flags = msg.Elements[i++].UInt32;
                    }

                    else
                    {
                        throw new Exception("invalid user property type");
                    }
                }
            }

            m_kws.OnStateChange(WmStateChange.Permanent);
            return(KwsAnpEventStatus.Processed);
        }
Example #6
0
        private KwsAnpEventStatus HandleUserRegisteredEvent(AnpMsg msg)
        {
            UInt32 userID   = msg.Elements[2].UInt32;
            String userName = msg.Elements[3].String;

            KwsUser user = m_kws.Cd.UserInfo.GetNonVirtualUserByID(userID);

            if (user == null)
            {
                throw new Exception("no such user");
            }
            user.UserName = userName;

            m_kws.OnStateChange(WmStateChange.Permanent);
            return(KwsAnpEventStatus.Processed);
        }
Example #7
0
        private KwsAnpEventStatus HandleKwsInvitationEvent(AnpMsg msg)
        {
            UInt32 nbUser = msg.Elements[msg.Minor <= 2 ? 2 : 3].UInt32;

            // This is not supposed to happen, unless in the case of a broken
            // KWM. Indeed, the server does not enforce any kind of restriction
            // regarding the number of invitees in an INVITE command. If a KWM
            // sends such a command with no invitees, the server will fire an
            // empty INVITE event.
            if (nbUser < 1)
            {
                return(KwsAnpEventStatus.Processed);
            }

            List <KwsUser> users = new List <KwsUser>();

            // Add the users in the user list.
            int j = (msg.Minor <= 2) ? 3 : 4;

            for (int i = 0; i < nbUser; i++)
            {
                KwsUser user = new KwsUser();
                user.UserID         = msg.Elements[j++].UInt32;
                user.InvitationDate = msg.Elements[1].UInt64;
                if (msg.Minor >= 3)
                {
                    user.InvitedBy = msg.Elements[2].UInt32;
                }
                user.AdminName    = msg.Elements[j++].String;
                user.EmailAddress = msg.Elements[j++].String;
                if (msg.Minor <= 2)
                {
                    j += 2;
                }
                user.OrgName = msg.Elements[j++].String;
                users.Add(user);
                m_kws.Cd.UserInfo.UserTree[user.UserID] = user;
            }

            m_kws.OnStateChange(WmStateChange.Permanent);
            return(KwsAnpEventStatus.Processed);
        }
Example #8
0
        private KwsAnpEventStatus HandleKwsInvitationEvent(AnpMsg msg)
        {
            UInt32 nbUser = msg.Elements[msg.Minor <= 2 ? 2 : 3].UInt32;

            // This is not supposed to happen, unless in the case of a broken
            // KWM. Indeed, the server does not enforce any kind of restriction
            // regarding the number of invitees in an INVITE command. If a KWM
            // sends such a command with no invitees, the server will fire an
            // empty INVITE event.
            if (nbUser < 1) return KwsAnpEventStatus.Processed;

            List<KwsUser> users = new List<KwsUser>();

            // Add the users in the user list.
            int j = (msg.Minor <= 2) ? 3 : 4;
            for (int i = 0; i < nbUser; i++)
            {
                KwsUser user = new KwsUser();
                user.UserID = msg.Elements[j++].UInt32;
                user.InvitationDate = msg.Elements[1].UInt64;
                if (msg.Minor >= 3) user.InvitedBy = msg.Elements[2].UInt32;
                user.AdminName = msg.Elements[j++].String;
                user.EmailAddress = msg.Elements[j++].String;
                if (msg.Minor <= 2) j += 2;
                user.OrgName = msg.Elements[j++].String;
                users.Add(user);
                m_kws.Cd.UserInfo.UserTree[user.UserID] = user;
            }

            m_kws.OnStateChange(WmStateChange.Permanent);
            return KwsAnpEventStatus.Processed;
        }
Example #9
0
 public void Relink(KwsCoreData cd)
 {
     m_cd = cd;
     RootUser = new KwsUser();
     RootUser.AdminFlag = true;
     RootUser.ManagerFlag = true;
     RootUser.RegisterFlag = true;
     RootUser.VirtualFlag = true;
     RootUser.AdminName = RootUser.UserName = "******";
 }
Example #10
0
        /// <summary>
        /// Return the user having the ID specified, if any. Virtual users
        /// may be returned.
        /// </summary>
        public KwsUser GetUserByID(UInt32 ID)
        {
            if (ID == 0) return RootUser;
            if (UserTree.ContainsKey(ID)) return UserTree[ID];

            KwsCredentials creds = m_cd.Credentials;
            if (ID == creds.UserID)
            {
                KwsUser user = new KwsUser();
                user.UserID = creds.UserID;
                user.AdminName = creds.UserName;
                user.UserName = creds.UserName;
                user.EmailAddress = creds.UserEmailAddress;
                user.VirtualFlag = true;
                return user;
            }

            return null;
        }