public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID,
                                   string queryText, uint queryFlags, int queryStart)
        {
            List <AvatarPickerAvatar> AvatarResponses =
                new List <AvatarPickerAvatar>();

            AvatarResponses = m_Scenes[0].SceneGridService.
                              GenerateAgentPickerRequestResponse(queryID, queryText);

            DirPeopleReplyData[] data =
                new DirPeopleReplyData[AvatarResponses.Count];

            int i = 0;

            foreach (AvatarPickerAvatar item in AvatarResponses)
            {
                data[i] = new DirPeopleReplyData();

                data[i].agentID    = item.AvatarID;
                data[i].firstName  = item.firstName;
                data[i].lastName   = item.lastName;
                data[i].group      = "";
                data[i].online     = false;
                data[i].reputation = 0;
                i++;
            }

            remoteClient.SendDirPeopleReply(queryID, data);
        }
Exemple #2
0
        public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID,
                                   string queryText, uint queryFlags, int queryStart)
        {
            List <UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText);

            DirPeopleReplyData[] data =
                new DirPeopleReplyData[accounts.Count];

            int i = 0;

            foreach (UserAccount item in accounts)
            {
                data[i] = new DirPeopleReplyData();

                data[i].agentID    = item.PrincipalID;
                data[i].firstName  = item.FirstName;
                data[i].lastName   = item.LastName;
                data[i].group      = "";
                data[i].online     = false;
                data[i].reputation = 0;
                i++;
            }

            remoteClient.SendDirPeopleReply(queryID, data);
        }
Exemple #3
0
        void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
        {
            queryText = queryText.Trim();

            if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People)
            {
                if (string.IsNullOrEmpty(queryText))
                {
                    remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]);
                }

                List <UserAccount>   accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText);
                DirPeopleReplyData[] hits     = new DirPeopleReplyData[accounts.Count];
                int i = 0;
                foreach (UserAccount acc in accounts)
                {
                    DirPeopleReplyData d = new DirPeopleReplyData();
                    d.agentID   = acc.PrincipalID;
                    d.firstName = acc.FirstName;
                    d.lastName  = acc.LastName;
                    d.online    = false;

                    hits[i++] = d;
                }

                // TODO: This currently ignores pretty much all the query flags including Mature and sort order
                remoteClient.SendDirPeopleReply(queryID, hits);
            }
            else if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
            {
                if (m_GroupsService == null)
                {
                    m_log.Warn("[BASIC SEARCH MODULE]: Groups service is not available. Unable to search groups.");
                    remoteClient.SendAlertMessage("Groups search is not enabled");
                    return;
                }

                if (string.IsNullOrEmpty(queryText))
                {
                    remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
                }

                // TODO: This currently ignores pretty much all the query flags including Mature and sort order
                remoteClient.SendDirGroupsReply(queryID, m_GroupsService.FindGroups(remoteClient, queryText).ToArray());
            }
        }
        //TODO: Flagged to optimize
        public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID,
                                   string queryText, uint queryFlags, int queryStart)
        {
            //Find the user accounts
            List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText);
            DirPeopleReplyData[] data =
                    new DirPeopleReplyData[accounts.Count];

            int i = 0;
            foreach (UserAccount item in accounts)
            {
                //This is really bad, we should not be searching for all of these people again in the Profile service
                IUserProfileInfo UserProfile = ProfileFrontend.GetUserProfile(item.PrincipalID);
                if (UserProfile == null)
                {
                    data[i] = new DirPeopleReplyData();
                    data[i].agentID = item.PrincipalID;
                    data[i].firstName = item.FirstName;
                    data[i].lastName = item.LastName;
                    if (GroupsModule == null)
                        data[i].group = "";
                    else
                    {
                        data[i].group = "";
                        GroupMembershipData[] memberships = GroupsModule.GetMembershipData(item.PrincipalID);
                        foreach (GroupMembershipData membership in memberships)
                        {
                            if (membership.Active)
                                data[i].group = membership.GroupName;
                        }
                    }
                    //Then we have to pull the GUI to see if the user is online or not
                    OpenSim.Services.Interfaces.GridUserInfo Pinfo = m_Scenes[0].GridUserService.GetGridUserInfo(item.PrincipalID.ToString());
                    if (Pinfo != null && Pinfo.Online) //If it is null, they are offline
                        data[i].online = true;
                    data[i].reputation = 0;
                    i++;
                }
                else if (UserProfile.AllowPublish) //Check whether they want to be in search or not
                {
                    data[i] = new DirPeopleReplyData();
                    data[i].agentID = item.PrincipalID;
                    data[i].firstName = item.FirstName;
                    data[i].lastName = item.LastName;
                    if (GroupsModule == null)
                        data[i].group = "";
                    else
                    {
                        data[i].group = "";
                        //Check what group they have set
                        GroupMembershipData[] memberships = GroupsModule.GetMembershipData(item.PrincipalID);
                        foreach (GroupMembershipData membership in memberships)
                        {
                            if (membership.Active)
                                data[i].group = membership.GroupName;
                        }
                    }
                    //Then we have to pull the GUI to see if the user is online or not
                    OpenSim.Services.Interfaces.GridUserInfo Pinfo = m_Scenes[0].GridUserService.GetGridUserInfo(item.PrincipalID.ToString());
                    if (Pinfo != null && Pinfo.Online)
                        data[i].online = true;
                    data[i].reputation = 0;
                    i++;
                }
            }
            //Only send 10 packets at a time
            if (data.Length > 10)
            {
                DirPeopleReplyData[] retvals = new DirPeopleReplyData[10];
                i = 0;
                foreach (DirPeopleReplyData d in data)
                {
                    retvals[i] = d;
                    i++;
                    if (i == 10)
                    {
                        remoteClient.SendDirPeopleReply(queryID, retvals);
                        i = 0;
                        if (data.Length - i < 10)
                            retvals = new DirPeopleReplyData[data.Length - i];
                        else
                            retvals = new DirPeopleReplyData[10];
                    }
                }
                //Send the remaining
                if(retvals.Length != 0)
                    remoteClient.SendDirPeopleReply(queryID, retvals);
            }
            else //Send all if under 10
                remoteClient.SendDirPeopleReply(queryID, data);
            
        }
        //TODO: Flagged to optimize
        public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID,
                                   string queryText, uint queryFlags, int queryStart)
        {
            //Find the user accounts
            List <UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(remoteClient.AllScopeIDs,
                                                                                         queryText);
            List <DirPeopleReplyData> ReturnValues =
                new List <DirPeopleReplyData>();

            foreach (UserAccount item in accounts)
            {
                //This is really bad, we should not be searching for all of these people again in the Profile service
                IUserProfileInfo UserProfile = ProfileFrontend.GetUserProfile(item.PrincipalID);
                if (UserProfile == null)
                {
                    DirPeopleReplyData person = new DirPeopleReplyData
                    {
                        agentID   = item.PrincipalID,
                        firstName = item.FirstName,
                        lastName  = item.LastName
                    };
                    if (GroupsModule == null)
                    {
                        person.group = "";
                    }
                    else
                    {
                        person.group = "";
                        GroupMembershipData[] memberships = GroupsModule.GetMembershipData(item.PrincipalID);
                        foreach (GroupMembershipData membership in memberships.Where(membership => membership.Active))
                        {
                            person.group = membership.GroupName;
                        }
                    }
                    //Then we have to pull the GUI to see if the user is online or not
                    UserInfo Pinfo =
                        m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(item.PrincipalID.ToString());
                    if (Pinfo != null && Pinfo.IsOnline) //If it is null, they are offline
                    {
                        person.online = true;
                    }
                    person.reputation = 0;
                    ReturnValues.Add(person);
                }
                else if (UserProfile.AllowPublish) //Check whether they want to be in search or not
                {
                    DirPeopleReplyData person = new DirPeopleReplyData
                    {
                        agentID   = item.PrincipalID,
                        firstName = item.FirstName,
                        lastName  = item.LastName
                    };
                    if (GroupsModule == null)
                    {
                        person.group = "";
                    }
                    else
                    {
                        person.group = "";
                        //Check what group they have set
                        GroupMembershipData[] memberships = GroupsModule.GetMembershipData(item.PrincipalID);
                        foreach (GroupMembershipData membership in memberships.Where(membership => membership.Active))
                        {
                            person.group = membership.GroupName;
                        }
                    }
                    //Then we have to pull the GUI to see if the user is online or not
                    UserInfo Pinfo =
                        m_Scenes[0].RequestModuleInterface <IAgentInfoService>().GetUserInfo(item.PrincipalID.ToString());
                    if (Pinfo != null && Pinfo.IsOnline)
                    {
                        person.online = true;
                    }
                    person.reputation = 0;
                    ReturnValues.Add(person);
                }
            }

#if (!ISWIN)
            SplitPackets <DirPeopleReplyData>(ReturnValues, delegate(DirPeopleReplyData[] data)
            {
                remoteClient.SendDirPeopleReply(queryID, data);
            });
#else
            SplitPackets(ReturnValues,
                         data => remoteClient.SendDirPeopleReply(queryID, data));
#endif
        }
        public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID,
                string queryText, uint queryFlags, int queryStart)
        {
            queryText = queryText.Trim();   // newer viewers sometimes append a space

            List<AvatarPickerAvatar> AvatarResponses =
                    new List<AvatarPickerAvatar>();
            AvatarResponses = m_Scenes[0].SceneGridService.
                    GenerateAgentPickerRequestResponse(queryID, queryText);

            DirPeopleReplyData[] data =
                    new DirPeopleReplyData[AvatarResponses.Count];

            int i = 0;
            foreach (AvatarPickerAvatar item in AvatarResponses)
            {
                data[i] = new DirPeopleReplyData();

                data[i].agentID = item.AvatarID;
                data[i].firstName = item.firstName;
                data[i].lastName = item.lastName;
                data[i].group = String.Empty;
                data[i].online = false;
                data[i].reputation = 0;
                i++;
            }

            remoteClient.SendDirPeopleReply(queryID, data);
        }
        public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID,
									string queryText, uint queryFlags, int queryStart)
        {
            List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText);

            DirPeopleReplyData[] data = new DirPeopleReplyData[accounts.Count];

            int i = 0;
            foreach (UserAccount item in accounts)
            {
                if ((item.UserFlags&0x01)==1) {
                    data[i] 			= new DirPeopleReplyData();
                    data[i].agentID 	= item.PrincipalID;
                    data[i].firstName 	= item.FirstName;
                    data[i].lastName  	= item.LastName;
                    data[i].group 	 	= "";
                    data[i].online 		= false;
                    data[i].reputation 	= 0;
                    i++;
                }
            }

            remoteClient.SendDirPeopleReply(queryID, data);
        }
        //TODO: Flagged to optimize
        public void DirPeopleQuery(IClientAPI remoteClient, UUID queryID,
                                   string queryText, uint queryFlags, int queryStart)
        {
            List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText);
            DirPeopleReplyData[] data =
                    new DirPeopleReplyData[accounts.Count];

            int i = 0;
            foreach (UserAccount item in accounts)
            {
                IUserProfileInfo UserProfile = ProfileFrontend.GetUserProfile(item.PrincipalID);
                if (UserProfile == null)
                {
                    data[i] = new DirPeopleReplyData();
                    data[i].agentID = item.PrincipalID;
                    data[i].firstName = item.FirstName;
                    data[i].lastName = item.LastName;
                    if (GroupsModule == null)
                        data[i].group = "";
                    else
                    {
                        data[i].group = "";
                        GroupMembershipData[] memberships = GroupsModule.GetMembershipData(item.PrincipalID);
                        foreach (GroupMembershipData membership in memberships)
                        {
                            if (membership.Active)
                                data[i].group = membership.GroupName;
                        }
                    }
                    OpenSim.Services.Interfaces.GridUserInfo Pinfo = m_scene.GridUserService.GetGridUserInfo(item.PrincipalID.ToString());
                    if (Pinfo != null)
                        data[i].online = true;
                    data[i].reputation = 0;
                    i++;
                }
                else if (UserProfile.AllowPublish)
                {
                    data[i] = new DirPeopleReplyData();
                    data[i].agentID = item.PrincipalID;
                    data[i].firstName = item.FirstName;
                    data[i].lastName = item.LastName;
                    if (GroupsModule == null)
                        data[i].group = "";
                    else
                    {
                        data[i].group = "";
                        GroupMembershipData[] memberships = GroupsModule.GetMembershipData(item.PrincipalID);
                        foreach (GroupMembershipData membership in memberships)
                        {
                            if (membership.Active)
                                data[i].group = membership.GroupName;
                        }
                    }
                    OpenSim.Services.Interfaces.GridUserInfo Pinfo = m_scene.GridUserService.GetGridUserInfo(item.PrincipalID.ToString());
                    if (Pinfo != null)
                        data[i].online = true;
                    data[i].reputation = 0;
                    i++;
                }
            }
            if (data.Length > 10)
            {
                DirPeopleReplyData[] retvals = new DirPeopleReplyData[10];
                
                i = 0;
                foreach (DirPeopleReplyData d in data)
                {
                    retvals[i] = d;
                    i++;
                    if (i == 10)
                    {
                        remoteClient.SendDirPeopleReply(queryID, retvals);
                        i = 0;
                        if (data.Length - i < 10)
                        {
                            retvals = new DirPeopleReplyData[data.Length - i];
                        }
                        else
                        {
                            retvals = new DirPeopleReplyData[10];
                        }
                    }
                }
                remoteClient.SendDirPeopleReply(queryID, retvals);
            }
            else
                remoteClient.SendDirPeopleReply(queryID, data);
            
        }
        void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
        {
            if (!string.IsNullOrEmpty(queryText))
            {
                queryText = queryText.Trim();
                queryText = queryText.ToLowerInvariant();
            }

            if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People)
            {
                if (string.IsNullOrEmpty(queryText))
                {
                    remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]);
                }

                List <UserAccount> accounts;
                if (!queryPeopleCache.TryGetValue(queryText, out accounts))
                {
                    accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText);
                }

                queryPeopleCache.AddOrUpdate(queryText, accounts, 30.0);

                if (accounts.Count == 0)
                {
                    remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]);
                    return;
                }

                DirPeopleReplyData[] hits = new DirPeopleReplyData[accounts.Count];
                int count = 0;
                foreach (UserAccount acc in accounts)
                {
                    DirPeopleReplyData d = new DirPeopleReplyData();
                    d.agentID   = acc.PrincipalID;
                    d.firstName = acc.FirstName;
                    d.lastName  = acc.LastName;
                    d.online    = false;

                    hits[count++] = d;
                }

                // viewers don't sent sorting, so results they show are a nice mess
                if ((queryStart > 0) && (queryStart < count))
                {
                    int len = count - queryStart;
                    if (len > 101) // a viewer page is 100
                    {
                        len = 101;
                    }
                    DirPeopleReplyData[] tmp = new DirPeopleReplyData[len];
                    Array.Copy(hits, queryStart, tmp, 0, len);
                    hits = tmp;
                }
                else if (count > 101)
                {
                    DirPeopleReplyData[] tmp = new DirPeopleReplyData[101];
                    Array.Copy(hits, 0, tmp, 0, 101);
                    hits = tmp;
                }
                // TODO: This currently ignores pretty much all the query flags including Mature and sort order
                remoteClient.SendDirPeopleReply(queryID, hits);
            }
            else if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
            {
                if (m_GroupsService == null)
                {
                    m_log.Warn("[BASIC SEARCH MODULE]: Groups service is not available. Unable to search groups.");
                    remoteClient.SendAlertMessage("Groups search is not enabled");
                    return;
                }

                if (string.IsNullOrEmpty(queryText))
                {
                    remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
                }

                List <DirGroupsReplyData> answer;
                if (!queryGroupCache.TryGetValue(queryText, out answer))
                {
                    answer = m_GroupsService.FindGroups(remoteClient, queryText);
                }

                queryGroupCache.AddOrUpdate(queryText, answer, 30.0);

                if (answer.Count == 0)
                {
                    remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
                    return;
                }

                // filter out groups
                DirGroupsReplyData[] result = new DirGroupsReplyData[answer.Count];
                int count = 0;
                foreach (DirGroupsReplyData dgrd in answer)
                {
                    if (dgrd.members > 0)
                    {
                        result[count++] = dgrd;
                    }
                }
                answer = null;

                // viewers don't sent sorting, so results they show are a nice mess
                if ((queryStart > 0) && (queryStart < count))
                {
                    int len = count - queryStart;
                    if (len > 101) // a viewer page is 100
                    {
                        len = 101;
                    }
                    DirGroupsReplyData[] tmp = new DirGroupsReplyData[len];
                    Array.Copy(result, queryStart, tmp, 0, len);
                    result = tmp;
                }
                else if (count > 101)
                {
                    DirGroupsReplyData[] tmp = new DirGroupsReplyData[101];
                    Array.Copy(result, 0, tmp, 0, 101);
                    result = tmp;
                }

                // TODO: This currently ignores pretty much all the query flags including Mature and sort order
                remoteClient.SendDirGroupsReply(queryID, result);
            }
        }
        void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
        {
            queryText = queryText.Trim();

            if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People)
            {
                if (string.IsNullOrEmpty(queryText))
                    remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]);

                List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText);
                DirPeopleReplyData[] hits = new DirPeopleReplyData[accounts.Count];
                int i = 0;
                foreach (UserAccount acc in accounts)
                {
                    DirPeopleReplyData d = new DirPeopleReplyData();
                    d.agentID = acc.PrincipalID;
                    d.firstName = acc.FirstName;
                    d.lastName = acc.LastName;
                    d.online = false;

                    hits[i++] = d;
                }

                // TODO: This currently ignores pretty much all the query flags including Mature and sort order
                remoteClient.SendDirPeopleReply(queryID, hits);
            }
            else if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
            {
                if (m_GroupsService == null)
                {
                    m_log.Warn("[BASIC SEARCH MODULE]: Groups service is not available. Unable to search groups.");
                    remoteClient.SendAlertMessage("Groups search is not enabled");
                    return;
                }

                if (string.IsNullOrEmpty(queryText))
                    remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);

                // TODO: This currently ignores pretty much all the query flags including Mature and sort order
                remoteClient.SendDirGroupsReply(queryID, m_GroupsService.FindGroups(remoteClient, queryText).ToArray());
            }

        }