diff --git a/EVEData/EveManager.cs b/EVEData/EveManager.cs index bc7b854..6305143 100644 --- a/EVEData/EveManager.cs +++ b/EVEData/EveManager.cs @@ -37,6 +37,11 @@ public class EveManager private bool BackgroundThreadShouldTerminate; + /// + /// Is it a local file. + /// + private Dictionary isLocalFile; + /// /// Read position map for the intel files /// @@ -188,6 +193,10 @@ public static EveManager Instance public string EVELogFolder { get; set; } + public bool EnableHTTPProxy { get; set; } + public string HTTPProxyServer { get; set; } + public string HTTPProxyPort { get; set; } + /// /// Sov Campaign Updated Event Handler /// @@ -1976,6 +1985,7 @@ public void SetupIntelWatcher() } intelFileReadPos = new Dictionary(); + isLocalFile = new Dictionary(); if (string.IsNullOrEmpty(EVELogFolder) || !Directory.Exists(EVELogFolder)) { @@ -2075,6 +2085,7 @@ private void LogFileCacheTrigger(List eveLogFolders) FileInfo[] files = di.GetFiles("*.txt"); foreach (FileInfo file in files) { + /* bool readFile = false; foreach (string intelFilterStr in IntelFilters) { @@ -2091,11 +2102,21 @@ private void LogFileCacheTrigger(List eveLogFolders) readFile = true; } + // local files, again. + if (isLocalFile.ContainsKey(file.FullName)) + { + readFile = true; + } + // gamelogs if (folder.Contains("Gamelogs")) { readFile = true; } + */ + + // Local chat files cannot be confirmed by file name here, so all files are triggered by default. + bool readFile = true; // only read files from the last day if (file.CreationTime > DateTime.Now.AddDays(-1) && readFile) @@ -2444,7 +2465,26 @@ private void Init() UserAgent = "SMT-map-app", }); - ESIClient = new ESI.NET.EsiClient(config); + HttpClientHandler handler = new HttpClientHandler + { + // Switch to All which adds brotli encoding for .net core due to https://github.com/ccpgames/sso-issues/issues/81 +#if NET + AutomaticDecompression = DecompressionMethods.All +#else + AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate +#endif + + }; + + if (EnableHTTPProxy == true) + { + handler.Proxy = new WebProxy($"http://{HTTPProxyServer}:{HTTPProxyPort}"); + } + + HttpClient client = new HttpClient(handler); + + + ESIClient = new ESI.NET.EsiClient(config, client); ESIScopes = new List { "publicData", @@ -2593,235 +2633,240 @@ private void IntelFileWatcher_Changed(object sender, FileSystemEventArgs e) string[] channelParts = e.Name.Split("_"); string channelName = string.Join("_", channelParts, 0, channelParts.Length - 3); - bool processFile = false; bool localChat = false; + bool intelChat = false; - // check if the changed file path contains the name of a channel we're looking for foreach (string intelFilterStr in IntelFilters) { if (changedFile.Contains(intelFilterStr, StringComparison.OrdinalIgnoreCase)) { - processFile = true; + intelChat = true; break; } } - if (changedFile.Contains("Local_")) + try { - localChat = true; - processFile = true; - } + Encoding fe = Misc.GetEncoding(changedFile); + FileStream ifs = new FileStream(changedFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - if (processFile) - { - try - { - Encoding fe = Misc.GetEncoding(changedFile); - FileStream ifs = new FileStream(changedFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + StreamReader file = new StreamReader(ifs, fe); - StreamReader file = new StreamReader(ifs, fe); + int fileReadFrom = 0; - int fileReadFrom = 0; + // have we seen this file before + if (intelFileReadPos.ContainsKey(changedFile)) + { + fileReadFrom = intelFileReadPos[changedFile]; + localChat = isLocalFile[changedFile]; + } + else + { + string system = string.Empty; + string characterName = string.Empty; - // have we seen this file before - if (intelFileReadPos.ContainsKey(changedFile)) - { - fileReadFrom = intelFileReadPos[changedFile]; - } - else + // read the iniital block + while (!file.EndOfStream) { - if (localChat) + string l = file.ReadLine(); + fileReadFrom++; + + // explicitly skip just "local" + if (l.Contains("Channel ID: local")) { - string system = string.Empty; - string characterName = string.Empty; + localChat = true; - // read the iniital block - while (!file.EndOfStream) - { - string l = file.ReadLine(); - fileReadFrom++; + // now can read the next line + l = file.ReadLine(); // should be the "Channel Name: " + l = file.ReadLine(); // should be the "Listener : " + fileReadFrom++; - // explicitly skip just "local" - if (l.Contains("Channel Name: Local")) - { - // now can read the next line - l = file.ReadLine(); // should be the "Listener : " - fileReadFrom++; + characterName = l.Split(':')[1].Trim(); - characterName = l.Split(':')[1].Trim(); + bool addChar = true; + foreach (EVEData.LocalCharacter c in LocalCharacters) + { + if (characterName == c.Name) + { + c.Location = system; + c.LocalChatFile = changedFile; - bool addChar = true; - foreach (EVEData.LocalCharacter c in LocalCharacters) + System s = GetEveSystem(system); + if (s != null) { - if (characterName == c.Name) - { - c.Location = system; - c.LocalChatFile = changedFile; - - System s = GetEveSystem(system); - if (s != null) - { - c.Region = s.Region; - } - else - { - c.Region = ""; - } - - addChar = false; - } + c.Region = s.Region; } - - if (addChar) + else { - LocalCharacters.Add(new EVEData.LocalCharacter(characterName, changedFile, system)); - if (LocalCharacterUpdateEvent != null) - { - LocalCharacterUpdateEvent(); - } + c.Region = ""; } - break; + addChar = false; } } - } - while (file.ReadLine() != null) - { - fileReadFrom++; - } + if (addChar) + { + LocalCharacters.Add(new EVEData.LocalCharacter(characterName, changedFile, system)); + if (LocalCharacterUpdateEvent != null) + { + LocalCharacterUpdateEvent(); + } + } - fileReadFrom--; - file.BaseStream.Seek(0, SeekOrigin.Begin); + break; + } } - for (int i = 0; i < fileReadFrom; i++) + while (file.ReadLine() != null) { - file.ReadLine(); + fileReadFrom++; } - string line = file.ReadLine(); + fileReadFrom--; + file.BaseStream.Seek(0, SeekOrigin.Begin); + } - while (line != null) - { // trim any items off the front - if (line.Contains('[') && line.Contains(']')) - { - line = line.Substring(line.IndexOf("[")); - } + for (int i = 0; i < fileReadFrom; i++) + { + file.ReadLine(); + } - if (line == "") - { - line = file.ReadLine(); - continue; - } + string line = file.ReadLine(); - fileReadFrom++; + while (line != null) + { // trim any items off the front + if (line.Contains('[') && line.Contains(']')) + { + line = line.Substring(line.IndexOf("[")); + } - if (localChat) - { - if (line.StartsWith("[") && line.Contains("EVE System > Channel changed to Local")) - { - string system = line.Split(':').Last().Trim(); + if (line == "") + { + line = file.ReadLine(); + continue; + } - foreach (EVEData.LocalCharacter c in LocalCharacters) - { - if (c.LocalChatFile == changedFile) - { - c.Location = system; - } - } - } - } - else - { - // check if it is in the intel list already (ie if you have multiple clients running) - bool addToIntel = true; + fileReadFrom++; - int start = line.IndexOf('>') + 1; - string newIntelString = line.Substring(start); + if (localChat) + { + if (line.StartsWith("[") && line.Contains("] EVE") && line.EndsWith("*")) + { + string system = string.Empty; - if (newIntelString != null) + // Compatible with Chinese punctuation marks + if (line.Contains(":")) { - foreach (EVEData.IntelData idl in IntelDataList) - { - if (idl.IntelString == newIntelString && (DateTime.Now - idl.IntelTime).Seconds < 5) - { - addToIntel = false; - break; - } - } + system = line.Split(':').Last().Trim(); + system = system.Replace("*", ""); // Remove localized } else { - addToIntel = false; + system = line.Split(':').Last().Trim(); } - if (line.Contains("Channel MOTD:")) + foreach (EVEData.LocalCharacter c in LocalCharacters) { - addToIntel = false; + if (c.LocalChatFile == changedFile) + { + c.Location = system; + } } + } + } + else + { + // check if it is in the intel list already (ie if you have multiple clients running) + bool addToIntel = true; - foreach (String ignoreMarker in IntelIgnoreFilters) + int start = line.IndexOf('>') + 1; + string newIntelString = line.Substring(start); + + if (newIntelString != null) + { + foreach (EVEData.IntelData idl in IntelDataList) { - if (line.IndexOf(ignoreMarker, StringComparison.OrdinalIgnoreCase) != -1) + if (idl.IntelString == newIntelString && (DateTime.Now - idl.IntelTime).Seconds < 5) { addToIntel = false; break; } } + } + else + { + addToIntel = false; + } + if (line.Contains("Channel MOTD:")) + { + addToIntel = false; + } + + if (intelChat == false) + { + addToIntel = false; + } - if (addToIntel) + foreach (String ignoreMarker in IntelIgnoreFilters) + { + if (line.IndexOf(ignoreMarker, StringComparison.OrdinalIgnoreCase) != -1) { - EVEData.IntelData id = new EVEData.IntelData(line, channelName); + addToIntel = false; + break; + } + } - foreach (string s in id.IntelString.Split(' ')) + if (addToIntel) + { + EVEData.IntelData id = new EVEData.IntelData(line, channelName); + + + foreach (string s in id.IntelString.Split(' ')) + { + if (s == "" || s.Length < 3) { - if (s == "" || s.Length < 3) - { - continue; - } + continue; + } - foreach (String clearMarker in IntelClearFilters) + foreach (String clearMarker in IntelClearFilters) + { + if (clearMarker.IndexOf(s, StringComparison.OrdinalIgnoreCase) == 0) { - if (clearMarker.IndexOf(s, StringComparison.OrdinalIgnoreCase) == 0) - { - id.ClearNotification = true; - } + id.ClearNotification = true; } + } - foreach (System sys in Systems) + foreach (System sys in Systems) + { + if (sys.Name.IndexOf(s, StringComparison.OrdinalIgnoreCase) == 0 || s.IndexOf(sys.Name, StringComparison.OrdinalIgnoreCase) == 0) { - if (sys.Name.IndexOf(s, StringComparison.OrdinalIgnoreCase) == 0 || s.IndexOf(sys.Name, StringComparison.OrdinalIgnoreCase) == 0) - { - id.Systems.Add(sys.Name); - } + id.Systems.Add(sys.Name); } } + } - IntelDataList.Enqueue(id); - - if (IntelUpdatedEvent != null) - { - IntelUpdatedEvent(IntelDataList); - } + IntelDataList.Enqueue(id); + if (IntelUpdatedEvent != null) + { + IntelUpdatedEvent(IntelDataList); } - } - line = file.ReadLine(); + } } - ifs.Close(); - - intelFileReadPos[changedFile] = fileReadFrom; - } - catch - { + line = file.ReadLine(); } + + ifs.Close(); + + intelFileReadPos[changedFile] = fileReadFrom; + isLocalFile[changedFile] = localChat; } - else + catch { } } diff --git a/SMT/MainWindow.xaml.cs b/SMT/MainWindow.xaml.cs index 3d139b0..8fed073 100644 --- a/SMT/MainWindow.xaml.cs +++ b/SMT/MainWindow.xaml.cs @@ -138,6 +138,10 @@ public MainWindow() EVEData.EveManager.Instance = EVEManager; EVEManager.EVELogFolder = MapConf.CustomEveLogFolderLocation; + EVEManager.EnableHTTPProxy = MapConf.EnableHTTPProxy; + EVEManager.HTTPProxyServer = MapConf.HTTPProxyServer; + EVEManager.HTTPProxyPort = MapConf.HTTPProxyPort; + EVEManager.UseESIForCharacterPositions = MapConf.UseESIForCharacterPositions; // if we want to re-build the data as we've changed the format, recreate it all from scratch diff --git a/SMT/MapConfig.cs b/SMT/MapConfig.cs index 5e7b40b..5e71916 100644 --- a/SMT/MapConfig.cs +++ b/SMT/MapConfig.cs @@ -109,6 +109,11 @@ public class MapConfig : INotifyPropertyChanged private bool m_overlayShowAllCharacterNames = false; private bool m_overlayIndividualCharacterWindows = false; + private bool m_EnableHTTPProxy; + private string m_HTTPProxyServer; + private string m_HTTPProxyPort; + + public MapConfig() { SetDefaults(); @@ -220,6 +225,22 @@ public string DefaultRegion [Browsable(false)] public bool Debug_EnableMapEdit { get; set; } + + [Browsable(false)] + public bool EnableHTTPProxy + { + get => m_EnableHTTPProxy; + set + { + m_EnableHTTPProxy = value; + OnPropertyChanged("EnableHTTPProxy"); + } + } + + public string HTTPProxyServer { get; set; } + public string HTTPProxyPort { get; set; } + + public bool DisableJumpBridgesPathAnimation { get => m_DisableJumpBridgesPathAnimation; diff --git a/SMT/Preferences.xaml b/SMT/Preferences.xaml index b6ca7b8..4ed8a9e 100644 --- a/SMT/Preferences.xaml +++ b/SMT/Preferences.xaml @@ -349,16 +349,30 @@ - - + + + - + Enable Universe Map Edits + + + + + + + + +