コード例 #1
0
        public void ASNotifyRng(User caller, User recipient, SwitchboardInvitation invite)
        {
            // should ASNotifyRng be using UserListEntry? Why can't it use .FriendlyName, why must it use .CustomName, which must be recalled from somewhere?
            UserListEntry callerEntry = new UserListEntry(caller, caller.FriendlyName);

            NotificationConnection connection = GetConnectionForUser(recipient);

            if (connection != null)
            {
                connection.Protocol.ASNotifyRng(callerEntry, connection, invite);
            }
        }
コード例 #2
0
        public void ASNotifyAddRL(User adder, User recipient)
        {
            // again, should this be using UserListEntry?
            UserListEntry adderEntry = new UserListEntry(adder, adder.FriendlyName);

            NotificationConnection connection = GetConnectionForUser(recipient);

            if (connection != null)
            {
                connection.Protocol.ASNotifyAddRL(connection, adderEntry);
            }
        }
コード例 #3
0
        /// <summary>Adds the <paramref name="target"/> user to <paramref name="listOwner"/>'s <paramref name="list"/> list, then sends out appropriate notifications if necessary.</summary>
        public AddListResult AddToList(User listOwner, String listName, User target, String customName)
        {
            lock (listOwner.Properties)
                lock (target.Properties) {
                    switch (listName)
                    {
                    case "FL":

                        // Add to the Forward List
                        // Add to the Reverse List of the target
                        // if the target is online send an async ADD notification to that user

                        // NOTE: adding to the Allow List is explicitly done by the client, there is no implicit AL add

                        listOwner.Properties.ForwardList.Add(target, customName);
                        listOwner.Properties.Serial++;

                        UserListEntry rlEntry =
                            target.Properties.ReverseList.Add(listOwner, listOwner.FriendlyName);
                        target.Properties.Serial++;

                        NotificationConnection targetC1 = GetConnectionForUser(target);
                        if (targetC1 != null && target.Status != Status.Fln)
                        {
                            targetC1.Protocol.ASNotifyAddRL(targetC1, rlEntry);
                        }

                        if (target.Status.AppearOnline() && target.Properties.GetResultantAS(listOwner) == AllowSetting.Allow)
                        {
                            // if listOwner is allowed to see target

                            NotificationConnection listOwnerC = GetConnectionForUser(listOwner);
                            listOwnerC.Protocol.ASNotifyIln(listOwnerC, target);
                        }

                        // TODO: If the added user is online, send ILN

                        return(AddListResult.Success);

                    case "AL":

                        // Check user isn't already on the BL, you can't be on both
                        // Then add to the AL
                        // If the target is online and has this user in their forward list, send ILN to the target

                        UserPermissionListEntry alEntry;
                        if (listOwner.Properties.PermissList.TryGetValue(target, out alEntry))
                        {
                            return(alEntry.Allowed == AllowSetting.Allow ? AddListResult.Success : AddListResult.MutexBL);
                        }
                        else
                        {
                            alEntry = new UserPermissionListEntry(target, customName, AllowSetting.Allow);

                            listOwner.Properties.PermissList.Add(target, alEntry);
                            listOwner.Properties.Serial++;

                            if (listOwner.Status.AppearOnline() && target.Properties.ForwardList.ContainsKey(listOwner))
                            {
                                NotificationConnection targetC2 = GetConnectionForUser(target);
                                if (targetC2 != null && target.Status != Status.Fln)
                                {
                                    targetC2.Protocol.ASNotifyNln(targetC2, listOwner);
                                }
                            }

                            return(AddListResult.Success);
                        }

                    case "BL":

                        // Same as AL, but with some tweaks for the different list

                        UserPermissionListEntry blEntry;
                        if (listOwner.Properties.PermissList.TryGetValue(target, out blEntry))
                        {
                            return(blEntry.Allowed == AllowSetting.Block ? AddListResult.Success : AddListResult.MutexAL);
                        }
                        else
                        {
                            blEntry = new UserPermissionListEntry(target, customName, AllowSetting.Block);

                            listOwner.Properties.PermissList.Add(target, blEntry);
                            listOwner.Properties.Serial++;

                            if (target.Properties.ForwardList.ContainsKey(listOwner))
                            {
                                NotificationConnection c2 = GetConnectionForUser(target);
                                if (listOwner.Status.AppearOnline() && c2 != null && target.Status != Status.Fln)
                                {
                                    c2.Protocol.ASNotifyFln(c2, listOwner);
                                }
                            }

                            return(AddListResult.Success);
                        }

                    case "RL":
                        return(AddListResult.CannotAddtoRL);

                    default:
                        return(AddListResult.UnknownList);
                    } //switch
                }     //lock
        }             //AddToList