OSDN Git Service

RAD-124: Added Ability to read Friends Conference with speech plugin
authorLatif Khalifa <latifer@streamgrid.net>
Thu, 18 Mar 2010 10:30:43 +0000 (10:30 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Thu, 18 Mar 2010 10:30:43 +0000 (10:30 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@525 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/GUI/Consoles/ConferenceIMTabWindow.cs
plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/ConferenceIMSession.cs [new file with mode: 0644]
plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/Control.cs
plugins/Radegast.Plugin.Speech/RadSpeech/Radegast.Plugin.Speech.csproj

index b7ac96c..8434982 100644 (file)
@@ -47,6 +47,8 @@ namespace Radegast
         private List<UUID> participants = new List<UUID>();
         ManualResetEvent WaitForSessionStart = new ManualResetEvent(false);
 
+        public string SessionName { get; set; }
+
         public ConferenceIMTabWindow(RadegastInstance instance, UUID session, string sessionName)
         {
             InitializeComponent();
@@ -54,6 +56,7 @@ namespace Radegast
 
             this.instance = instance;
             this.client = instance.Client;
+            this.SessionName = sessionName;
             netcom = this.instance.Netcom;
 
             this.session = session;
diff --git a/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/ConferenceIMSession.cs b/plugins/Radegast.Plugin.Speech/RadSpeech/Conversation/ConferenceIMSession.cs
new file mode 100644 (file)
index 0000000..ca9f0cb
--- /dev/null
@@ -0,0 +1,75 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using OpenMetaverse;\r
+\r
+namespace RadegastSpeech.Conversation\r
+{\r
+    class ConferenceIMSession : IMSession\r
+    {\r
+        internal ConferenceIMSession(PluginControl pc, UUID session, string title)\r
+            : base(pc, session)\r
+        {\r
+            AgentID = session;\r
+            Title = title;\r
+            Talker.Say("New " + Title, Talk.BeepType.Comm);\r
+        }\r
+\r
+        /// <summary>\r
+        /// A group IM session is made active.\r
+        /// </summary>\r
+        internal override void Start()\r
+        {\r
+            base.Start();\r
+            Talker.SayMore(Title);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Handle arriving message within an IM session.\r
+        /// </summary>\r
+        /// <param name="agentID"></param>\r
+        /// <param name="agentName"></param>\r
+        /// <param name="message"></param>\r
+        internal override void OnMessage(UUID agentID, string agentName, string message)\r
+        {\r
+            if (isMuted) return;\r
+\r
+            string who = FriendlyName(agentName, agentID);\r
+            if (!amCurrent())\r
+                who = Title + ", " + who;\r
+\r
+            Talker.SayIMPerson(who,\r
+                    message,\r
+                    SessionPosition,\r
+                    Talker.voices.VoiceFor(agentID));\r
+        }\r
+\r
+        /// <summary>\r
+        /// Handle recognized speech during a Group IM Session.\r
+        /// </summary>\r
+        /// <param name="message"></param>\r
+        /// <returns></returns>\r
+        internal override bool Hear(string message)\r
+        {\r
+            // Let higher level commands have a chance.\r
+            if (base.Hear(message)) return true;\r
+\r
+            // Command to Close the session?\r
+            if (message.ToLower() == "disconnect")\r
+            {\r
+                Radegast.RadegastTab tab = TabConsole.Tabs[Title];\r
+                tab.Close();\r
+                return true;\r
+            }\r
+\r
+            // Otherwise put the text into the session.\r
+            Talker.Say(control.converse.LoginName, message);\r
+            control.instance.Netcom.SendInstantMessage(\r
+                        message,\r
+                        SessionID,\r
+                        SessionID);\r
+            return true;\r
+        }\r
+    }\r
+}\r
index b300997..c916b18 100644 (file)
@@ -200,6 +200,11 @@ namespace RadegastSpeech.Conversation
                 SelectConversation(
                     control.instance.Groups[tab.SessionId].Name);
             }
+            else if (sTabControl is ConferenceIMTabWindow)
+            {
+                ConferenceIMTabWindow tab = (ConferenceIMTabWindow)sTabControl;
+                SelectConversation(tab.SessionName);
+            }
             else if (sTabControl is IMTabWindow)
             {
                 IMTabWindow tab = (IMTabWindow)sTabControl;
@@ -241,6 +246,12 @@ namespace RadegastSpeech.Conversation
                 AddConversation(new GroupIMSession(control, tab.SessionId));
                 return;
             }
+            else if (sTabControl is ConferenceIMTabWindow)
+            {
+                ConferenceIMTabWindow tab = (ConferenceIMTabWindow)sTabControl;
+                AddConversation(new ConferenceIMSession(control, tab.SessionId, tab.SessionName));
+                return;
+            }
             else if (sTabControl is IMTabWindow)
             {
                 IMTabWindow tab = (IMTabWindow)sTabControl;
@@ -249,8 +260,8 @@ namespace RadegastSpeech.Conversation
             }
             else if (sTabControl is ObjectsConsole)
             {
-                surroundings = new Surroundings( control );
-                AddConversation( surroundings );
+                surroundings = new Surroundings(control);
+                AddConversation(surroundings);
             }
 
             // If a conversation was created, switch to it.
@@ -625,7 +636,7 @@ namespace RadegastSpeech.Conversation
         /// <param name="simulator"></param>
         void OnInstantMessage(object sender, InstantMessageEventArgs e)
         {
-            Conversation.IMSession sess;
+            Conversation.IMSession sess = null;
             string groupName;
 
             // All sorts of things come in as a instant messages. For actual messages
@@ -645,8 +656,7 @@ namespace RadegastSpeech.Conversation
                     else if (e.IM.BinaryBucket.Length >= 2)
                     {
                         // Ad-hoc friend conference
-                        // TODO this is probably the wrong name
-                        sess = (IMSession)control.converse.GetConversation(e.IM.FromAgentName);
+                        sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket));
                         if (sess != null)
                             sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                     }
@@ -664,9 +674,17 @@ namespace RadegastSpeech.Conversation
                     break;
 
                 case InstantMessageDialog.SessionSend:
-                    // Message from a group member
-                    groupName = control.instance.Groups[e.IM.IMSessionID].Name;
-                    sess = (IMSession)control.converse.GetConversation(groupName);
+                    if (control.instance.Groups.ContainsKey(e.IM.IMSessionID))
+                    {
+                        // Message from a group member
+                        groupName = control.instance.Groups[e.IM.IMSessionID].Name;
+                        sess = (IMSession)control.converse.GetConversation(groupName);
+                    }
+                    else if (e.IM.BinaryBucket.Length >= 2) // ad hoc friends conference
+                    {
+                        sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket));
+                    }
+
                     if (sess != null)
                         sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                     break;
index c6bc210..6d8b112 100644 (file)
@@ -70,6 +70,7 @@
   <ItemGroup>\r
     <Compile Include="AreaControl.cs" />\r
     <Compile Include="Conversation\Chat.cs" />\r
+    <Compile Include="Conversation\ConferenceIMSession.cs" />\r
     <Compile Include="Conversation\Control.cs" />\r
     <Compile Include="Conversation\BlueMenu.cs" />\r
     <Compile Include="Conversation\Friends.cs" />\r