Пример #1
0
        /// <summary>
        /// Ask server for details of cost and impact of the mesh upload
        /// </summary>
        /// <param name="callback">Callback that will be invoke upon completion of the upload. Null is sent on request failure</param>
        public void PrepareUpload(ModelUploadCallback callback)
        {
            CapsClient request = null;

            if (Client.Network.CurrentSim == null ||
                Client.Network.CurrentSim.Caps == null ||
                (request = Client.Network.CurrentSim.Caps.CreateCapsClient("NewFileAgentInventory")) == null)
            {
                Logger.Log("Cannot upload mesh, no connection or NewFileAgentInventory not available", Helpers.LogLevel.Warning);
                callback?.Invoke(null);
                return;
            }

            Images   = new List <byte[]>();
            ImgIndex = new Dictionary <string, int>();

            OSDMap req = new OSDMap
            {
                ["name"]              = InvName,
                ["description"]       = InvDescription,
                ["asset_resources"]   = AssetResources(false),
                ["asset_type"]        = "mesh",
                ["inventory_type"]    = "object",
                ["folder_id"]         = Client.Inventory.FindFolderForType(AssetType.Object),
                ["texture_folder_id"] = Client.Inventory.FindFolderForType(AssetType.Texture),
                ["everyone_mask"]     = (int)PermissionMask.All,
                ["group_mask"]        = (int)PermissionMask.All,
                ["next_owner_mask"]   = (int)PermissionMask.All
            };

            request.OnComplete += (client, result, error) =>
            {
                if (error != null || result == null || result.Type != OSDType.Map)
                {
                    Logger.Log("Mesh upload request failure", Helpers.LogLevel.Error);
                    callback?.Invoke(null);
                    return;
                }
                OSDMap res = (OSDMap)result;

                if (res["state"] != "upload")
                {
                    Logger.Log("Mesh upload failure: " + res["message"], Helpers.LogLevel.Error);
                    callback?.Invoke(null);
                    return;
                }

                Logger.Log("Response from mesh upload prepare:" + Environment.NewLine + OSDParser.SerializeLLSDNotationFormatted(result), Helpers.LogLevel.Debug);
                callback?.Invoke(result);
            };

            request.PostRequestAsync(req, OSDFormat.Xml, 3 * 60 * 1000);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="layer"></param>
        public void RequestMapLayer(GridLayerType layer)
        {
            CapsClient request = Client.Network.CurrentSim.Caps.CreateCapsClient("MapLayer");

            if (request != null)
            {
                OSDMap body = new OSDMap {
                    ["Flags"] = OSD.FromInteger((int)layer)
                };

                request.OnComplete += new CapsClient.CompleteCallback(MapLayerResponseHandler);
                request.PostRequestAsync(body, OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
            }
        }
Пример #3
0
        /// <summary>
        /// Sends user report first by trying SendUserReport sim cap, falling back to legacy
        /// </summary>
        /// <param name="reportType"></param>
        /// <param name="category"></param>
        /// <param name="screenshotId"></param>
        /// <param name="objectId"></param>
        /// <param name="abuserId"></param>
        /// <param name="abuseRegionName"></param>
        /// <param name="abuseRegionId"></param>
        /// <param name="pos"></param>
        /// <param name="summary"></param>
        /// <param name="details"></param>
        public void SendUserReport(ReportType reportType, int category,
                                   UUID screenshotId, UUID objectId, UUID abuserId,
                                   string abuseRegionName, UUID abuseRegionId, Vector3 pos,
                                   string summary, string details)
        {
            OSDMap report = new OSDMap
            {
                ["report-type"]       = (byte)reportType,
                ["category"]          = (byte)category,
                ["check-flags"]       = (byte)0u, // this is not used
                ["screenshot-id"]     = screenshotId,
                ["object-id"]         = objectId,
                ["abuser-id"]         = abuserId,
                ["abuse-region-name"] = "",
                ["abuse-region-id"]   = UUID.Zero,
                ["position"]          = pos,
                ["summary"]           = summary,
                ["version-string"]    = $"<3 LibreMetaverse",
                ["details"]           = details
            };

            Uri userReportCap = (screenshotId != UUID.Zero)
                ? Client.Network.CurrentSim.Caps.CapabilityURI("SendUserReportWithScreenshot")
                : Client.Network.CurrentSim.Caps.CapabilityURI("SendUserReport");

            if (userReportCap != null)
            {
                var request = new CapsClient(userReportCap);
                request.OnComplete += delegate(CapsClient client, OSD result, Exception error)
                {
                    if (error != null)
                    {
                        Logger.Log($"Failed to send abuse report via {userReportCap}. " +
                                   $"({error.Message}) Falling back to legacy protocol.",
                                   Helpers.LogLevel.Warning);
                        SendUserReportLegacy(reportType, category, screenshotId, objectId, abuserId,
                                             abuseRegionName, abuseRegionId, pos, summary, details);
                    }
                };
                request.PostRequestAsync(report, OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
            }
            else
            {
                SendUserReportLegacy(reportType, category, screenshotId, objectId, abuserId,
                                     abuseRegionName, abuseRegionId, pos, summary, details);
            }
        }
Пример #4
0
        /// <summary>
        /// Performas actual mesh and image upload
        /// </summary>
        /// <param name="uploader">Uri recieved in the upload prepare stage</param>
        /// <param name="callback">Callback that will be invoke upon completion of the upload. Null is sent on request failure</param>
        public void PerformUpload(Uri uploader, ModelUploadCallback callback)
        {
            CapsClient request = new CapsClient(uploader, "MeshUploader");

            request.OnComplete += (client, result, error) =>
            {
                if (error != null || result == null || result.Type != OSDType.Map)
                {
                    Logger.Log("Mesh upload request failure", Helpers.LogLevel.Error);
                    callback?.Invoke(null);
                    return;
                }
                OSDMap res = (OSDMap)result;
                Logger.Log("Response from mesh upload perform:" + Environment.NewLine
                           + OSDParser.SerializeLLSDNotationFormatted(result), Helpers.LogLevel.Debug);
                callback?.Invoke(res);
            };

            request.PostRequestAsync(AssetResources(true), OSDFormat.Xml, 60 * 1000);
        }
Пример #5
0
        private void MakeSeedRequest()
        {
            if (Simulator == null || !Simulator.Client.Network.Connected)
            {
                return;
            }

            // Create a request list
            OSDArray req = new OSDArray
            {
                "AbuseCategories",
                "AcceptFriendship",
                "AcceptGroupInvite",
                "AgentPreferences",
                "AgentState",
                "AttachmentResources",
                "AvatarPickerSearch",
                "AvatarRenderInfo",
                "CharacterProperties",
                "ChatSessionRequest",
                "CopyInventoryFromNotecard",
                "CreateInventoryCategory",
                "DeclineFriendship",
                "DeclineGroupInvite",
                "DispatchRegionInfo",
                "DirectDelivery",
                "EnvironmentSettings",
                "EstateChangeInfo",
                "EventQueueGet",
                "ExtEnvironment",
                "FetchLib2",
                "FetchLibDescendents2",
                "FetchInventory2",
                "FetchInventoryDescendents2",
                "IncrementCOFVersion",
                "GetDisplayNames",
                "GetExperiences",
                "AgentExperiences",
                "FindExperienceByName",
                "GetExperienceInfo",
                "GetAdminExperiences",
                "GetCreatorExperiences",
                "ExperiencePreferences",
                "GroupExperiences",
                "UpdateExperience",
                "IsExperienceAdmin",
                "IsExperienceContributor",
                "RegionExperiences",
                "ExperienceQuery",
                "GetMesh",
                "GetMesh2",
                "GetMetadata",
                "GetObjectCost",
                "GetObjectPhysicsData",
                "GetTexture",
                "GroupAPIv1",
                "GroupMemberData",
                "GroupProposalBallot",
                "HomeLocation",
                "LandResources",
                "LSLSyntax",
                "MapLayer",
                "MapLayerGod",
                "MeshUploadFlag",
                "NavMeshGenerationStatus",
                "NewFileAgentInventory",
                "ObjectMedia",
                "ObjectMediaNavigate",
                "ObjectNavMeshProperties",
                "ParcelPropertiesUpdate",
                "ParcelVoiceInfoRequest",
                "ProductInfoRequest",
                "ProvisionVoiceAccountRequest",
                "ReadOfflineMsgs",
                "RemoteParcelRequest",
                "RenderMaterials",
                "RequestTextureDownload",
                "ResourceCostSelected",
                "RetrieveNavMeshSrc",
                "SearchStatRequest",
                "SearchStatTracking",
                "SendPostcard",
                "SendUserReport",
                "SendUserReportWithScreenshot",
                "ServerReleaseNotes",
                "SetDisplayName",
                "SimConsoleAsync",
                "SimulatorFeatures",
                "StartGroupProposal",
                "TerrainNavMeshProperties",
                "TextureStats",
                "UntrustedSimulatorMessage",
                "UpdateAgentInformation",
                "UpdateAgentLanguage",
                "UpdateAvatarAppearance",
                "UpdateGestureAgentInventory",
                "UpdateGestureTaskInventory",
                "UpdateNotecardAgentInventory",
                "UpdateNotecardTaskInventory",
                "UpdateScriptAgent",
                "UpdateScriptTask",
                "UploadBakedTexture",
                "UserInfo",
                "ViewerAsset",
                "ViewerBenefits",
                "ViewerMetrics",
                "ViewerStartAuction",
                "ViewerStats",
                // AIS3
                "InventoryAPIv3",
                "LibraryAPIv3"
            };

            _SeedRequest             = new CapsClient(new Uri(_SeedCapsURI), "SeedCaps");
            _SeedRequest.OnComplete += SeedRequestCompleteHandler;
            _SeedRequest.PostRequestAsync(req, OSDFormat.Xml, Simulator.Client.Settings.CAPS_TIMEOUT);
        }