Esempio n. 1
0
        public RadegastNetcom(RadegastInstance instance)
        {
            this.instance = instance;
            loginOptions = new LoginOptions();

            instance.ClientChanged += new EventHandler<ClientChangedEventArgs>(instance_ClientChanged);
            RegisterClientEvents(client);
        }
Esempio n. 2
0
        public void Login()
        {
            IsLoggingIn = true;

            // Report crashes only once and not on relogs/reconnects
            LastExecStatus execStatus = instance.GetLastExecStatus();

            if (!instance.AnotherInstanceRunning() && execStatus != LastExecStatus.Normal && (!instance.ReportedCrash))
            {
                instance.ReportedCrash     = true;
                loginOptions.LastExecEvent = execStatus;
                Logger.Log("Reporting crash of the last application run to the grid login service", Helpers.LogLevel.Warning);
            }
            else
            {
                loginOptions.LastExecEvent = LastExecStatus.Normal;
                Logger.Log("Reporting normal shutdown of the last application run to the grid login service", Helpers.LogLevel.Info);
            }
            instance.MarkStartExecution();

            OverrideEventArgs ea = new OverrideEventArgs();

            OnClientLoggingIn(ea);

            if (ea.Cancel)
            {
                IsLoggingIn = false;
                return;
            }

            if (string.IsNullOrEmpty(loginOptions.FirstName) ||
                string.IsNullOrEmpty(loginOptions.LastName) ||
                string.IsNullOrEmpty(loginOptions.Password))
            {
                OnClientLoginStatus(
                    new LoginProgressEventArgs(LoginStatus.Failed, "One or more fields are blank.", string.Empty));
            }

            string startLocation = string.Empty;

            switch (loginOptions.StartLocation)
            {
            case StartLocationType.Home: startLocation = "home"; break;

            case StartLocationType.Last: startLocation = "last"; break;

            case StartLocationType.Custom:
                startLocation = loginOptions.StartLocationCustom.Trim();

                StartLocationParser parser = new StartLocationParser(startLocation);
                startLocation = NetworkManager.StartLocation(parser.Sim, parser.X, parser.Y, parser.Z);

                break;
            }

            string password;

            if (LoginOptions.IsPasswordMD5(loginOptions.Password))
            {
                password = loginOptions.Password;
            }
            else
            {
                if (loginOptions.Password.Length > 16)
                {
                    password = Utils.MD5(loginOptions.Password.Substring(0, 16));
                }
                else
                {
                    password = Utils.MD5(loginOptions.Password);
                }
            }

            LoginParams loginParams = client.Network.DefaultLoginParams(
                loginOptions.FirstName, loginOptions.LastName, password,
                loginOptions.Channel, loginOptions.Version);

            Grid = loginOptions.Grid;
            loginParams.Start         = startLocation;
            loginParams.AgreeToTos    = AgreeToTos;
            loginParams.URI           = Grid.LoginURI;
            loginParams.LastExecEvent = loginOptions.LastExecEvent;
            client.Network.BeginLogin(loginParams);
        }
Esempio n. 3
0
        static public void SetRadegastLoginForm(RadegastInstance instance, LoginConsole console, LoginOptions options)
        {
            // var instance = TheRadegastInstance;
            if (console.IsDisposed) return;
            console.cbxUsername.Text = (String.Format("{0} {1}", options.FirstName, options.LastName)).Trim();

            switch (options.StartLocation)
            {
                case StartLocationType.Last:
                    //console.cbxLocation.Text = options.StartLocationCustom = "last";
                    console.cbxLocation.SelectedIndex = 1;
                    break;
                case StartLocationType.Home:
                    //console.cbxLocation.Text = options.StartLocationCustom = "home";
                    console.cbxLocation.SelectedIndex = 0;
                    break;
                default:
                    console.cbxLocation.SelectedIndex = -1;
                    console.cbxLocation.Text = options.StartLocationCustom;
                    break;
            }
            console.cbTOS.Checked = true;
            var G = options.Grid;
            string gridName = options.GridCustomLoginUri;
            int gridIx = -1;
            String LoginURI = null;
            G = GetGridIndex(instance, gridName, out gridIx) ?? G;
            if (gridIx == -1)
            {
                if (G != null && !String.IsNullOrEmpty(G.ID))
                {
                    LoginURI = G.LoginURI;
                    if (LoginURI != null) console.txtCustomLoginUri.Text = LoginURI;
                    console.cbxGrid.Text = G.Name ?? G.ID;
                    instance.Netcom.LoginOptions.Grid = G;
                }
                else { console.cbxGrid.Text = "Custom"; }
                if (LoginURI == null) console.txtCustomLoginUri.Text = options.GridCustomLoginUri;
            }
            else
            {
                console.txtCustomLoginUri.Text = G.LoginURI;
                console.cbxGrid.SelectedIndex = gridIx;
            }
        }