FromOSD() public method

public FromOSD ( OSDMap map ) : void
map OSDMap
return void
        public Classified GetClassifiedByID(UUID id)
        {
            object remoteValue = DoRemote(id);
            if (remoteValue != null || m_doRemoteOnly)
                return (Classified) remoteValue;

            QueryFilter filter = new QueryFilter();
            Dictionary<string, object> where = new Dictionary<string, object>(1);
            where.Add("ClassifiedUUID", id);
            filter.andFilters = where;
            List<string> retVal = GD.Query(new[] {"*"}, "userclassifieds", filter, null, null, null);
            if ((retVal == null) || (retVal.Count == 0)) return null;
            Classified classified = new Classified();
            classified.FromOSD((OSDMap) OSDParser.DeserializeJson(retVal[6]));
            return classified;
        }
        public List<Classified> GetClassifiedsInRegion(string regionName)
        {
            object remoteValue = DoRemote(regionName);
            if (remoteValue != null || m_doRemoteOnly)
                return (List<Classified>) remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["SimName"] = regionName;
            List<string> retVal = GD.Query(new[] {"*"}, "userclassifieds", filter, null, null, null);

            if (retVal.Count == 0)
            {
                return new List<Classified>();
            }

            List<Classified> Classifieds = new List<Classified>();
            for (int i = 0; i < retVal.Count; i += 9)
            {
                Classified classified = new Classified();
                //Pull the classified out of OSD
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(retVal[i + 6]));
                Classifieds.Add(classified);
            }
            return Classifieds;
        }
        public List<DirClassifiedReplyData> FindClassifieds(string queryText, string category, uint queryFlags,
            int StartQuery, UUID scopeID)
        {
            object remoteValue = DoRemote(queryText, category, queryFlags, StartQuery, scopeID);
            if (remoteValue != null || m_doRemoteOnly)
                return (List<DirClassifiedReplyData>) remoteValue;

            QueryFilter filter = new QueryFilter();

            filter.andLikeFilters["Name"] = "%" + queryText + "%";
            if (int.Parse(category) != (int) DirectoryManager.ClassifiedCategories.Any) //Check the category
                filter.andFilters["Category"] = category;
            if (scopeID != UUID.Zero)
                filter.andFilters["ScopeID"] = scopeID;

            List<string> retVal = GD.Query(new[] {"*"}, "userclassifieds", filter, null, (uint) StartQuery, 50);
            if (retVal.Count == 0)
                return new List<DirClassifiedReplyData>();

            List<DirClassifiedReplyData> Data = new List<DirClassifiedReplyData>();
            for (int i = 0; i < retVal.Count; i += 9)
            {
                //Pull the classified out of OSD
                Classified classified = new Classified();
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(retVal[i + 5]));

                DirClassifiedReplyData replyData = new DirClassifiedReplyData
                                                       {
                                                           classifiedFlags = classified.ClassifiedFlags,
                                                           classifiedID = classified.ClassifiedUUID,
                                                           creationDate = classified.CreationDate,
                                                           expirationDate = classified.ExpirationDate,
                                                           price = classified.PriceForListing,
                                                           name = classified.Name
                                                       };
                //Check maturity levels
                if ((replyData.classifiedFlags & (uint) DirectoryManager.ClassifiedFlags.Mature) !=
                    (uint) DirectoryManager.ClassifiedFlags.Mature)
                {
                    if ((queryFlags & (uint) DirectoryManager.ClassifiedQueryFlags.Mature) ==
                        (uint) DirectoryManager.ClassifiedQueryFlags.Mature)
                        Data.Add(replyData);
                }
                else
                    //Its Mature, add all
                    Data.Add(replyData);
            }
            return Data;
        }
        public List<Classified> GetAllClassifieds (int category, uint classifiedFlags)
        {
            // WebUI call
            List<Classified> classifieds = new List<Classified> ();

            if (m_doRemoteOnly) {
                object remoteValue = DoRemote (category, classifiedFlags);
                return remoteValue != null ? (List<Classified>)remoteValue : classifieds;
            }

            QueryFilter filter = new QueryFilter ();

            //filter.andLikeFilters ["Name"] = "%" + queryText + "%";
            if (category != (int)DirectoryManager.ClassifiedCategories.Any) //Check the category
                filter.andFilters ["Category"] = category.ToString();
            //if (scopeID != UUID.Zero)
            //    filter.andFilters ["ScopeID"] = scopeID;

            List<string> retVal = GD.Query (new [] { "*" }, m_userClassifiedsTable, filter, null, null, null);

            if (retVal.Count != 0) {
                for (int i = 0; i < retVal.Count; i += 9) {
                    Classified classified = new Classified ();
                    //Pull the classified out of OSD
                    classified.FromOSD ((OSDMap)OSDParser.DeserializeJson (retVal [i + 6]));

                    //Check maturity levels
                    if (classifiedFlags != (uint)DirectoryManager.ClassifiedQueryFlags.All) {
                        if ((classifiedFlags & classified.ClassifiedFlags) != 0) // required rating All, PG, Mature ( Adult )
                            classifieds.Add (classified);
                    } else
                        // add all
                        classifieds.Add (classified);
                }
            }
            return classifieds;
        }
        public List<DirClassifiedReplyData> FindClassifieds(string queryText, string category, uint queryFlags,
                                                            int StartQuery, UUID scopeID)
        {
            if (m_doRemoteOnly) {
                object remoteValue = DoRemote (queryText, category, queryFlags, StartQuery, scopeID);
                return remoteValue != null ? (List<DirClassifiedReplyData>)remoteValue : new List<DirClassifiedReplyData> ();
            }

            QueryFilter filter = new QueryFilter();

            filter.andLikeFilters["Name"] = "%" + queryText + "%";
            if (int.Parse(category) != (int) DirectoryManager.ClassifiedCategories.Any) //Check the category
                filter.andFilters["Category"] = category;
            if (scopeID != UUID.Zero)
                filter.andFilters["ScopeID"] = scopeID;

            List<string> retVal = GD.Query(new[] {"*"}, m_userClassifiedsTable, filter, null, (uint) StartQuery, 50);
            if (retVal.Count == 0)
                return new List<DirClassifiedReplyData>();

            List<DirClassifiedReplyData> Data = new List<DirClassifiedReplyData>();
            for (int i = 0; i < retVal.Count; i += 9)
            {
                //Pull the classified out of OSD
                Classified classified = new Classified();
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(retVal[i + 6]));

                DirClassifiedReplyData replyData = new DirClassifiedReplyData
                                                       {
                                                           classifiedFlags = classified.ClassifiedFlags,
                                                           classifiedID = classified.ClassifiedUUID,
                                                           creationDate = classified.CreationDate,
                                                           expirationDate = classified.ExpirationDate,
                                                           price = classified.PriceForListing,
                                                           name = classified.Name
                                                       };
                //Check maturity levels
                var maturityquery = queryFlags & 0x4C;      // strip everything except what we want
                if (maturityquery == (uint)DirectoryManager.ClassifiedQueryFlags.All)
                    Data.Add (replyData); 
                else {
                    //var classifiedMaturity = replyData.classifiedFlags > 0 
                    //                                  ? replyData.classifiedFlags 
                    //                                  : (byte)DirectoryManager.ClassifiedQueryFlags.PG;
                    if ((maturityquery & replyData.classifiedFlags) != 0) // required rating  PG, Mature (Adult)
                            Data.Add (replyData);
                }
            }
            return Data;
        }
        public List<Classified> GetClassifieds(UUID ownerID)
        {
            object remoteValue = DoRemote(ownerID);
            if (remoteValue != null || m_doRemoteOnly)
                return (List<Classified>) remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["OwnerUUID"] = ownerID;

            List<string> query = GD.Query(new[] {"*"}, "userclassifieds", filter, null, null, null);

            List<Classified> classifieds = new List<Classified>();
            for (int i = 0; i < query.Count; i += 9)
            {
                Classified classified = new Classified();
                classified.FromOSD((OSDMap) OSDParser.DeserializeJson(query[i + 6]));
                classifieds.Add(classified);
            }
            return classifieds;
        }
        public Classified GetClassified(UUID queryClassifiedID)
        {
            object remoteValue = DoRemote(queryClassifiedID);
            if (remoteValue != null || m_doRemoteOnly)
                return (Classified) remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["ClassifiedUUID"] = queryClassifiedID;

            List<string> query = GD.Query(new[] {"*"}, "userclassifieds", filter, null, null, null);

            if (query.Count < 9)
            {
                return null;
            }
            Classified classified = new Classified();
            classified.FromOSD((OSDMap) OSDParser.DeserializeJson(query[6]));
            return classified;
        }