//
// Radegast Metaverse Client
-// Copyright (c) 2009-2011, Radegast Development Team
+// Copyright (c) 2009-2014, Radegast Development Team
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
private GridClient client { get { return instance.Client; } }
private RadegastNetcom netcom { get { return instance.Netcom; } }
private ChatTextManager mainChatManger;
+ public ChatTextManager MainChatManger { get { return mainChatManger; } }
private Dictionary<string, RadegastTab> tabs = new Dictionary<string, RadegastTab>();
public Dictionary<string, RadegastTab> Tabs { get { return tabs; } }
void Self_ScriptDialog(object sender, ScriptDialogEventArgs e)
{
+ if (instance.MainForm.InvokeRequired)
+ {
+ instance.MainForm.BeginInvoke(new MethodInvoker(() => Self_ScriptDialog(sender, e)));
+ return;
+ }
+
// 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) // object muted by name
|| (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));
+ if (instance.GlobalSettings["on_script_question"] == "Auto Decline"
+ || instance.RLV.RestictionActive("denypermission"))
+ {
+ instance.Client.Self.ScriptQuestionReply(e.Simulator, e.ItemID, e.TaskID, 0);
+ }
+ else if (instance.GlobalSettings["on_script_question"] == "Auto Accept"
+ || instance.RLV.RestictionActive("acceptpermission"))
+ {
+ instance.Client.Self.ScriptQuestionReply(e.Simulator, e.ItemID, e.TaskID, e.Questions);
+ }
+ else
+ {
+ instance.MainForm.AddNotification(new ntfPermissions(instance, e.Simulator, e.TaskID, e.ItemID, e.ObjectName, e.ObjectOwnerName, e.Questions));
+ }
}
private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e)
// Messaage from someone we muted?
if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.IM.FromAgentID)) return;
+ try
+ {
+ if (instance.State.LSLHelper.ProcessIM(e))
+ {
+ return;
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.Log("Failed executing automation action: " + ex.ToString(), Helpers.LogLevel.Warning);
+ }
+
switch (e.IM.Dialog)
{
case InstantMessageDialog.SessionSend:
{
HandleIMFromObject(e);
}
+ else if (e.IM.FromAgentID == UUID.Zero)
+ {
+ instance.MainForm.AddNotification(new ntfGeneric(instance, e.IM.Message));
+ }
else if (e.IM.GroupIM || instance.Groups.ContainsKey(e.IM.IMSessionID))
{
HandleGroupIM(e);
{ // conference
HandleConferenceIM(e);
}
+ else if (e.IM.IMSessionID == UUID.Zero)
+ {
+ String msg = string.Format("Message from {0}: {1}", instance.Names.Get(e.IM.FromAgentID, e.IM.FromAgentName), e.IM.Message);
+ instance.MainForm.AddNotification(new ntfGeneric(instance, msg));
+ DisplayNotificationInChat(msg);
+ }
else
{
HandleIM(e);
}
break;
+ case InstantMessageDialog.RequestLure:
+ instance.MainForm.AddNotification(new ntfRequestLure(instance, e.IM));
+ break;
+
case InstantMessageDialog.GroupInvitation:
instance.MainForm.AddNotification(new ntfGroupInvitation(instance, e.IM));
break;
break;
case InstantMessageDialog.InventoryOffered:
- instance.MainForm.AddNotification(new ntfInventoryOffer(instance, e.IM));
+ var ion = new ntfInventoryOffer(instance, e.IM);
+ instance.MainForm.AddNotification(ion);
+ if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 1)
+ {
+ ion.btnAccept.PerformClick();
+ }
+ else if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 2)
+ {
+ ion.btnDiscard.PerformClick();
+ }
break;
case InstantMessageDialog.TaskInventoryOffered:
// Is the object muted by name?
if (null != client.Self.MuteList.Find(me => me.Type == MuteType.ByName && me.Name == e.IM.FromAgentName)) break;
- instance.MainForm.AddNotification(new ntfInventoryOffer(instance, e.IM));
+ var iont = new ntfInventoryOffer(instance, e.IM);
+ instance.MainForm.AddNotification(iont);
+ if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 1)
+ {
+ iont.btnAccept.PerformClick();
+ }
+ else if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 2)
+ {
+ iont.btnDiscard.PerformClick();
+ }
break;
}
}
/// </summary>
public void SelectDefaultTab()
{
- if (TabExists("chat"))
+ if (IsHandleCreated && TabExists("chat"))
tabs["chat"].Select();
}
{
ChatBufferItem line = new ChatBufferItem(
DateTime.Now,
+ string.Empty,
+ UUID.Zero,
msg,
style
);
DisplayNotificationInChat(e.IM.FromAgentName + ": " + e.IM.Message);
}
- private void HandleIM(InstantMessageEventArgs e)
+ public static Control FindFocusedControl(Control control)
{
- if (TabExists(e.IM.IMSessionID.ToString()))
+ var container = control as ContainerControl;
+ while (container != null)
{
- RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
- if (!tab.Selected) tab.Highlight();
- return;
+ control = container.ActiveControl;
+ container = control as ContainerControl;
}
+ return control;
+ }
- instance.MediaManager.PlayUISound(UISounds.IM);
+ /// <summary>
+ /// Creates new IM tab if needed
+ /// </summary>
+ /// <param name="agentID">IM session with agentID</param>
+ /// <param name="label">Tab label</param>
+ /// <param name="makeActive">Should tab be selected and focused</param>
+ /// <returns>True if there was an existing IM tab, false if it was created</returns>
+ public bool ShowIMTab(UUID agentID, string label, bool makeActive)
+ {
+ if (instance.TabConsole.TabExists((client.Self.AgentID ^ agentID).ToString()))
+ {
+ if (makeActive)
+ {
+ instance.TabConsole.SelectTab((client.Self.AgentID ^ agentID).ToString());
+ }
+ return false;
+ }
- IMTabWindow imTab = AddIMTab(e);
- tabs[e.IM.IMSessionID.ToString()].Highlight();
+ if (makeActive)
+ {
+ instance.MediaManager.PlayUISound(UISounds.IMWindow);
+ }
+ else
+ {
+ instance.MediaManager.PlayUISound(UISounds.IM);
+ }
+
+ Control active = FindFocusedControl(instance.MainForm);
+
+ instance.TabConsole.AddIMTab(agentID, client.Self.AgentID ^ agentID, label);
+
+ if (makeActive)
+ {
+ instance.TabConsole.SelectTab((client.Self.AgentID ^ agentID).ToString());
+ }
+ else if (active != null)
+ {
+ active.Focus();
+ }
+
+ return true;
+ }
+
+ private void HandleIM(InstantMessageEventArgs e)
+ {
+ bool isNew = ShowIMTab(e.IM.FromAgentID, e.IM.FromAgentName, false);
+ if (!TabExists(e.IM.IMSessionID.ToString())) return; // this should now exist. sanity check anyway
+ RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
+ tab.Highlight();
+
+ if (isNew)
+ {
+ ((IMTabWindow)tab.Control).TextManager.ProcessIM(e);
+ }
}
private void HandleConferenceIM(InstantMessageEventArgs e)
if (TabExists(e.IM.IMSessionID.ToString()))
{
RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
- if (!tab.Selected) tab.Highlight();
+ tab.Highlight();
return;
}
instance.MediaManager.PlayUISound(UISounds.IM);
- ConferenceIMTabWindow imTab = AddConferenceIMTab(e);
+ Control active = FindFocusedControl(instance.MainForm);
+
+ ConferenceIMTabWindow imTab = AddConferenceIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket));
tabs[e.IM.IMSessionID.ToString()].Highlight();
+ imTab.TextManager.ProcessIM(e);
+
+ if (active != null)
+ {
+ active.Focus();
+ }
}
private void HandleGroupIM(InstantMessageEventArgs e)
if (TabExists(e.IM.IMSessionID.ToString()))
{
RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
- if (!tab.Selected) tab.Highlight();
+ tab.Highlight();
return;
}
instance.MediaManager.PlayUISound(UISounds.IM);
- GroupIMTabWindow imTab = AddGroupIMTab(e);
+ Control active = FindFocusedControl(instance.MainForm);
+
+ GroupIMTabWindow imTab = AddGroupIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket));
+ imTab.TextManager.ProcessIM(e);
tabs[e.IM.IMSessionID.ToString()].Highlight();
+
+ if (active != null)
+ {
+ active.Focus();
+ }
}
- private void InitializeMainTab()
+ public void InitializeMainTab()
{
+ if (TabExists("login"))
+ {
+ ForceCloseTab("login");
+ }
+
LoginConsole loginConsole = new LoginConsole(instance);
RadegastTab tab = AddTab("login", "Login", loginConsole);
button.Image = null;
button.AutoToolTip = false;
button.Tag = name.ToLower();
+ button.AllowDrop = true;
button.Click += new EventHandler(TabButtonClick);
RadegastTab tab = new RadegastTab(instance, button, control, name.ToLower(), label);
catch (Exception) { }
}
+ button.MouseDown += (msender, margs) =>
+ {
+ if (margs.Button == MouseButtons.Middle)
+ {
+ if (tab.AllowClose)
+ {
+ tab.Close();
+ }
+ else if (tab.AllowHide)
+ {
+ tab.Hide();
+ }
+ }
+ };
+
return tab;
}
selectedTab = tab;
- tbtnCloseTab.Enabled = tab.AllowClose || tab.AllowHide;
+ tbtnCloseTab.Enabled = !tab.Merged && (tab.AllowClose || tab.AllowHide);
if (owner != null)
{
RadegastTab tab = AddTab(session.ToString(), "IM: " + targetName, imTab);
imTab.SelectIMInput();
- tab.Highlight();
return imTab;
}
return imTab;
}
-
- public ConferenceIMTabWindow AddConferenceIMTab(InstantMessageEventArgs e)
- {
- ConferenceIMTabWindow imTab = AddConferenceIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket));
- imTab.TextManager.ProcessIM(e);
- return imTab;
- }
-
public GroupIMTabWindow AddGroupIMTab(UUID session, string name)
{
GroupIMTabWindow imTab = new GroupIMTabWindow(instance, session, name);
return imTab;
}
- public GroupIMTabWindow AddGroupIMTab(InstantMessageEventArgs e)
- {
- GroupIMTabWindow imTab = AddGroupIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket));
- imTab.TextManager.ProcessIM(e);
- return imTab;
- }
-
- public IMTabWindow AddIMTab(InstantMessageEventArgs e)
- {
- IMTabWindow imTab = AddIMTab(e.IM.FromAgentID, e.IM.IMSessionID, e.IM.FromAgentName);
- imTab.TextManager.ProcessIM(e);
- return imTab;
- }
-
public OutfitTextures AddOTTab(Avatar avatar)
{
OutfitTextures otTab = new OutfitTextures(instance, avatar);
private void tbtnCloseTab_Click(object sender, EventArgs e)
{
RadegastTab tab = selectedTab;
- if (tab.AllowClose)
+ if (tab.Merged)
+ return;
+ else if (tab.AllowClose)
tab.Close();
else if (tab.AllowHide)
tab.Hide();
private void ctxTabs_Opening(object sender, CancelEventArgs e)
{
+ e.Cancel = false;
+
Point pt = this.PointToClient(Cursor.Position);
ToolStripItem stripItem = tstTabs.GetItemAt(pt);
{
tabs[stripItem.Tag.ToString()].Select();
- ctxBtnClose.Enabled = selectedTab.AllowClose || selectedTab.AllowHide;
+ ctxBtnClose.Enabled = !selectedTab.Merged && (selectedTab.AllowClose || selectedTab.AllowHide);
ctxBtnDetach.Enabled = selectedTab.AllowDetach;
ctxBtnMerge.Enabled = selectedTab.AllowMerge;
ctxBtnMerge.DropDown.Items.Clear();