OSDN Git Service

RAD-85: Muting mostly function.
authorLatif Khalifa <latifer@streamgrid.net>
Thu, 7 Apr 2011 16:08:05 +0000 (16:08 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Thu, 7 Apr 2011 16:08:05 +0000 (16:08 +0000)
TODO: Add ability to mute avatars from their profile, and objects from the object list.

git-svn-id: https://radegast.googlecode.com/svn/trunk@818 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/Core/ChatTextManager.cs
Radegast/GUI/Consoles/TabsConsole.Designer.cs
Radegast/GUI/Consoles/TabsConsole.cs
Radegast/GUI/Notifications/LoadURLNotification.Designer.cs
Radegast/GUI/Notifications/LoadURLNotification.cs
Radegast/GUI/Notifications/PermissionsNotification.Designer.cs
Radegast/GUI/Notifications/PermissionsNotification.cs

index a08d0b1..7465f76 100644 (file)
@@ -220,6 +220,19 @@ namespace Radegast
         {
             if (string.IsNullOrEmpty(e.Message)) return;
 
+            // Check if the sender agent is muted
+            if (e.SourceType == ChatSourceType.Agent &&
+                null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.SourceID)
+                ) return;
+
+            // Check if sender object is muted
+            if (e.SourceType == ChatSourceType.Object &&
+                null != client.Self.MuteList.Find(me =>
+                    (me.Type == MuteType.Resident && me.ID == e.OwnerID) // Owner muted
+                    || (me.Type == MuteType.Object && me.ID == e.SourceID) // Object muted by ID
+                    || (me.Type == MuteType.ByName && me.Name == e.FromName) // Object muted by name
+                )) return;
+
             if (instance.RLV.Enabled && e.Message.StartsWith("@"))
             {
                 instance.RLV.TryProcessCMD(e);
@@ -299,6 +312,8 @@ namespace Radegast
             }
 
             ProcessBufferItem(item, true);
+            instance.TabConsole.Tabs["chat"].Highlight();
+
             sb = null;
         }
 
index 97d9a85..6bc9718 100644 (file)
@@ -43,6 +43,15 @@ namespace Radegast
         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
         protected override void Dispose(bool disposing)
         {
+            if (InvokeRequired)
+            {
+                if (!instance.MonoRuntime || IsHandleCreated)
+                {
+                    Invoke(new System.Windows.Forms.MethodInvoker(() => Dispose(disposing)));
+                }
+                return;
+            }
+
             if (disposing && (components != null))
             {
                 components.Dispose();
index b05ddd0..8a2bb9e 100644 (file)
@@ -181,7 +181,6 @@ namespace Radegast
             netcom.ClientLoginStatus += new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
             netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut);
             netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
-            netcom.ChatReceived += new EventHandler<ChatEventArgs>(netcom_ChatReceived);
             netcom.ChatSent += new EventHandler<ChatSentEventArgs>(netcom_ChatSent);
             netcom.AlertMessageReceived += new EventHandler<AlertMessageEventArgs>(netcom_AlertMessageReceived);
             netcom.InstantMessageReceived += new EventHandler<InstantMessageEventArgs>(netcom_InstantMessageReceived);
@@ -192,7 +191,6 @@ namespace Radegast
             netcom.ClientLoginStatus -= new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
             netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
             netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
-            netcom.ChatReceived -= new EventHandler<ChatEventArgs>(netcom_ChatReceived);
             netcom.ChatSent -= new EventHandler<ChatSentEventArgs>(netcom_ChatSent);
             netcom.AlertMessageReceived -= new EventHandler<AlertMessageEventArgs>(netcom_AlertMessageReceived);
             netcom.InstantMessageReceived -= new EventHandler<InstantMessageEventArgs>(netcom_InstantMessageReceived);
@@ -202,12 +200,19 @@ namespace Radegast
         {
             // Is this object muted
             if (null != client.Self.MuteList.Find(m => (m.Type == MuteType.Object && m.ID == e.ObjectID) // muted object by id
-                || (m.Type == MuteType.ByName && m.Name == e.ObjectName))) return;
+                || (m.Type == MuteType.ByName && m.Name == e.ObjectName) // object muted by name
+                )) return;
+            
             instance.MainForm.AddNotification(new ntfScriptDialog(instance, e.Message, e.ObjectName, e.ImageID, e.ObjectID, e.FirstName, e.LastName, e.Channel, e.ButtonLabels));
         }
 
         void Self_ScriptQuestion(object sender, ScriptQuestionEventArgs e)
         {
+            // Is this object muted
+            if (null != client.Self.MuteList.Find(m => (m.Type == MuteType.Object && m.ID == e.TaskID) // muted object by id
+                || (m.Type == MuteType.ByName && m.Name == e.ObjectName) // object muted by name
+                )) return;
+
             instance.MainForm.AddNotification(new ntfPermissions(instance, e.Simulator, e.TaskID, e.ItemID, e.ObjectName, e.ObjectOwnerName, e.Questions));
         }
 
@@ -280,20 +285,22 @@ namespace Radegast
             tabs["chat"].Highlight();
         }
 
-        private void netcom_ChatReceived(object sender, ChatEventArgs e)
-        {
-            if (string.IsNullOrEmpty(e.Message)) return;
-
-            tabs["chat"].Highlight();
-        }
-
         void Self_LoadURL(object sender, LoadUrlEventArgs e)
         {
+            // Is the object or the owner muted?
+            if (null != client.Self.MuteList.Find(m => (m.Type == MuteType.Object && m.ID == e.ObjectID) // muted object by id 
+                || (m.Type == MuteType.ByName && m.Name == e.ObjectName) // object muted by name
+                || (m.Type == MuteType.Resident && m.ID == e.OwnerID) // object's owner muted
+                )) return;
+
             instance.MainForm.AddNotification(new ntfLoadURL(instance, e));
         }
 
         private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e)
         {
+            // Messaage from someone we muted?
+            if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.IM.FromAgentID)) return;
+
             switch (e.IM.Dialog)
             {
                 case InstantMessageDialog.SessionSend:
@@ -469,6 +476,12 @@ namespace Radegast
 
         private void HandleIMFromObject(InstantMessageEventArgs e)
         {
+            // Is the object or the owner muted?
+            if (null != client.Self.MuteList.Find(m => (m.Type == MuteType.Object && m.ID == e.IM.IMSessionID) // muted object by id 
+                || (m.Type == MuteType.ByName && m.Name == e.IM.FromAgentName) // object muted by name
+                || (m.Type == MuteType.Resident && m.ID == e.IM.FromAgentID) // object's owner muted
+                )) return;
+
             DisplayNotificationInChat(e.IM.FromAgentName + ": " + e.IM.Message);
         }
 
index a3b926b..65de9b8 100644 (file)
@@ -61,6 +61,7 @@ namespace Radegast
             this.rtbText = new System.Windows.Forms.RichTextBox();
             this.btnGoTo = new System.Windows.Forms.Button();
             this.btnCancel = new System.Windows.Forms.Button();
+            this.btnMute = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
             // rtbText
@@ -76,8 +77,8 @@ namespace Radegast
             this.rtbText.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
             this.rtbText.Size = new System.Drawing.Size(289, 96);
             this.rtbText.TabIndex = 0;
-            this.rtbText.Text = "Load web page http://radegast.org/ ?\n\nPlease visit\n\nFrom object: Object, ow" +
-                "ner Latif Khalifa?";
+            this.rtbText.Text = "Load web page http://radegast.org/ ?\n\nPlease visit\n\nFrom object: Object, owner La" +
+                "tif Khalifa?";
             this.rtbText.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbText_LinkClicked);
             // 
             // btnGoTo
@@ -100,10 +101,21 @@ namespace Radegast
             this.btnCancel.UseVisualStyleBackColor = true;
             this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
             // 
+            // btnMute
+            // 
+            this.btnMute.Location = new System.Drawing.Point(230, 117);
+            this.btnMute.Name = "btnMute";
+            this.btnMute.Size = new System.Drawing.Size(75, 23);
+            this.btnMute.TabIndex = 3;
+            this.btnMute.Text = "Mute";
+            this.btnMute.UseVisualStyleBackColor = true;
+            this.btnMute.Click += new System.EventHandler(this.btnMute_Click);
+            // 
             // ntfLoadURL
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.Controls.Add(this.btnMute);
             this.Controls.Add(this.btnCancel);
             this.Controls.Add(this.btnGoTo);
             this.Controls.Add(this.rtbText);
@@ -119,6 +131,7 @@ namespace Radegast
         public System.Windows.Forms.RichTextBox rtbText;
         public System.Windows.Forms.Button btnGoTo;
         public System.Windows.Forms.Button btnCancel;
+        public System.Windows.Forms.Button btnMute;
 
     }
 }
index 7995bc8..0fadbb0 100644 (file)
@@ -118,5 +118,11 @@ namespace Radegast
                 rtbText.BackColor = Parent.BackColor;
             }
         }
+
+        private void btnMute_Click(object sender, EventArgs e)
+        {
+            instance.Client.Self.UpdateMuteListEntry(MuteType.Object, ev.ObjectID, ev.ObjectName);
+            instance.MainForm.RemoveNotification(this);
+        }
     }
 }
index 77e6147..d9e52ec 100644 (file)
@@ -58,21 +58,21 @@ namespace Radegast
         /// </summary>
         private void InitializeComponent()
         {
-            this.btnIgnore = new System.Windows.Forms.Button();
+            this.btnMute = new System.Windows.Forms.Button();
             this.btnNo = new System.Windows.Forms.Button();
             this.btnYes = new System.Windows.Forms.Button();
             this.txtMessage = new System.Windows.Forms.TextBox();
             this.SuspendLayout();
             // 
-            // btnIgnore
+            // btnMute
             // 
-            this.btnIgnore.Location = new System.Drawing.Point(165, 62);
-            this.btnIgnore.Name = "btnIgnore";
-            this.btnIgnore.Size = new System.Drawing.Size(75, 23);
-            this.btnIgnore.TabIndex = 8;
-            this.btnIgnore.Text = "&Ignore";
-            this.btnIgnore.UseVisualStyleBackColor = true;
-            this.btnIgnore.Click += new System.EventHandler(this.btnIgnore_Click);
+            this.btnMute.Location = new System.Drawing.Point(165, 62);
+            this.btnMute.Name = "btnMute";
+            this.btnMute.Size = new System.Drawing.Size(75, 23);
+            this.btnMute.TabIndex = 8;
+            this.btnMute.Text = "&Mute";
+            this.btnMute.UseVisualStyleBackColor = true;
+            this.btnMute.Click += new System.EventHandler(this.btnMute_Click);
             // 
             // btnNo
             // 
@@ -111,7 +111,7 @@ namespace Radegast
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.Controls.Add(this.btnIgnore);
+            this.Controls.Add(this.btnMute);
             this.Controls.Add(this.btnNo);
             this.Controls.Add(this.btnYes);
             this.Controls.Add(this.txtMessage);
@@ -124,7 +124,7 @@ namespace Radegast
 
         #endregion
 
-        public System.Windows.Forms.Button btnIgnore;
+        public System.Windows.Forms.Button btnMute;
         public System.Windows.Forms.Button btnNo;
         public System.Windows.Forms.Button btnYes;
         public System.Windows.Forms.TextBox txtMessage;
index fb370fe..10faabc 100644 (file)
@@ -66,7 +66,7 @@ namespace Radegast
             args.Text = txtMessage.Text;
             args.Buttons.Add(btnYes);
             args.Buttons.Add(btnNo);
-            args.Buttons.Add(btnIgnore);
+            args.Buttons.Add(btnMute);
             FireNotificationCallback(args);
         }
 
@@ -82,8 +82,9 @@ namespace Radegast
             instance.MainForm.RemoveNotification(this);
         }
 
-        private void btnIgnore_Click(object sender, EventArgs e)
+        private void btnMute_Click(object sender, EventArgs e)
         {
+            instance.Client.Self.UpdateMuteListEntry(MuteType.Object, taskID, objectName);
             instance.MainForm.RemoveNotification(this);
         }
     }