Exemple #1
0
        public bool CheckName(string firstName, LastName lastName)
        {
            if (Initializing)
            {
                throw new InvalidOperationException("still initializing");
            }

            if (_caps.CheckName == null)
            {
                throw new InvalidOperationException("access denied; only approved developers have access to the registration api");
            }

            // Create the POST data
            LLSDMap query = new LLSDMap();

            query.Add("username", LLSD.FromString(firstName));
            query.Add("last_name_id", LLSD.FromInteger(lastName.ID));
            byte[] postData = LLSDParser.SerializeXmlBytes(query);

            CapsClient request = new CapsClient(_caps.CheckName);

            request.OnComplete += new CapsClient.CompleteCallback(CheckNameResponse);
            request.StartRequest();

            // FIXME:
            return(false);
        }
Exemple #2
0
        public LLSD ToLLSD()
        {
            LLSDMap path = new LLSDMap(14);

            path["begin"]         = LLSD.FromReal(Data.PathBegin);
            path["curve"]         = LLSD.FromInteger((int)Data.PathCurve);
            path["end"]           = LLSD.FromReal(Data.PathEnd);
            path["radius_offset"] = LLSD.FromReal(Data.PathRadiusOffset);
            path["revolutions"]   = LLSD.FromReal(Data.PathRevolutions);
            path["scale_x"]       = LLSD.FromReal(Data.PathScaleX);
            path["scale_y"]       = LLSD.FromReal(Data.PathScaleY);
            path["shear_x"]       = LLSD.FromReal(Data.PathShearX);
            path["shear_y"]       = LLSD.FromReal(Data.PathShearY);
            path["skew"]          = LLSD.FromReal(Data.PathSkew);
            path["taper_x"]       = LLSD.FromReal(Data.PathTaperX);
            path["taper_y"]       = LLSD.FromReal(Data.PathTaperY);
            path["twist"]         = LLSD.FromReal(Data.PathTwist);
            path["twist_begin"]   = LLSD.FromReal(Data.PathTwistBegin);

            LLSDMap profile = new LLSDMap(4);

            profile["begin"]  = LLSD.FromReal(Data.ProfileBegin);
            profile["curve"]  = LLSD.FromInteger((int)Data.ProfileCurve);
            profile["hole"]   = LLSD.FromInteger((int)Data.ProfileHole);
            profile["end"]    = LLSD.FromReal(Data.ProfileEnd);
            profile["hollow"] = LLSD.FromReal(Data.ProfileHollow);

            LLSDMap volume = new LLSDMap(2);

            volume["path"]    = path;
            volume["profile"] = profile;

            LLSDMap prim = new LLSDMap(9);

            prim["name"]        = LLSD.FromString(Properties.Name);
            prim["description"] = LLSD.FromString(Properties.Description);
            prim["phantom"]     = LLSD.FromBoolean(((Flags & ObjectFlags.Phantom) != 0));
            prim["physical"]    = LLSD.FromBoolean(((Flags & ObjectFlags.Physics) != 0));
            prim["position"]    = Position.ToLLSD();
            prim["rotation"]    = Rotation.ToLLSD();
            prim["scale"]       = Scale.ToLLSD();
            prim["material"]    = LLSD.FromInteger((int)Data.Material);
            prim["shadows"]     = LLSD.FromBoolean(((Flags & ObjectFlags.CastShadows) != 0));
            prim["textures"]    = Textures.ToLLSD();
            prim["volume"]      = volume;
            if (ParentID != 0)
            {
                prim["parentid"] = LLSD.FromInteger(ParentID);
            }

            prim["light"]  = Light.ToLLSD();
            prim["flex"]   = Flexible.ToLLSD();
            prim["sculpt"] = Sculpt.ToLLSD();

            return(prim);
        }
Exemple #3
0
        /// <summary>
        /// Returns the new user ID or throws an exception containing the error code
        /// The error codes can be found here: https://wiki.secondlife.com/wiki/RegAPIError
        /// </summary>
        /// <param name="user">New user account to create</param>
        /// <returns>The UUID of the new user account</returns>
        public LLUUID CreateUser(CreateUserParam user)
        {
            if (Initializing)
            {
                throw new InvalidOperationException("still initializing");
            }

            if (_caps.CreateUser == null)
            {
                throw new InvalidOperationException("access denied; only approved developers have access to the registration api");
            }

            // Create the POST data
            LLSDMap query = new LLSDMap();

            query.Add("username", LLSD.FromString(user.FirstName));
            query.Add("last_name_id", LLSD.FromInteger(user.LastName.ID));
            query.Add("email", LLSD.FromString(user.Email));
            query.Add("password", LLSD.FromString(user.Password));
            query.Add("dob", LLSD.FromString(user.Birthdate.ToString("yyyy-MM-dd")));

            if (user.LimitedToEstate != null)
            {
                query.Add("limited_to_estate", LLSD.FromInteger(user.LimitedToEstate.Value));
            }

            if (!string.IsNullOrEmpty(user.StartRegionName))
            {
                query.Add("start_region_name", LLSD.FromInteger(user.LimitedToEstate.Value));
            }

            if (user.StartLocation != null)
            {
                query.Add("start_local_x", LLSD.FromReal(user.StartLocation.Value.X));
                query.Add("start_local_y", LLSD.FromReal(user.StartLocation.Value.Y));
                query.Add("start_local_z", LLSD.FromReal(user.StartLocation.Value.Z));
            }

            if (user.StartLookAt != null)
            {
                query.Add("start_look_at_x", LLSD.FromReal(user.StartLookAt.Value.X));
                query.Add("start_look_at_y", LLSD.FromReal(user.StartLookAt.Value.Y));
                query.Add("start_look_at_z", LLSD.FromReal(user.StartLookAt.Value.Z));
            }

            byte[] postData = LLSDParser.SerializeXmlBytes(query);

            // Make the request
            CapsClient request = new CapsClient(_caps.CreateUser);

            request.OnComplete += new CapsClient.CompleteCallback(CreateUserResponse);
            request.StartRequest();

            // FIXME: Block
            return(LLUUID.Zero);
        }
Exemple #4
0
        private void BeginLogin()
        {
            LoginParams loginParams = CurrentContext.Value;

            // Sanity check
            if (loginParams.Options == null)
            {
                loginParams.Options = new List <string>();
            }

            // Convert the password to MD5 if it isn't already
            if (loginParams.Password.Length != 35 && !loginParams.Password.StartsWith("$1$"))
            {
                loginParams.Password = Helpers.MD5(loginParams.Password);
            }

            // Override SSL authentication mechanisms. DO NOT convert this to the
            // .NET 2.0 preferred method, the equivalent function in Mono has a
            // different name and it will break compatibility!
            ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
            // TODO: At some point, maybe we should check the cert?

            // Create the CAPS login structure
            LLSDMap loginLLSD = new LLSDMap();

            loginLLSD["first"]         = LLSD.FromString(loginParams.FirstName);
            loginLLSD["last"]          = LLSD.FromString(loginParams.LastName);
            loginLLSD["passwd"]        = LLSD.FromString(loginParams.Password);
            loginLLSD["start"]         = LLSD.FromString(loginParams.Start);
            loginLLSD["channel"]       = LLSD.FromString(loginParams.Channel);
            loginLLSD["version"]       = LLSD.FromString(loginParams.Version);
            loginLLSD["platform"]      = LLSD.FromString(loginParams.Platform);
            loginLLSD["mac"]           = LLSD.FromString(loginParams.MAC);
            loginLLSD["agree_to_tos"]  = LLSD.FromBoolean(true);
            loginLLSD["read_critical"] = LLSD.FromBoolean(true);
            loginLLSD["viewer_digest"] = LLSD.FromString(loginParams.ViewerDigest);
            loginLLSD["id0"]           = LLSD.FromString(loginParams.id0);

            // Create the options LLSD array
            LLSDArray optionsLLSD = new LLSDArray();

            for (int i = 0; i < loginParams.Options.Count; i++)
            {
                optionsLLSD.Add(LLSD.FromString(loginParams.Options[i]));
            }
            foreach (string[] callbackOpts in CallbackOptions.Values)
            {
                if (callbackOpts != null)
                {
                    for (int i = 0; i < callbackOpts.Length; i++)
                    {
                        if (!optionsLLSD.Contains(callbackOpts[i]))
                        {
                            optionsLLSD.Add(callbackOpts[i]);
                        }
                    }
                }
            }
            loginLLSD["options"] = optionsLLSD;

            // Make the CAPS POST for login
            Uri loginUri;

            try
            {
                loginUri = new Uri(loginParams.URI);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Failed to parse login URI {0}, {1}", loginParams.URI, ex.Message),
                           Helpers.LogLevel.Error, Client);
                return;
            }

            CapsClient loginRequest = new CapsClient(new Uri(loginParams.URI));

            loginRequest.OnComplete += new CapsClient.CompleteCallback(LoginReplyHandler);
            loginRequest.UserData    = CurrentContext;
            loginRequest.StartRequest(LLSDParser.SerializeXmlBytes(loginLLSD), "application/xml+llsd");
        }