Beispiel #1
0
        private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders)
        {
            MainConsole.Instance.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID);


            FriendInfo[] friends = FriendsService.GetFriendsRequest(agentID).ToArray();
            foreach (FriendInfo fi in friends)
            {
                if (fi.MyFlags == 0)
                {
                    UUID fromAgentID;
                    if (!UUID.TryParse(fi.Friend, out fromAgentID))
                    {
                        continue;
                    }
                    if (fromAgentID == friendID) //Get those pesky HG travelers as well
                    {
                        FriendsService.Delete(agentID, fi.Friend);
                    }
                }
            }
            FriendsService.Delete(friendID, agentID.ToString());

            //
            // Notify the friend
            //

            // Try local
            if (LocalFriendshipDenied(agentID, client.Name, friendID))
            {
                return;
            }
            SyncMessagePosterService.PostToServer(SyncMessageHelper.FriendshipDenied(
                                                      agentID, client.Name, friendID, m_scene.RegionInfo.RegionID));
        }
Beispiel #2
0
        private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID,
                                            List <UUID> callingCardFolders)
        {
            MainConsole.Instance.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID);

            FriendsService.StoreFriend(agentID, friendID.ToString(), 1);
            FriendsService.StoreFriend(friendID, agentID.ToString(), 1);

            // Update the local cache
            UpdateFriendsCache(agentID);

            // Notify the friend and send calling card to the local user

            ICallingCardModule ccmodule = client.Scene.RequestModuleInterface <ICallingCardModule>();

            if (ccmodule != null)
            {
                UserAccount account  = client.Scene.UserAccountService.GetUserAccount(client.AllScopeIDs, friendID);
                UUID        folderID =
                    client.Scene.InventoryService.GetFolderForType(agentID, InventoryType.Unknown, AssetType.CallingCard)
                    .ID;
                if (account != null)
                {
                    ccmodule.CreateCallingCard(client, friendID, folderID, account.Name);
                }
            }

            // Try Local
            if (LocalFriendshipApproved(agentID, client.Name, client, friendID))
            {
                return;
            }
            SyncMessagePosterService.PostToServer(SyncMessageHelper.FriendshipApproved(
                                                      agentID, client.Name, friendID, m_scene.RegionInfo.RegionID));
        }
Beispiel #3
0
        private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
        {
            FriendInfo[] friends = GetFriends(remoteClient.AgentId);
            if (friends.Length == 0)
            {
                return;
            }

            MainConsole.Instance.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights,
                                             target);
            // Let's find the friend in this user's friend list
            FriendInfo friend = null;

#if (!ISWIN)
            foreach (FriendInfo fi in friends)
            {
                if (fi.Friend == target.ToString())
                {
                    friend = fi;
                }
            }
#else
            foreach (FriendInfo fi in friends.Where(fi => fi.Friend == target.ToString()))
            {
                friend = fi;
            }
#endif

            if (friend != null) // Found it
            {
                // Store it on the DB
                FriendsService.StoreFriend(requester, target.ToString(), rights);

                // Store it in the local cache
                int myFlags = friend.MyFlags;
                friend.MyFlags = rights;

                // Always send this back to the original client
                remoteClient.SendChangeUserRights(requester, target, rights);

                //
                // Notify the friend
                //


                // Try local
                if (!LocalGrantRights(requester, target, myFlags, rights))
                {
                    SyncMessagePosterService.Post(SyncMessageHelper.FriendGrantRights(
                                                      requester, target, myFlags, rights, m_Scenes[0].RegionInfo.RegionHandle),
                                                  m_Scenes[0].RegionInfo.RegionHandle);
                }
            }
        }
Beispiel #4
0
        private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List <UUID> callingCardFolders)
        {
            MainConsole.Instance.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID);

            FriendsService.Delete(agentID, friendID.ToString());
            FriendsService.Delete(friendID, agentID.ToString());

            //
            // Notify the friend
            //

            // Try local
            if (LocalFriendshipDenied(agentID, client.Name, friendID))
            {
                return;
            }
            SyncMessagePosterService.Post(SyncMessageHelper.FriendshipDenied(
                                              agentID, client.Name, friendID, m_Scenes[0].RegionInfo.RegionHandle),
                                          m_Scenes[0].RegionInfo.RegionHandle);
        }
Beispiel #5
0
        private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im)
        {
            // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID)
            // We stick this agent's ID as imSession, so that it's directly available on the receiving end
            im.SessionID = im.FromAgentID;

            // Try the local sim
            UserAccount account = UserAccountService.GetUserAccount(m_scene.RegionInfo.AllScopeIDs, agentID);

            im.FromAgentName = (account == null) ? "Unknown" : account.Name;

            if (LocalFriendshipOffered(friendID, im))
            {
                return;
            }

            // The prospective friend is not here [as root]. Let's4 forward.
            SyncMessagePosterService.PostToServer(SyncMessageHelper.FriendshipOffered(agentID, friendID, im,
                                                                                      m_scene.RegionInfo.RegionID));
            // If the prospective friend is not online, he'll get the message upon login.
        }
Beispiel #6
0
        private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID)
        {
            FriendsService.Delete(agentID, exfriendID.ToString());
            FriendsService.Delete(exfriendID, agentID.ToString());

            // Update local cache
            UpdateFriendsCache(agentID);

            client.SendTerminateFriend(exfriendID);

            // Notify the friend

            // Try local
            if (LocalFriendshipTerminated(exfriendID, agentID))
            {
                return;
            }

            SyncMessagePosterService.PostToServer(SyncMessageHelper.FriendTerminated(
                                                      agentID, exfriendID, m_scene.RegionInfo.RegionID));
        }