Esempio n. 1
0
        OSDMap GetParcel(OSDMap map)
        {
            OSDMap resp = new OSDMap();

            UUID regionID = map.ContainsKey("RegionID") ? UUID.Parse(map ["RegionID"].ToString()) : UUID.Zero;
            // not used?? // UUID scopeID = map.ContainsKey ("ScopeID") ? UUID.Parse (map ["ScopeID"].ToString ()) : UUID.Zero;
            UUID   parcelID   = map.ContainsKey("ParcelInfoUUID") ? UUID.Parse(map ["ParcelInfoUUID"].ToString()) : UUID.Zero;
            string parcelName = map.ContainsKey("Parcel") ? map ["Parcel"].ToString().Trim() : string.Empty;

            var directory = DataPlugins.RequestPlugin <IDirectoryServiceConnector> ();

            if (directory != null && (parcelID != UUID.Zero || (regionID != UUID.Zero && parcelName != string.Empty)))
            {
                LandData parcel = null;

                if (parcelID != UUID.Zero)
                {
                    parcel = directory.GetParcelInfo(parcelID);
                }
                else if (regionID != UUID.Zero && parcelName != string.Empty)
                {
                    parcel = directory.GetParcelInfo(regionID, parcelName);
                }

                if (parcel != null)
                {
                    resp ["Parcel"] = LandData2WebOSD(parcel);
                }
            }

            return(resp);
        }
Esempio n. 2
0
        OSDMap GetRegion(OSDMap map)
        {
            OSDMap      resp       = new OSDMap();
            IRegionData regiondata = DataPlugins.RequestPlugin <IRegionData> ();

            if (regiondata != null && (map.ContainsKey("RegionID") || map.ContainsKey("Region")))
            {
                string regionName = map.ContainsKey("Region") ? map ["Region"].ToString().Trim() : "";
                UUID   regionID   = map.ContainsKey("RegionID") ? UUID.Parse(map ["RegionID"].ToString()) : UUID.Zero;
                // not used?? // UUID scopeID = map.ContainsKey ("ScopeID") ? UUID.Parse (map ["ScopeID"].ToString ()) : UUID.Zero;
                GridRegion region = null;
                if (regionID != UUID.Zero)
                {
                    region = regiondata.Get(regionID, null);
                }
                else if (regionName != string.Empty)
                {
                    region = regiondata.Get(regionName, null, null, null) [0];
                }
                if (region != null)
                {
                    resp ["Region"] = region.ToOSD();
                }
            }
            return(resp);
        }
Esempio n. 3
0
        OSDMap GetRegions(OSDMap map)
        {
            OSDMap      resp  = new OSDMap();
            RegionFlags type  = map.Keys.Contains("RegionFlags") ? (RegionFlags)map ["RegionFlags"].AsInteger() : RegionFlags.RegionOnline;
            int         start = map.Keys.Contains("Start") ? map ["Start"].AsInteger() : 0;

            if (start < 0)
            {
                start = 0;
            }
            int count = map.Keys.Contains("Count") ? map ["Count"].AsInteger() : 10;

            if (count < 0)
            {
                count = 1;
            }

            var regiondata = DataPlugins.RequestPlugin <IRegionData> ();

            Dictionary <string, bool> sort = new Dictionary <string, bool> ();

            string [] supportedSort =
            {
                "SortRegionName",
                "SortLocX",
                "SortLocY"
            };

            foreach (string sortable in supportedSort)
            {
                if (map.ContainsKey(sortable))
                {
                    sort [sortable.Substring(4)] = map [sortable].AsBoolean();
                }
            }

            List <GridRegion> regions = regiondata.Get(type, sort);
            OSDArray          Regions = new OSDArray();

            if (start < regions.Count)
            {
                int i = 0;
                int j = regions.Count <= (start + count) ? regions.Count : (start + count);
                for (i = start; i < j; ++i)
                {
                    Regions.Add(regions [i].ToOSD());
                }
            }
            resp ["Start"]   = OSD.FromInteger(start);
            resp ["Count"]   = OSD.FromInteger(count);
            resp ["Total"]   = OSD.FromInteger(regions.Count);
            resp ["Regions"] = Regions;
            return(resp);
        }
Esempio n. 4
0
        OSDMap GetGroups(OSDMap map)
        {
            var resp  = new OSDMap();
            var start = map.ContainsKey("Start") ? map ["Start"].AsUInteger() : 0;

            resp ["Start"] = start;
            resp ["Total"] = 0;

            var groups = DataPlugins.RequestPlugin <IGroupsServiceConnector> ();
            var Groups = new OSDArray();

            if (groups != null)
            {
                var sort       = new Dictionary <string, bool> ();
                var boolFields = new Dictionary <string, bool> ();

                if (map.ContainsKey("Sort") && map ["Sort"].Type == OSDType.Map)
                {
                    var fields = (OSDMap)map ["Sort"];
                    foreach (string field in fields.Keys)
                    {
                        sort [field] = int.Parse(fields [field]) != 0;
                    }
                }
                if (map.ContainsKey("BoolFields") && map ["BoolFields"].Type == OSDType.Map)
                {
                    var fields = (OSDMap)map ["BoolFields"];
                    foreach (string field in fields.Keys)
                    {
                        boolFields [field] = int.Parse(fields [field]) != 0;
                    }
                }
                var reply = groups.GetGroupRecords(
                    AdminAgentID,
                    start,
                    map.ContainsKey("Count") ? map ["Count"].AsUInteger() : 10,
                    sort,
                    boolFields
                    );
                if (reply.Count > 0)
                {
                    foreach (GroupRecord groupReply in reply)
                    {
                        Groups.Add(GroupRecord2OSDMap(groupReply));
                    }
                }
                resp ["Total"] = groups.GetNumberOfGroups(AdminAgentID, boolFields);
            }

            resp ["Groups"] = Groups;
            return(resp);
        }
Esempio n. 5
0
        OSDMap GroupNotices(OSDMap map)
        {
            var resp = new OSDMap();

            resp ["GroupNotices"] = new OSDArray();
            resp ["Total"]        = 0;
            var groups = DataPlugins.RequestPlugin <IGroupsServiceConnector> ();

            if (map.ContainsKey("Groups") && groups != null && map ["Groups"].Type.ToString() == "Array")
            {
                var groupIDs = (OSDArray)map ["Groups"];
                var GroupIDs = new List <UUID> ();
                foreach (string groupID in groupIDs)
                {
                    UUID foo;
                    if (UUID.TryParse(groupID, out foo))
                    {
                        GroupIDs.Add(foo);
                    }
                }
                if (GroupIDs.Count > 0)
                {
                    var start           = map.ContainsKey("Start") ? uint.Parse(map ["Start"]) : 0;
                    var count           = map.ContainsKey("Count") ? uint.Parse(map ["Count"]) : 10;
                    var groupNoticeList = groups.GetGroupNotices(AdminAgentID, start, count, GroupIDs);
                    var groupNotices    = new OSDArray(groupNoticeList.Count);

                    foreach (GroupNoticeData GND in groupNoticeList)
                    {
                        var gnd = new OSDMap();

                        gnd ["GroupID"]       = OSD.FromUUID(GND.GroupID);
                        gnd ["NoticeID"]      = OSD.FromUUID(GND.NoticeID);
                        gnd ["Timestamp"]     = OSD.FromInteger((int)GND.Timestamp);
                        gnd ["FromName"]      = OSD.FromString(GND.FromName);
                        gnd ["Subject"]       = OSD.FromString(GND.Subject);
                        gnd ["HasAttachment"] = OSD.FromBoolean(GND.HasAttachment);
                        gnd ["ItemID"]        = OSD.FromUUID(GND.ItemID);
                        gnd ["AssetType"]     = OSD.FromInteger((int)GND.AssetType);
                        gnd ["ItemName"]      = OSD.FromString(GND.ItemName);

                        var notice = groups.GetGroupNotice(AdminAgentID, GND.NoticeID);
                        gnd ["Message"] = OSD.FromString(notice.Message);
                        groupNotices.Add(gnd);
                    }
                    resp ["GroupNotices"] = groupNotices;
                    resp ["Total"]        = (int)groups.GetNumberOfGroupNotices(AdminAgentID, GroupIDs);
                }
            }

            return(resp);
        }
Esempio n. 6
0
        OSDMap NewsFromGroupNotices(OSDMap map)
        {
            var resp = new OSDMap();

            resp ["GroupNotices"] = new OSDArray();
            resp ["Total"]        = 0;
            var generics = DataPlugins.RequestPlugin <IGenericsConnector> ();
            var groups   = DataPlugins.RequestPlugin <IGroupsServiceConnector> ();

            if (generics == null || groups == null)
            {
                return(resp);
            }

            var useValue = new OSDMap();

            useValue ["Use"] = OSD.FromBoolean(true);
            var GroupIDs = generics.GetOwnersByGeneric("Group", "WebUI_newsSource", useValue);

            if (GroupIDs.Count <= 0)
            {
                return(resp);
            }
            foreach (UUID groupID in GroupIDs)
            {
                var group = groups.GetGroupRecord(AdminAgentID, groupID, "");
                if (!group.ShowInList)
                {
                    GroupIDs.Remove(groupID);
                }
            }

            var start = map.ContainsKey("Start") ? uint.Parse(map ["Start"].ToString()) : 0;
            var count = map.ContainsKey("Count") ? uint.Parse(map ["Count"].ToString()) : 10;

            var args = new OSDMap();

            args ["Start"]  = OSD.FromString(start.ToString());
            args ["Count"]  = OSD.FromString(count.ToString());
            args ["Groups"] = new OSDArray(GroupIDs.ConvertAll(x => OSD.FromString(x.ToString())));

            return(GroupNotices(args));
        }
Esempio n. 7
0
        OSDMap GetGroup(OSDMap map)
        {
            var resp   = new OSDMap();
            var groups = DataPlugins.RequestPlugin <IGroupsServiceConnector> ();

            resp ["Group"] = false;

            if (groups != null && (map.ContainsKey("Name") || map.ContainsKey("UUID")))
            {
                UUID        groupID = map.ContainsKey("UUID") ? UUID.Parse(map ["UUID"].ToString()) : UUID.Zero;
                string      name    = map.ContainsKey("Name") ? map ["Name"].ToString() : "";
                GroupRecord reply   = groups.GetGroupRecord(AdminAgentID, groupID, name);
                if (reply != null)
                {
                    resp ["Group"] = GroupRecord2OSDMap(reply);
                }
            }
            return(resp);
        }
        OSDMap GetClassifieds(OSDMap map)
        {
            var resp = new OSDMap();

            var directory = DataPlugins.RequestPlugin <IDirectoryServiceConnector> ();

            if (directory != null)
            {
                var classifieds = new List <Classified> ();

                int category = map.Keys.Contains("category")
                                  ? map ["category"].AsInteger()
                                  : (int)DirectoryManager.ClassifiedCategories.Any;
                int maturity = map.Keys.Contains("maturity")
                                  ? map ["maturity"].AsInteger()
                                  : (int)DirectoryManager.ClassifiedFlags.None;

                classifieds = directory.GetAllClassifieds(category, (uint)maturity);

                if (classifieds.Count > 0)
                {
                    // build a list of classifieds
                    var clarry = new OSDArray();
                    foreach (var classified in classifieds)
                    {
                        clarry.Add(classified.ToOSD());
                    }

                    resp ["classifieds"] = clarry;
                    resp ["count"]       = clarry.Count.ToString();

                    return(resp);
                }
            }

            // no classifieds
            resp ["classifieds"] = new OSDArray();
            resp ["count"]       = "0";

            return(resp);
        }
Esempio n. 9
0
        OSDMap GetParcelsByRegion(OSDMap map)
        {
            var resp = new OSDMap();

            resp ["Parcels"] = new OSDArray();
            resp ["Total"]   = OSD.FromInteger(0);

            var directory = DataPlugins.RequestPlugin <IDirectoryServiceConnector> ();

            if (directory != null && map.ContainsKey("Region") == true)
            {
                UUID regionID = UUID.Parse(map ["Region"]);
                // not used? // UUID scopeID = map.ContainsKey ("ScopeID") ? UUID.Parse (map ["ScopeID"].ToString ()) : UUID.Zero;
                UUID           owner    = map.ContainsKey("Owner") ? UUID.Parse(map ["Owner"].ToString()) : UUID.Zero;
                uint           start    = map.ContainsKey("Start") ? uint.Parse(map ["Start"].ToString()) : 0;
                uint           count    = map.ContainsKey("Count") ? uint.Parse(map ["Count"].ToString()) : 10;
                ParcelFlags    flags    = map.ContainsKey("Flags") ? (ParcelFlags)int.Parse(map ["Flags"].ToString()) : ParcelFlags.None;
                ParcelCategory category = map.ContainsKey("Category") ? (ParcelCategory)uint.Parse(map ["Flags"].ToString()) : ParcelCategory.Any;
                uint           total    = directory.GetNumberOfParcelsByRegion(regionID, owner, flags, category);

                if (total > 0)
                {
                    resp ["Total"] = OSD.FromInteger((int)total);
                    if (count == 0)
                    {
                        return(resp);
                    }
                    List <LandData> regionParcels = directory.GetParcelsByRegion(start, count, regionID, owner, flags, category);
                    OSDArray        parcels       = new OSDArray(regionParcels.Count);
                    regionParcels.ForEach(delegate(LandData parcel) {
                        parcels.Add(LandData2WebOSD(parcel));
                    });
                    resp ["Parcels"] = parcels;
                }
            }

            return(resp);
        }
Esempio n. 10
0
        OSDMap GroupAsNewsSource(OSDMap map)
        {
            var resp = new OSDMap();

            resp ["Verified"] = OSD.FromBoolean(false);
            var  generics = DataPlugins.RequestPlugin <IGenericsConnector> ();
            UUID groupID;

            if (generics != null && map.ContainsKey("Group") == true && map.ContainsKey("Use") && UUID.TryParse(map ["Group"], out groupID) == true)
            {
                if (map ["Use"].AsBoolean())
                {
                    var useValue = new OSDMap();
                    useValue ["Use"] = OSD.FromBoolean(true);
                    generics.AddGeneric(groupID, "Group", "WebUI_newsSource", useValue);
                }
                else
                {
                    generics.RemoveGeneric(groupID, "Group", "WebUI_newsSource");
                }
                resp ["Verified"] = OSD.FromBoolean(true);
            }
            return(resp);
        }