OSDN Git Service

Added URI settings and updated URI name resolution. 18/head
authornooperation <madbrahmin@gmail.com>
Tue, 14 Jul 2015 21:16:28 +0000 (17:16 -0400)
committernooperation <madbrahmin@gmail.com>
Tue, 14 Jul 2015 21:16:28 +0000 (17:16 -0400)
* Modified preferences GUI to align a couple overlapping controls and
add elements for enabling URI resolution and specifying a URI resolution
timeout.
* Changed the default URI name resolution rule to follow the user
specified naming mode.

Radegast/Core/SlUriParser.cs
Radegast/GUI/Dialogs/Settings.Designer.cs
Radegast/GUI/Dialogs/Settings.cs

index 0f6ffab..425c9e3 100644 (file)
@@ -11,9 +11,9 @@ namespace Radegast
         private enum ResolveType
         {
             /// <summary>
-            /// Display (first.last)
+            /// Client specified name format
             /// </summary>
-            AgentCompleteName,
+            AgentDefaultName,
             /// <summary>
             /// Display
             /// </summary>
@@ -79,6 +79,11 @@ namespace Radegast
         /// <returns>Display text for URI</returns>
         public string GetLinkName(string uri)
         {
+            if (!RadegastInstance.GlobalInstance.GlobalSettings["resolve_uris"])
+            {
+                return uri;
+            }
+
             Match match = patternUri.Match(uri);
             if (!match.Success)
             {
@@ -230,11 +235,6 @@ namespace Radegast
         #region Name Resolution
 
         /// <summary>
-        /// Amount of time in milliseconds to wait before giving up on name resolution
-        /// </summary>
-        private const int NameResolveTimeoutInMs = 150;
-
-        /// <summary>
         /// Gets the name of an agent by UUID. Will block for a short period of time to allow for name resolution.
         /// </summary>
         /// <param name="agentID">Agent UUID</param>
@@ -262,9 +262,9 @@ namespace Radegast
 
                 instance.Names.NameUpdated += handler;
 
-                if (nameType == ResolveType.AgentCompleteName)
+                if (nameType == ResolveType.AgentDefaultName)
                 {
-                    name = instance.Names.GetLegacyName(agentID);
+                    name = instance.Names.Get(agentID);
                 }
                 else if (nameType == ResolveType.AgentUsername)
                 {
@@ -276,12 +276,13 @@ namespace Radegast
                 }
                 else
                 {
+                    instance.Names.NameUpdated -= handler;
                     return agentID.ToString();
                 }
 
                 if (name == RadegastInstance.INCOMPLETE_NAME)
                 {
-                    gotName.WaitOne(NameResolveTimeoutInMs, false);
+                    gotName.WaitOne(instance.GlobalSettings["resolve_uri_time"], false);
                 }
 
                 instance.Names.NameUpdated -= handler;
@@ -319,7 +320,7 @@ namespace Radegast
                 instance.Client.Groups.RequestGroupName(groupID);
                 if (name == RadegastInstance.INCOMPLETE_NAME)
                 {
-                    gotName.WaitOne(NameResolveTimeoutInMs, false);
+                    gotName.WaitOne(instance.GlobalSettings["resolve_uri_time"], false);
                 }
 
                 instance.Client.Groups.GroupNamesReply -= handler;
@@ -357,7 +358,7 @@ namespace Radegast
                 instance.Client.Parcels.RequestParcelInfo(parcelID);
                 if (name == RadegastInstance.INCOMPLETE_NAME)
                 {
-                    gotName.WaitOne(NameResolveTimeoutInMs, false);
+                    gotName.WaitOne(instance.GlobalSettings["resolve_uri_time"], false);
                 }
 
                 instance.Client.Parcels.ParcelInfoReply -= handler;
@@ -377,7 +378,7 @@ namespace Radegast
         {
             switch (type)
             {
-                case ResolveType.AgentCompleteName:
+                case ResolveType.AgentDefaultName:
                 case ResolveType.AgentDisplayName:
                 case ResolveType.AgentUsername:
                     return GetAgentName(id, type);
@@ -427,23 +428,23 @@ namespace Radegast
                 case "about":
                 case "inspect":
                 case "completename":
-                    return Resolve(agentID, ResolveType.AgentCompleteName);
+                    return Resolve(agentID, ResolveType.AgentDefaultName);
                 case "displayname":
                     return Resolve(agentID, ResolveType.AgentDisplayName);
                 case "username":
                     return Resolve(agentID, ResolveType.AgentUsername);
                 case "im":
-                    return "IM " + Resolve(agentID, ResolveType.AgentCompleteName);
+                    return "IM " + Resolve(agentID, ResolveType.AgentDefaultName);
                 case "offerteleport":
-                    return "Offer Teleport to " + Resolve(agentID, ResolveType.AgentCompleteName);
+                    return "Offer Teleport to " + Resolve(agentID, ResolveType.AgentDefaultName);
                 case "pay":
-                    return "Pay " + Resolve(agentID, ResolveType.AgentCompleteName);
+                    return "Pay " + Resolve(agentID, ResolveType.AgentDefaultName);
                 case "requestfriend":
-                    return "Friend Request " + Resolve(agentID, ResolveType.AgentCompleteName);
+                    return "Friend Request " + Resolve(agentID, ResolveType.AgentDefaultName);
                 case "mute":
-                    return "Mute " + Resolve(agentID, ResolveType.AgentCompleteName);
+                    return "Mute " + Resolve(agentID, ResolveType.AgentDefaultName);
                 case "unmute":
-                    return "Unmute " + Resolve(agentID, ResolveType.AgentCompleteName);
+                    return "Unmute " + Resolve(agentID, ResolveType.AgentDefaultName);
                 default:
                     return match.ToString();
             }
index 6c43e3f..d44c12d 100644 (file)
@@ -68,6 +68,9 @@ namespace Radegast
             this.cbFriendsHighlight = new System.Windows.Forms.CheckBox();
             this.cbTaskBarHighLight = new System.Windows.Forms.CheckBox();
             this.cbMisc = new System.Windows.Forms.GroupBox();
+            this.txtResolveURITime = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.cbResolveURIs = new System.Windows.Forms.CheckBox();
             this.cbShowScriptErrors = new System.Windows.Forms.CheckBox();
             this.cbDisableHTTPInventory = new System.Windows.Forms.CheckBox();
             this.cbHideLoginGraphics = new System.Windows.Forms.CheckBox();
@@ -98,6 +101,8 @@ namespace Radegast
             this.rbDNSmart = new System.Windows.Forms.RadioButton();
             this.rbDNOff = new System.Windows.Forms.RadioButton();
             this.tbpAutoResponse = new System.Windows.Forms.TabPage();
+            this.gnAutoScriptPermission = new System.Windows.Forms.GroupBox();
+            this.cbAutoScriptPermission = new System.Windows.Forms.ComboBox();
             this.gnAutoInventory = new System.Windows.Forms.GroupBox();
             this.cbOnInvOffer = new System.Windows.Forms.ComboBox();
             this.txtAutoResponse = new System.Windows.Forms.TextBox();
@@ -129,8 +134,6 @@ namespace Radegast
             this.autoSitUUID = new System.Windows.Forms.TextBox();
             this.autoSitName = new System.Windows.Forms.TextBox();
             this.autoSitNameLabel = new System.Windows.Forms.Label();
-            this.gnAutoScriptPermission = new System.Windows.Forms.GroupBox();
-            this.cbAutoScriptPermission = new System.Windows.Forms.ComboBox();
             this.tcGraphics.SuspendLayout();
             this.tbpGeneral.SuspendLayout();
             this.cbHighLight.SuspendLayout();
@@ -138,6 +141,7 @@ namespace Radegast
             this.Chat.SuspendLayout();
             this.gbDisplayNames.SuspendLayout();
             this.tbpAutoResponse.SuspendLayout();
+            this.gnAutoScriptPermission.SuspendLayout();
             this.gnAutoInventory.SuspendLayout();
             this.gbAutoResponse.SuspendLayout();
             this.tbpBot.SuspendLayout();
@@ -145,7 +149,6 @@ namespace Radegast
             this.pseudoHome.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pseudoHomeTolerance)).BeginInit();
             this.autoSit.SuspendLayout();
-            this.gnAutoScriptPermission.SuspendLayout();
             this.SuspendLayout();
             // 
             // tcGraphics
@@ -243,6 +246,9 @@ namespace Radegast
             // 
             // cbMisc
             // 
+            this.cbMisc.Controls.Add(this.txtResolveURITime);
+            this.cbMisc.Controls.Add(this.label4);
+            this.cbMisc.Controls.Add(this.cbResolveURIs);
             this.cbMisc.Controls.Add(this.cbShowScriptErrors);
             this.cbMisc.Controls.Add(this.cbDisableHTTPInventory);
             this.cbMisc.Controls.Add(this.cbHideLoginGraphics);
@@ -260,10 +266,39 @@ namespace Radegast
             this.cbMisc.Controls.Add(this.cbSyntaxHighlight);
             this.cbMisc.Location = new System.Drawing.Point(270, 6);
             this.cbMisc.Name = "cbMisc";
-            this.cbMisc.Size = new System.Drawing.Size(236, 310);
+            this.cbMisc.Size = new System.Drawing.Size(236, 345);
             this.cbMisc.TabIndex = 2;
             this.cbMisc.TabStop = false;
             // 
+            // txtResolveURITime
+            // 
+            this.txtResolveURITime.Location = new System.Drawing.Point(138, 318);
+            this.txtResolveURITime.Name = "txtResolveURITime";
+            this.txtResolveURITime.Size = new System.Drawing.Size(53, 20);
+            this.txtResolveURITime.TabIndex = 20;
+            this.txtResolveURITime.Text = "100";
+            this.txtResolveURITime.TextChanged += new System.EventHandler(this.txtResolveURITime_TextChanged);
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(23, 321);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(109, 13);
+            this.label4.TabIndex = 19;
+            this.label4.Text = "Resolve Timeout (ms)";
+            // 
+            // cbResolveURIs
+            // 
+            this.cbResolveURIs.AutoSize = true;
+            this.cbResolveURIs.Location = new System.Drawing.Point(6, 304);
+            this.cbResolveURIs.Name = "cbResolveURIs";
+            this.cbResolveURIs.Size = new System.Drawing.Size(92, 17);
+            this.cbResolveURIs.TabIndex = 18;
+            this.cbResolveURIs.Text = "Resolve URIs";
+            this.cbResolveURIs.UseVisualStyleBackColor = true;
+            this.cbResolveURIs.CheckedChanged += new System.EventHandler(this.cbResolveURIs_CheckedChanged);
+            // 
             // cbShowScriptErrors
             // 
             this.cbShowScriptErrors.AutoSize = true;
@@ -351,7 +386,7 @@ namespace Radegast
             // 
             // txtReconnectTime
             // 
-            this.txtReconnectTime.Location = new System.Drawing.Point(151, 96);
+            this.txtReconnectTime.Location = new System.Drawing.Point(157, 88);
             this.txtReconnectTime.Name = "txtReconnectTime";
             this.txtReconnectTime.Size = new System.Drawing.Size(53, 20);
             this.txtReconnectTime.TabIndex = 8;
@@ -372,7 +407,7 @@ namespace Radegast
             // label2
             // 
             this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(22, 91);
+            this.label2.Location = new System.Drawing.Point(23, 91);
             this.label2.Name = "label2";
             this.label2.Size = new System.Drawing.Size(128, 13);
             this.label2.TabIndex = 7;
@@ -511,7 +546,7 @@ namespace Radegast
             "14",
             "16",
             "20"});
-            this.cbFontSize.Location = new System.Drawing.Point(97, 51);
+            this.cbFontSize.Location = new System.Drawing.Point(104, 53);
             this.cbFontSize.Name = "cbFontSize";
             this.cbFontSize.Size = new System.Drawing.Size(54, 21);
             this.cbFontSize.TabIndex = 3;
@@ -523,7 +558,7 @@ namespace Radegast
             // label1
             // 
             this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(24, 54);
+            this.label1.Location = new System.Drawing.Point(26, 56);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(73, 13);
             this.label1.TabIndex = 2;
@@ -604,6 +639,30 @@ namespace Radegast
             this.tbpAutoResponse.Text = "Auto Response";
             this.tbpAutoResponse.UseVisualStyleBackColor = true;
             // 
+            // gnAutoScriptPermission
+            // 
+            this.gnAutoScriptPermission.Controls.Add(this.cbAutoScriptPermission);
+            this.gnAutoScriptPermission.Location = new System.Drawing.Point(9, 216);
+            this.gnAutoScriptPermission.Name = "gnAutoScriptPermission";
+            this.gnAutoScriptPermission.Size = new System.Drawing.Size(281, 54);
+            this.gnAutoScriptPermission.TabIndex = 3;
+            this.gnAutoScriptPermission.TabStop = false;
+            this.gnAutoScriptPermission.Text = "On script permission questions";
+            // 
+            // cbAutoScriptPermission
+            // 
+            this.cbAutoScriptPermission.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.cbAutoScriptPermission.FormattingEnabled = true;
+            this.cbAutoScriptPermission.Items.AddRange(new object[] {
+            "Ask",
+            "Auto Accept",
+            "Auto Decline"});
+            this.cbAutoScriptPermission.Location = new System.Drawing.Point(6, 19);
+            this.cbAutoScriptPermission.Name = "cbAutoScriptPermission";
+            this.cbAutoScriptPermission.Size = new System.Drawing.Size(121, 21);
+            this.cbAutoScriptPermission.TabIndex = 0;
+            this.cbAutoScriptPermission.SelectedIndexChanged += new System.EventHandler(this.cbAutoScriptPermission_SelectedIndexChanged);
+            // 
             // gnAutoInventory
             // 
             this.gnAutoInventory.Controls.Add(this.cbOnInvOffer);
@@ -950,30 +1009,6 @@ namespace Radegast
             this.autoSitNameLabel.Text = "Name";
             this.autoSitNameLabel.Click += new System.EventHandler(this.autoSitNameLabel_Click);
             // 
-            // gnAutoScriptPermission
-            // 
-            this.gnAutoScriptPermission.Controls.Add(this.cbAutoScriptPermission);
-            this.gnAutoScriptPermission.Location = new System.Drawing.Point(9, 216);
-            this.gnAutoScriptPermission.Name = "gnAutoScriptPermission";
-            this.gnAutoScriptPermission.Size = new System.Drawing.Size(281, 54);
-            this.gnAutoScriptPermission.TabIndex = 3;
-            this.gnAutoScriptPermission.TabStop = false;
-            this.gnAutoScriptPermission.Text = "On script permission questions";
-            // 
-            // cbAutoScriptPermission
-            // 
-            this.cbAutoScriptPermission.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.cbAutoScriptPermission.FormattingEnabled = true;
-            this.cbAutoScriptPermission.Items.AddRange(new object[] {
-            "Ask",
-            "Auto Accept",
-            "Auto Decline"});
-            this.cbAutoScriptPermission.Location = new System.Drawing.Point(6, 19);
-            this.cbAutoScriptPermission.Name = "cbAutoScriptPermission";
-            this.cbAutoScriptPermission.Size = new System.Drawing.Size(121, 21);
-            this.cbAutoScriptPermission.TabIndex = 0;
-            this.cbAutoScriptPermission.SelectedIndexChanged += new System.EventHandler(this.cbAutoScriptPermission_SelectedIndexChanged);
-            // 
             // frmSettings
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -995,6 +1030,7 @@ namespace Radegast
             this.gbDisplayNames.PerformLayout();
             this.tbpAutoResponse.ResumeLayout(false);
             this.tbpAutoResponse.PerformLayout();
+            this.gnAutoScriptPermission.ResumeLayout(false);
             this.gnAutoInventory.ResumeLayout(false);
             this.gbAutoResponse.ResumeLayout(false);
             this.gbAutoResponse.PerformLayout();
@@ -1006,7 +1042,6 @@ namespace Radegast
             ((System.ComponentModel.ISupportInitialize)(this.pseudoHomeTolerance)).EndInit();
             this.autoSit.ResumeLayout(false);
             this.autoSit.PerformLayout();
-            this.gnAutoScriptPermission.ResumeLayout(false);
             this.ResumeLayout(false);
 
         }
@@ -1085,6 +1120,9 @@ namespace Radegast
         public System.Windows.Forms.CheckBox cbShowScriptErrors;
         public System.Windows.Forms.GroupBox gnAutoScriptPermission;
         public System.Windows.Forms.ComboBox cbAutoScriptPermission;
+        public System.Windows.Forms.TextBox txtResolveURITime;
+        public System.Windows.Forms.Label label4;
+        public System.Windows.Forms.CheckBox cbResolveURIs;
 
 
     }
index b92ac2d..11ca7b0 100644 (file)
@@ -101,6 +101,10 @@ namespace Radegast
 
             if (!s.ContainsKey("reconnect_time")) s["reconnect_time"] = 120;
 
+            if (!s.ContainsKey("resolve_uri_time")) s["resolve_uri_time"] = 100;
+
+            if (!s.ContainsKey("resolve_uris")) s["resolve_uris"] = true;
+
             if (!s.ContainsKey("transaction_notification_chat")) s["transaction_notification_chat"] = true;
 
             if (!s.ContainsKey("transaction_notification_dialog")) s["transaction_notification_dialog"] = true;
@@ -172,6 +176,9 @@ namespace Radegast
             cbAutoReconnect.Checked = s["auto_reconnect"].AsBoolean();
             cbAutoReconnect.CheckedChanged += new EventHandler(cbAutoReconnect_CheckedChanged);
 
+            cbResolveURIs.Checked = s["resolve_uris"].AsBoolean();
+            cbResolveURIs.CheckedChanged += new EventHandler(cbResolveURIs_CheckedChanged); ;
+
             cbHideLoginGraphics.Checked = s["hide_login_graphics"].AsBoolean();
             cbHideLoginGraphics.CheckedChanged += new EventHandler(cbHideLoginGraphics_CheckedChanged);
 
@@ -237,6 +244,8 @@ namespace Radegast
 
             txtReconnectTime.Text = s["reconnect_time"].AsInteger().ToString();
 
+            txtResolveURITime.Text = s["resolve_uri_time"].AsInteger().ToString();
+
             cbRadegastClientTag.Checked = s["send_rad_client_tag"];
             cbRadegastClientTag.CheckedChanged += (sender, e) =>
             {
@@ -352,6 +361,11 @@ namespace Radegast
             s["auto_reconnect"] = OSD.FromBoolean(cbAutoReconnect.Checked);
         }
 
+        private void cbResolveURIs_CheckedChanged(object sender, EventArgs e)
+        {
+            s["resolve_uris"] = OSD.FromBoolean(cbResolveURIs.Checked);
+        }
+
         void cbFriendsNotifications_CheckedChanged(object sender, EventArgs e)
         {
             s["show_friends_online_notifications"] = OSD.FromBoolean(cbFriendsNotifications.Checked);
@@ -478,6 +492,21 @@ namespace Radegast
             s["reconnect_time"] = t;
         }
 
+        private void txtResolveURITime_TextChanged(object sender, EventArgs e)
+        {
+            string input = System.Text.RegularExpressions.Regex.Replace(txtResolveURITime.Text, @"[^\d]", "");
+            int t = 100;
+            int.TryParse(input, out t);
+
+            if (txtResolveURITime.Text != t.ToString())
+            {
+                txtResolveURITime.Text = t.ToString();
+                txtResolveURITime.Select(txtResolveURITime.Text.Length, 0);
+            }
+
+            s["resolve_uri_time"] = t;
+        }
+
         private void cbRadegastLogToFile_CheckedChanged(object sender, EventArgs e)
         {
             s["log_to_file"] = OSD.FromBoolean(cbRadegastLogToFile.Checked);