Esempio n. 1
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());
            }
        }
Esempio n. 2
0
        public void DirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
        {
            m_log.InfoFormat("[OPEN SEARCH MODULE]: DirFindQuery Flags = {0}", queryFlags);

            /*
             * DirFindFlags
             *      People = 1,
             *      Online = 2,
             *      Events = 8,
             *      Groups = 16,
             *      DateEvents = 32,
             *      AgentOwned = 64,
             *      ForSale = 128,
             *      GroupOwned = 256,
             *      DwellSort = 1024,
             *      PgSimsOnly = 2048,
             *      PicturesOnly = 4096,
             *      PgEventsOnly = 8192,
             *      MatureSimsOnly = 16384,
             *      SortAsc = 32768,
             *      PricesSort = 65536,
             *      PerMeterSort = 131072,
             *      AreaSort = 262144,
             *      NameSort = 524288,
             *      LimitByPrice = 1048576,
             *      LimitByArea = 2097152,
             *      FilterMature = 4194304,
             *      PGOnly = 8388608,
             *      IncludePG = 16777216,
             *      IncludeMature = 33554432,
             *      IncludeAdult = 67108864,
             *      AdultOnly = 134217728,
             */

            //
            if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People)
            {
                m_log.InfoFormat("[OPEN SEARCH MODULE]: DirFindQuery.People");
                DirPeopleQuery(remoteClient, queryID, queryText, queryFlags, queryStart);
                return;
            }
            else if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
            {
                m_log.InfoFormat("[OPEN SEARCH MODULE]: DirFindQuery.Groups");
                if (m_GroupsService == null)
                {
                    m_log.Warn("[OPEN 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]);
                }
                remoteClient.SendDirGroupsReply(queryID, m_GroupsService.FindGroups(remoteClient, queryText).ToArray());
                return;
            }
            else if (((DirFindFlags)queryFlags & DirFindFlags.DateEvents) == DirFindFlags.DateEvents)
            {
                m_log.InfoFormat("[OPEN SEARCH MODULE]: DirFindQuery.DateEvents");
                DirEventsQuery(remoteClient, queryID, queryText, queryFlags, queryStart);
                return;
            }
        }
Esempio n. 3
0
        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);
            }
        }