\r
public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer)\r
{\r
+ instance.LogClientMessage("chat.txt", item.Text);\r
if (addToBuffer) textBuffer.Add(item);\r
\r
if (showTimestamps)\r
{\r
StringBuilder sb = new StringBuilder();\r
\r
- sb.Append("(channel ");\r
- sb.Append(e.Channel);\r
- sb.Append(") You");\r
+ sb.AppendFormat("(channel {0}) {1}", e.Channel, client.Self.Name);\r
\r
switch (e.Type)\r
{\r
}\r
else if (e.FromName == netcom.LoginOptions.FullName && e.SourceType == ChatSourceType.Agent)\r
{\r
- sb.Append("You");\r
+ sb.Append(client.Self.Name);\r
\r
switch (e.Type)\r
{\r
break;\r
\r
case ChatType.Whisper:\r
- sb.Append(" whisper: ");\r
+ sb.Append(" whispers: ");\r
break;\r
\r
case ChatType.Shout:\r
- sb.Append(" shout: ");\r
+ sb.Append(" shouts: ");\r
break;\r
}\r
\r
\r
public ConfigManager(RadegastInstance instance)\r
{\r
- defaultConfigPath = Path.Combine(instance.userDir, Properties.Resources.ProgramName + @".ini");\r
+ defaultConfigPath = Path.Combine(instance.UserDir, Properties.Resources.ProgramName + @".ini");\r
}\r
\r
public void ApplyCurrentConfig()\r
private RadegastNetcom netcom;\r
private ITextPrinter textPrinter;\r
private UUID sessionID;\r
+ private string sessionName;\r
\r
private ArrayList textBuffer;\r
\r
private bool showTimestamps;\r
\r
- public IMTextManager(RadegastInstance instance, ITextPrinter textPrinter, UUID sessionID)\r
+ public IMTextManager(RadegastInstance instance, ITextPrinter textPrinter, UUID sessionID, string sessionName)\r
{\r
this.sessionID = sessionID;\r
-\r
+ this.sessionName = sessionName;\r
this.textPrinter = textPrinter;\r
this.textBuffer = new ArrayList();\r
\r
sb.Append(message);\r
}\r
\r
+ instance.LogClientMessage(sessionName + ".txt", message);\r
textPrinter.PrintTextLine(sb.ToString());\r
sb = null;\r
}\r
}\r
}\r
\r
- public readonly string userDir;\r
- public readonly string animCacheDir;\r
+ private string userDir;\r
+ /// <summary>\r
+ /// System (not grid!) user's dir\r
+ /// </summary>\r
+ public string UserDir { get { return userDir; } }\r
+\r
+ private string clientDir;\r
+ /// <summary>\r
+ /// Grid client's user dir for settings and logs\r
+ /// </summary>\r
+ public string ClientDir { get { return clientDir; } }\r
+\r
+ private string animCacheDir;\r
+ public string AnimCacheDir { get { return animCacheDir; } }\r
+\r
+ private string globalLogFile;\r
+ public string GlobalLogFile { get { return globalLogFile; } }\r
+\r
+ private bool monoRuntime;\r
+ public bool MonoRuntime { get { return monoRuntime; } }\r
\r
public Dictionary<UUID, Group> groups;\r
public Dictionary<UUID, string> nameCache = new Dictionary<UUID,string>();\r
public event OnAvatarNameCallBack OnAvatarName;\r
\r
public readonly bool advancedDebugging = false;\r
- public readonly bool MonoRuntime;\r
\r
private RadegastInstance()\r
{\r
- try\r
- {\r
- userDir = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), Properties.Resources.ProgramName);\r
- if (!Directory.Exists(userDir))\r
- {\r
- Directory.CreateDirectory(userDir);\r
- }\r
- }\r
- catch (Exception) \r
- {\r
- userDir = System.Environment.CurrentDirectory;\r
- };\r
- animCacheDir = Path.Combine(userDir, @"anim_cache");\r
-\r
- // Are we running mono?\r
- if (null == Type.GetType("Mono.Runtime"))\r
- {\r
- MonoRuntime = false;\r
- }\r
- else\r
- {\r
- MonoRuntime = true;\r
- }\r
+ InitializeLoggingAndConfig();\r
\r
Settings.PIPELINE_REFRESH_INTERVAL = 2000.0f;\r
\r
client.Settings.OBJECT_TRACKING = true;\r
client.Settings.ENABLE_SIMSTATS = true;\r
client.Settings.FETCH_MISSING_INVENTORY = true;\r
- client.Settings.MULTIPLE_SIMS = false;\r
+ client.Settings.MULTIPLE_SIMS = true;\r
client.Settings.SEND_AGENT_THROTTLE = true;\r
client.Settings.SEND_AGENT_UPDATES = true;\r
\r
client.Settings.USE_INTERPOLATION_TIMER = false;\r
\r
netcom = new RadegastNetcom(client);\r
-\r
imageCache = new ImageCache();\r
state = new StateManager(this);\r
- InitializeConfig();\r
+\r
+ InitializeConfigLegacy();\r
\r
mainForm = new frmMain(this);\r
mainForm.InitializeControls();\r
client.Groups.OnGroupJoined += new GroupManager.GroupJoinedCallback(Groups_OnGroupJoined);\r
client.Groups.OnGroupProfile += new GroupManager.GroupProfileCallback(Groups_OnGroupProfile);\r
client.Avatars.OnAvatarNames += new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames);\r
+ client.Network.OnLogin += new NetworkManager.LoginCallback(Network_OnLogin);\r
+ client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(Network_OnDisconnected);\r
}\r
\r
public void CleanUp()\r
client.Groups.OnGroupJoined -= new GroupManager.GroupJoinedCallback(Groups_OnGroupJoined);\r
client.Groups.OnGroupProfile -= new GroupManager.GroupProfileCallback(Groups_OnGroupProfile);\r
client.Avatars.OnAvatarNames -= new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames);\r
+ client.Network.OnLogin -= new NetworkManager.LoginCallback(Network_OnLogin);\r
+ client.Network.OnDisconnected -= new NetworkManager.DisconnectedCallback(Network_OnDisconnected);\r
}\r
\r
if (MonoRuntime)\r
}\r
}\r
\r
+ void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message)\r
+ {\r
+ clientDir = null;\r
+ }\r
+\r
+ void Network_OnLogin(LoginStatus login, string message)\r
+ {\r
+ if (login != LoginStatus.Success)\r
+ return;\r
+\r
+ clientDir = Path.Combine(userDir, client.Self.Name);\r
+ try\r
+ {\r
+ if (!Directory.Exists(clientDir))\r
+ {\r
+ Directory.CreateDirectory(clientDir);\r
+ }\r
+ }\r
+ catch (Exception)\r
+ {\r
+ clientDir = Directory.GetCurrentDirectory();\r
+ }\r
+\r
+ }\r
+\r
+ public void LogClientMessage(string fileName, string message)\r
+ {\r
+ if (clientDir == null) return;\r
+\r
+ lock (this)\r
+ {\r
+ try\r
+ {\r
+ foreach (char lDisallowed in System.IO.Path.GetInvalidFileNameChars())\r
+ {\r
+ fileName = fileName.Replace(lDisallowed.ToString(), "_");\r
+ }\r
+\r
+ StreamWriter logfile = File.AppendText(Path.Combine(clientDir, fileName));\r
+ logfile.WriteLine(DateTime.Now.ToString("yyyy-MM-dd [HH:mm:ss] ") + message);\r
+ logfile.Close();\r
+ logfile.Dispose();\r
+ }\r
+ catch (Exception) { }\r
+ }\r
+ }\r
+\r
void Groups_OnCurrentGroups(Dictionary<UUID, Group> gr)\r
{\r
this.groups = gr;\r
config.SaveCurrentConfig();\r
}\r
\r
- private void InitializeConfig()\r
+ private void InitializeLoggingAndConfig()\r
+ {\r
+ // Are we running mono?\r
+ if (null == Type.GetType("Mono.Runtime"))\r
+ {\r
+ monoRuntime = false;\r
+ }\r
+ else\r
+ {\r
+ monoRuntime = true;\r
+ }\r
+\r
+ try\r
+ {\r
+ userDir = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), Properties.Resources.ProgramName);\r
+ if (!Directory.Exists(userDir))\r
+ {\r
+ Directory.CreateDirectory(userDir);\r
+ }\r
+ }\r
+ catch (Exception)\r
+ {\r
+ userDir = System.Environment.CurrentDirectory;\r
+ };\r
+\r
+ animCacheDir = Path.Combine(userDir, @"anim_cache");\r
+ globalLogFile = Path.Combine(userDir, Properties.Resources.ProgramName + ".log");\r
+ }\r
+\r
+ private void InitializeConfigLegacy()\r
{\r
config = new ConfigManager(this);\r
config.ApplyDefault();\r
// $Id$\r
//\r
using System;\r
+using System.IO;\r
using System.Text.RegularExpressions;\r
using log4net.Appender;\r
using log4net.Core;\r
{\r
string loggingMessage = RenderLoggingEvent(le);\r
\r
+ lock (this)\r
+ {\r
+ StreamWriter logfile = File.AppendText(RadegastInstance.GlobalInstance.GlobalLogFile);\r
+ logfile.WriteLine(loggingMessage);\r
+ logfile.Close();\r
+ logfile.Dispose();\r
+ }\r
+\r
string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)";\r
\r
Regex RE = new Regex(regex, RegexOptions.Multiline);\r
\r
private void AnimDetail_Load(object sender, EventArgs e)\r
{\r
- if (File.Exists(instance.animCacheDir + "/" + anim + ".fail")) {\r
+ if (File.Exists(instance.AnimCacheDir + "/" + anim + ".fail")) {\r
Visible = false;\r
return;\r
}\r
cbFriends.Items.Add(f);\r
}\r
\r
- if (File.Exists(instance.animCacheDir + "/" + anim + ".sla"))\r
+ if (File.Exists(instance.AnimCacheDir + "/" + anim + ".sla"))\r
{\r
pnlSave.Visible = true;\r
return;\r
\r
if (res == DialogResult.OK) {\r
try {\r
- byte[] data = File.ReadAllBytes(instance.animCacheDir + "/" + anim + ".sla");\r
+ byte[] data = File.ReadAllBytes(instance.AnimCacheDir + "/" + anim + ".sla");\r
File.WriteAllBytes(dlg.FileName, data);\r
} catch (Exception ex) {\r
Logger.Log("Saving animation failed: " + ex.Message, Helpers.LogLevel.Debug);\r
\r
if (transfer.Success) {\r
Logger.Log("Animation " + anim + " download success " + asset.AssetData.Length + " bytes.", Helpers.LogLevel.Debug);\r
- File.WriteAllBytes(instance.animCacheDir + "/" + anim + ".sla", asset.AssetData);\r
+ File.WriteAllBytes(instance.AnimCacheDir + "/" + anim + ".sla", asset.AssetData);\r
pnlSave.Visible = true;\r
} else {\r
Logger.Log("Animation " + anim + " download failed.", Helpers.LogLevel.Debug);\r
- FileStream f = File.Create(instance.animCacheDir + "/" + anim + ".fail");\r
+ FileStream f = File.Create(instance.AnimCacheDir + "/" + anim + ".fail");\r
f.Close();\r
Visible = false;\r
}\r
\r
private void btnSend_Click(object sender, EventArgs e)\r
{\r
- byte[] data = File.ReadAllBytes(instance.animCacheDir + "/" + anim + ".sla");\r
+ byte[] data = File.ReadAllBytes(instance.AnimCacheDir + "/" + anim + ".sla");\r
instance.Client.Inventory.RequestCreateItemFromAsset(data, boxAnimName.Text, "(No description)", AssetType.Animation, InventoryType.Animation, instance.Client.Inventory.FindFolderForType(AssetType.Animation), On_ItemCreated);\r
lblStatus.Text = "Uploading...";\r
cbFriends.Enabled = false;\r
{\r
if (!checkedDir) {\r
checkedDir = true;\r
- if (!Directory.Exists(instance.animCacheDir))\r
+ if (!Directory.Exists(instance.AnimCacheDir))\r
{\r
- Directory.CreateDirectory(instance.animCacheDir);\r
+ Directory.CreateDirectory(instance.AnimCacheDir);\r
}\r
}\r
}\r
private List<UUID> participants = new List<UUID>();\r
ManualResetEvent WaitForSessionStart = new ManualResetEvent(false);\r
\r
- public ConferenceIMTabWindow(RadegastInstance instance, UUID session)\r
+ public ConferenceIMTabWindow(RadegastInstance instance, UUID session, string sessionName)\r
{\r
InitializeComponent();\r
Disposed += new EventHandler(IMTabWindow_Disposed);\r
\r
this.session = session;\r
\r
- textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), this.session);\r
+ textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), this.session, sessionName);\r
\r
ApplyConfig(this.instance.Config.CurrentConfig);\r
\r
\r
ManualResetEvent WaitForSessionStart = new ManualResetEvent(false);\r
\r
- public GroupIMTabWindow(RadegastInstance instance, UUID session)\r
+ public GroupIMTabWindow(RadegastInstance instance, UUID session, string sessionName)\r
{\r
InitializeComponent();\r
Disposed += new EventHandler(IMTabWindow_Disposed);\r
this.instance = instance;\r
this.session = session;\r
\r
- textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), this.session);\r
+ textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), this.session, sessionName);\r
ApplyConfig(this.instance.Config.CurrentConfig);\r
\r
// Callbacks\r
this.session = session;\r
this.toName = toName;\r
\r
- textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), this.session);\r
+ textManager = new IMTextManager(this.instance, new RichTextBoxPrinter(rtbIMText), this.session, toName);\r
ApplyConfig(this.instance.Config.CurrentConfig);\r
this.instance.Config.ConfigApplied += new EventHandler<ConfigAppliedEventArgs>(Config_ConfigApplied);\r
}\r
\r
public ConferenceIMTabWindow AddConferenceIMTab(UUID session, string name)\r
{\r
- ConferenceIMTabWindow imTab = new ConferenceIMTabWindow(instance, session);\r
+ ConferenceIMTabWindow imTab = new ConferenceIMTabWindow(instance, session, name);\r
imTab.Dock = DockStyle.Fill;\r
\r
toolStripContainer1.ContentPanel.Controls.Add(imTab);\r
\r
public GroupIMTabWindow AddGroupIMTab(UUID session, string name)\r
{\r
- GroupIMTabWindow imTab = new GroupIMTabWindow(instance, session);\r
+ GroupIMTabWindow imTab = new GroupIMTabWindow(instance, session, name);\r
imTab.Dock = DockStyle.Fill;\r
\r
toolStripContainer1.ContentPanel.Controls.Add(imTab);\r
private void cleanCacheToolStripMenuItem_Click(object sender, EventArgs e)\r
{\r
client.Assets.Cache.Clear();\r
- DirectoryInfo di = new DirectoryInfo(instance.animCacheDir);\r
+ DirectoryInfo di = new DirectoryInfo(instance.AnimCacheDir);\r
FileInfo[] files = di.GetFiles();\r
\r
int num = 0;\r
\r
void Network_OnCurrentSimChanged(Simulator PreviousSimulator)\r
{\r
- client.Appearance.SetPreviousAppearance(true);\r
+ // client.Appearance.SetPreviousAppearance(true);\r
}\r
\r
private void Self_OnInstantMessage(InstantMessage im, Simulator simulator)\r