Exemplo n.º 1
0
        public void Save(string filename)
        {
            IniConfigSource source = new IniConfigSource();

            // General
            IConfig config = source.AddConfig("General");
            config.Set("Version", configVersion.ToString(CultureInfo.CurrentCulture));
            //config.Set("iRadar", iradar.ToString());
            config.Set("Connect4", connect4.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableNotifications", disablenotifications.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableInboundGroupInvites", disableinboundgroupinvites.ToString(CultureInfo.CurrentCulture));
            config.Set("AutoSit", autosit.ToString(CultureInfo.CurrentCulture));
            config.Set("RadarRange", radarrange.ToString(CultureInfo.CurrentCulture));
            config.Set("ObjectRange", objectrange.ToString(CultureInfo.CurrentCulture));
            config.Set("GroupManPro", groupmanpro);
            config.Set("GivePresent", givepressie.ToString(CultureInfo.CurrentCulture));
            config.Set("HideMeta", metahide.ToString(CultureInfo.CurrentCulture));
            config.Set("DeclineInv", declineinv.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableLookAt", disablelookat);
            config.Set("AutoRestart", autorestart.ToString(CultureInfo.CurrentCulture));
            config.Set("LogOffTime", logofftime.ToString(CultureInfo.CurrentCulture));
            config.Set("ReStartTime", restarttime.ToString(CultureInfo.CurrentCulture));
            config.Set("BandwidthThrottle", bandwidththrottle.ToString(CultureInfo.CurrentCulture));
            config.Set("ClassicChatLayout", useclassicchatlayout.ToString(CultureInfo.CurrentCulture));
            config.Set("HideDisconnectPrompt", hidedisconnectprompt.ToString(CultureInfo.CurrentCulture));

            if (headerfont == null)
            {
                headerfont = "Tahoma";
                headerfontstyle = "Regular";
                headerfontsize = 8.5f;
                headerbackcolour = Color.Lavender.ToArgb();
            }

            config.Set("HeaderFont", headerfont);
            config.Set("HeaderFontStyle", headerfontstyle);
            config.Set("HeaderFontSize", headerfontsize.ToString(CultureInfo.CurrentCulture));
            config.Set("HeaderBackColour", headerbackcolour.ToString(CultureInfo.CurrentCulture));
            //config.Set("BgColour", bgcolour.ToString());

            if (textfont == null)
            {
                textfont = "Tahoma";
                textfontstyle = "Regular";
                textfontsize = 8.5f;
            }

            config.Set("TextFont", textfont);
            config.Set("TextFontStyle", textfontstyle);
            config.Set("TextFontSize", textfontsize.ToString(CultureInfo.CurrentCulture));
            config.Set("PlayFriendOnline", playfriendonline.ToString(CultureInfo.CurrentCulture));
            config.Set("PlayFriendOffline", playfriendoffline.ToString(CultureInfo.CurrentCulture));
            config.Set("PlayIMreceived", playimreceived.ToString(CultureInfo.CurrentCulture));
            config.Set("PlayGroupIMreceived", playgroupimreceived.ToString(CultureInfo.CurrentCulture));
            config.Set("PlayGroupNoticeReceived", playgroupnotice.ToString(CultureInfo.CurrentCulture));
            config.Set("PlayInventoryItemReceived", playintentoryitem.ToString(CultureInfo.CurrentCulture));
            config.Set("PlayPaymentReceived", playpaymentreceived.ToString(CultureInfo.CurrentCulture));
            config.Set("AutoAcceptItems", autoacceptitems.ToString(CultureInfo.CurrentCulture));
            config.Set("StartMinimised", startminimised.ToString(CultureInfo.CurrentCulture));
            config.Set("AdRemove", adremove);
            config.Set("MasterAvatar", masteravatar);
            config.Set("MasterObject", masterobject);
            config.Set("EnforceLSLsecurity", enforcelslsecurity.ToString(CultureInfo.CurrentCulture));
            config.Set("DisplayLSLcommands", displaylslcommands.ToString(CultureInfo.CurrentCulture));
            config.Set("AutoTransfer", autotransfer.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableTrayIcon", disabletrayicon.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableFriendsNotifications", disablefriendsnotifications.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableTyping", disabletyping.ToString(CultureInfo.CurrentCulture));
            config.Set("AutoAcceptFriends", autoacceptfriends.ToString(CultureInfo.CurrentCulture));
            //config.Set("BroadcastID", broadcastid.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableRadar", disableradar.ToString(CultureInfo.CurrentCulture));
            config.Set("RestrictRadar", restrictradar.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableVoice", disablevoice.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableFavs", disablefavs.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableHTTPinv", disablehttpinv.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableRadarImageMiniMap", disableradarminimap.ToString(CultureInfo.CurrentCulture));
            config.Set("AppMenuPos", appmenupos.ToString(CultureInfo.CurrentCulture));
            config.Set("LandMenuPos", landmenupos.ToString(CultureInfo.CurrentCulture));
            config.Set("FnMenuPos", fnmenupos.ToString(CultureInfo.CurrentCulture));
            config.Set("UseLLSD", usellsd.ToString(CultureInfo.CurrentCulture));

            config.Set("ChatBufferLimit", chatbufferlimit.ToString(CultureInfo.CurrentCulture));
            config.Set("ScriptUrlBufferLimit", scripturlbufferlimit.ToString(CultureInfo.CurrentCulture));

            // Interface
            config = source.AddConfig("Interface");
            config.Set("MainWindowState", mainWindowState.ToString(CultureInfo.CurrentCulture));
            config.Set("Style", interfaceStyle.ToString(CultureInfo.CurrentCulture));

            // Login
            config = source.AddConfig("Login");
            config.Set("FirstName", firstName);
            config.Set("LastName", lastName);

            if (irempwd)
            {
                string epwd = passwordMD5;

                if (!string.IsNullOrEmpty(epwd))
                {
                    Crypto cryp = new Crypto(Crypto.SymmProvEnum.Rijndael);
                    //string cpwd = cryp.Encrypting(epwd);
                    string cpwd = cryp.Encrypt(epwd);

                    config.Set("Password", cpwd);
                }
            }
            else
            {
                config.Set("Password", string.Empty);
            }

            config.Set("UserNameList", usernamelist);
            config.Set("Grid", loginGrid.ToString(CultureInfo.CurrentCulture));
            config.Set("Uri", loginUri);
            config.Set("LocationType", loginLocationType.ToString(CultureInfo.CurrentCulture));
            config.Set("Location", loginLocation);
            config.Set("iRemPWD", irempwd.ToString(CultureInfo.CurrentCulture));

            // AI
            config = source.AddConfig("AI");
            config.Set("AIon", aion.ToString(CultureInfo.CurrentCulture));
            config.Set("ReplyAI", replyAI.ToString(CultureInfo.CurrentCulture));
            config.Set("ReplyText", replyText);
            config.Set("MultiLingualAI", multilingualai.ToString(CultureInfo.CurrentCulture));

            // Text
            config = source.AddConfig("Text");
            config.Set("ChatTimestamps", chatTimestamps.ToString(CultureInfo.CurrentCulture));
            config.Set("IMTimestamps", imTimestamps.ToString(CultureInfo.CurrentCulture));
            config.Set("ChatSmileys", chatSmileys.ToString(CultureInfo.CurrentCulture));
            config.Set("ParcelMusic", parcelmusic.ToString(CultureInfo.CurrentCulture));
            config.Set("ParcelMedia", parcelmedia.ToString(CultureInfo.CurrentCulture));
            config.Set("lineMax", linemax.ToString(CultureInfo.CurrentCulture));
            config.Set("UseSLT", useslt.ToString(CultureInfo.CurrentCulture));
            config.Set("PlaySound", playsound.ToString(CultureInfo.CurrentCulture));
            config.Set("BusyReply", busyreply);
            config.Set("InitialIMReply", initialIMreply);
            config.Set("SaveIMs", saveims.ToString(CultureInfo.CurrentCulture));
            config.Set("SaveChat", savechat.ToString(CultureInfo.CurrentCulture));
            config.Set("LogDir", logdir);
            config.Set("DisableGroupNotices", disablegnotices.ToString(CultureInfo.CurrentCulture));
            config.Set("DisableGroupIMs", disablegims.ToString(CultureInfo.CurrentCulture));

            //// Twitter
            //config = source.AddConfig("Twitter");
            //config.Set("TweeterName", tweetername);
            //config.Set("TweeterPwd", tweeterpwd);
            //config.Set("EnableTweeter", enabletweeter.ToString());
            //config.Set("EnableChatTweets", enablechattweets.ToString());
            //config.Set("Tweet", tweet.ToString());
            //config.Set("TweeterUser", tweetuser);

            // Proxy
            config = source.AddConfig("Proxy");
            config.Set("UseProxy", useproxy.ToString(CultureInfo.CurrentCulture));
            config.Set("ProxyURL", proxyurl);
            config.Set("ProxyPort", proxyport);
            config.Set("ProxyUser", proxyuser);
            config.Set("ProxyPWD", proxypwd);

            // META3D
            config = source.AddConfig("META3D");
            config.Set("DisableMipmaps", disablemipmaps.ToString(CultureInfo.CurrentCulture));

            // Plugins Loaded
            config = source.AddConfig("LoadedPlugIns");
            config.Set("PluginsToLoad", pluginstoload);

            // Plugins
            //added by GM on 2-JUL-2009
            config = source.AddConfig("PlugIn");
            //don't save if default
            if (groupManagerUid != "ned49b54-325d-486a-af3m")
            {
                config.Set("GroupManager", groupManagerUid);
            }
            config.Set("ChairAnnouncer", chairAnnouncerUuid.ToString());
            config.Set("ChairAnnouncerInterval", chairAnnouncerInterval);
            config.Set("ChairAnnouncerGroup1", chairAnnouncerGroup1.ToString());
            config.Set("ChairAnnouncerGroup2", chairAnnouncerGroup2.ToString());
            config.Set("ChairAnnouncerGroup3", chairAnnouncerGroup3.ToString());
            config.Set("ChairAnnouncerGroup4", chairAnnouncerGroup4.ToString());
            config.Set("ChairAnnouncerGroup5", chairAnnouncerGroup5.ToString());
            config.Set("ChairAnnouncerGroup6", chairAnnouncerGroup6.ToString());
            config.Set("ChairAnnouncerEnabled", chairAnnouncerEnabled);
            config.Set("ChairAnnouncerChat", chairAnnouncerChat);
            //added by GM on 1-APR-2009
            config.Set("ChairAnnouncerAdvert", chairAnnouncerAdvert);

            config = source.AddConfig("Spelling");
            config.Set("EnableSpelling", enablespellcheck.ToString(CultureInfo.CurrentCulture));
            config.Set("SpellLanguage", spelllang);

            FileInfo newFileInfo = new FileInfo(Path.Combine(METAbolt.DataFolder.GetDataFolder(), filename));

            if (newFileInfo.Exists)
            {
                if (newFileInfo.IsReadOnly)
                {
                    newFileInfo.IsReadOnly = false;
                }
            }

            source.Save(filename);
        }
Exemplo n.º 2
0
        private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e)
        {
            try
            {
                switch (e.Status)
                {
                    case LoginStatus.ConnectingToLogin:
                        lblLoginStatus.Text = "Connecting to login server...";
                        lblLoginStatus.ForeColor = Color.Black;
                        break;

                    case LoginStatus.ConnectingToSim:
                        lblLoginStatus.Text = "Connecting to region...";
                        lblLoginStatus.ForeColor = Color.Black;
                        break;

                    case LoginStatus.Redirecting:
                        lblLoginStatus.Text = "Redirecting...";
                        lblLoginStatus.ForeColor = Color.Black;
                        break;

                    case LoginStatus.ReadingResponse:
                        lblLoginStatus.Text = "Reading response...";
                        lblLoginStatus.ForeColor = Color.Black;
                        break;

                    case LoginStatus.Success:
                        //SetLang();

                        lblLoginStatus.Text = "Logged in as " + netcom.LoginOptions.FullName;
                        lblLoginStatus.ForeColor = Color.Blue;

                        string uname = client.Self.Name + "\\";

                        Wildcard wildcard = new Wildcard(client.Self.Name + "*", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                        List<string> torem = new List<string>();

                        foreach (string s in usernlist)
                        {
                            if(wildcard.IsMatch(s))
                            {
                                torem.Add(s);
                            }
                        }

                        foreach (string s in torem)
                        {
                            if (wildcard.IsMatch(s))
                            {
                                usernlist.Remove(s);
                            }
                        }

                        //string epwd1 = txtPassword.Text;

                        if (chkPWD.Checked)
                        {
                            string epwd = txtPassword.Text;
                            Crypto cryp = new Crypto(Crypto.SymmProvEnum.Rijndael);
                            string cpwd = cryp.Encrypt(epwd);

                            uname += cpwd;
                        }

                        usernlist.Add(uname);

                        btnLogin.Text = "Exit";
                        btnLogin.Enabled = true;

                        instance.ReBooted = false;
                        timer2.Enabled = false;
                        timer2.Stop();

                        try
                        {
                            SaveUserSettings();

                            string fname = client.Self.FirstName + "_" + client.Self.LastName;

                            if (chkCmd.Checked)
                            {
                                // create the CMD file
                                CreateCmdFile();

                                FileInfo newFileInfo = new FileInfo(Path.Combine(METAbolt.DataFolder.GetDataFolder(), fname + "_METAbolt.ini"));

                                if (!newFileInfo.Exists)
                                {
                                    string pth = Path.Combine(METAbolt.DataFolder.GetDataFolder(), fname + "_METAbolt.ini");
                                    instance.Config.CurrentConfig.Save(pth);
                                }
                            }

                            //instance.Config.ChangeConfigFile(fname);
                            this.instance.ReapplyConfig(fname);

                            if (instance.Config.CurrentConfig.AIon)
                            {
                                instance.InitAI();
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Log("Error trying to save user settings to METAbolt.ini ", Helpers.LogLevel.Warning, ex);
                        }

                        //LoadWebPage();

                        client.Self.Movement.Camera.Far = (float)instance.Config.CurrentConfig.RadarRange;

                        break;

                    case LoginStatus.Failed:
                        lblLoginStatus.Text = e.Message;
                        Logger.Log("Login Failed: " + e.FailReason, Helpers.LogLevel.Info);
                        lblLoginStatus.ForeColor = Color.Red;

                        //proLogin.Visible = false;

                        btnLogin.Text = "Retry";
                        btnLogin.Enabled = true;
                        break;
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Login (status): " + ex.Message, Helpers.LogLevel.Error);
            }
        }