private void c_btnChangeUserID_Click(object sender, EventArgs e) { if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == false) { SetupUserID.ShowSetupUserID(); c_txtUserID.Text = Settings.UserID; if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true) { c_cbContributeRealmPlayers.Enabled = true; c_cbContributeRealmPlayers.Checked = Settings.Instance.ContributeRealmPlayers; c_cbContributeRaidStats.Enabled = true; c_cbContributeRaidStats.Checked = Settings.Instance.ContributeRaidStats; c_cbxWait5Seconds.Enabled = true; c_cbxWait5Seconds.Checked = Settings.Instance.Wait5SecondsAfterUpload; } } else { var result = Utility.MessageBoxShow("Are you sure you want to change your UserID? A UserID is unique and should only be used by 1 person. There are very few reasons to ever change this UserID. Do you have a valid reason and are sure you want to change the UserID?", "Are you sure?", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { SetupUserID.ShowSetupUserID(); c_txtUserID.Text = Settings.UserID; } } }
private void c_btnSkip_Click(object sender, EventArgs e) { if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == false) { var dialogResult = Utility.MessageBoxShow("Skipping this step means contributions to realmplayers and raidstats wont work. However you can always setup UserID later in the menu File->Settings.\r\n\r\nAre you sure you want to skip configuring UserID?", "Skip configuring UserID?", MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.No) { return; } } Close(); }
private void CreateAddonPackageForm_Load(object sender, EventArgs e) { Utility.SetPositionToMouse(this); c_cbUpdateImportance.Items.AddRange(Enum.GetNames(typeof(ServerComm.UpdateImportance))); c_cbUpdateImportance.SelectedItem = ServerComm.UpdateImportance.Good.ToString(); //this.TopMost = true; if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == false) { Utility.MessageBoxShow("You must have a valid UserID to be able to create AddonPackages"); Close(); } }
private void ApplicationSettingsForm_Load(object sender, EventArgs e) { Utility.SetPositionToMouse(this); //this.TopMost = true; c_txtUserID.Text = Settings.UserID; c_txtWowDirectory.Text = Settings.GetWowDirectory(WowVersionEnum.Vanilla); c_cbAutoRefresh.Checked = Settings.Instance.AutoRefreshNews; c_cbxRunNotAdmin.Checked = Settings.Instance.RunWoWNotAdmin; c_cbxAutoHide.Checked = Settings.Instance.AutoHideOldNews; c_cbAutoUpdateVF.Checked = Settings.Instance.AutoUpdateVFAddons; c_cbxFeenixNews.Checked = Settings.Instance.NewsSources_Feenix; c_cbxNostalriusNews.Checked = Settings.Instance.NewsSources_Nostalrius; c_cbxKronosNews.Checked = Settings.Instance.NewsSources_Kronos; if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true) { c_cbContributeRealmPlayers.Enabled = true; c_cbContributeRealmPlayers.Checked = Settings.Instance.ContributeRealmPlayers; c_cbContributeRaidStats.Enabled = true; c_cbContributeRaidStats.Checked = Settings.Instance.ContributeRaidStats; c_cbxWait5Seconds.Enabled = true; c_cbxWait5Seconds.Checked = Settings.Instance.Wait5SecondsAfterUpload; } else { c_cbContributeRealmPlayers.Enabled = false; c_cbContributeRaidStats.Enabled = false; c_cbxWait5Seconds.Enabled = false; c_cbContributeRealmPlayers.Checked = false; c_cbContributeRaidStats.Checked = false; c_cbxWait5Seconds.Checked = false; } //c_cbxWoWNoDelay.Checked = Settings.Instance.UseWoWNoDelay; if (Settings.HaveTBC == true) { c_cbxEnableTBC.Checked = true; c_txtTBCWowDirectory.Enabled = true; c_txtTBCWowDirectory.Text = Settings.GetWowDirectory(WowVersionEnum.TBC); c_btnTBCWowDirectoryBrowse.Enabled = true; } else { c_cbxEnableTBC.Checked = false; c_txtTBCWowDirectory.Text = ""; c_txtTBCWowDirectory.Enabled = false; c_btnTBCWowDirectoryBrowse.Enabled = false; } }
private void SetupUserIDForm_Load(object sender, EventArgs e) { Utility.SetPositionToMouse(this); c_txtUserID.Text = Settings.UserID; if (RealmPlayersUploader.IsValidUserID(c_txtUserID.Text) == false) { if (System.IO.File.Exists(Settings.GetWowDirectory(WowVersionEnum.Vanilla) + "VF_RealmPlayersUploader\\Settings.cfg") == true) { var oldSettings = System.IO.File.ReadAllLines(Settings.GetWowDirectory(WowVersionEnum.Vanilla) + "VF_RealmPlayersUploader\\Settings.cfg"); foreach (var settingsLine in oldSettings) { if (settingsLine.StartsWith("UserID=")) { c_txtUserID.Text = settingsLine.Substring("UserID=".Length); Utility.MessageBoxShow("Found old installation of VF_RealmPlayersUploader, copied the UserID"); } } } } //this.TopMost = true; }
private void c_btnClose_Click(object sender, EventArgs e) { if (WowUtility.IsValidWowDirectory(c_txtWowDirectory.Text) == false) { var dialogResult = Utility.MessageBoxShow("The specified WoW Classic Directory is not valid. Only valid WoW Classic Directory can be used. Use the old specified \"" + Settings.GetWowDirectory(WowVersionEnum.Vanilla) + "\"?", "Not valid Wow Directory", MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.No) { c_txtWowDirectory.ForeColor = Color.Red; } else//if (dialogResult == System.Windows.Forms.DialogResult.Yes) { c_txtWowDirectory.Text = Settings.GetWowDirectory(WowVersionEnum.Vanilla); } return; } else { if (c_txtWowDirectory.Text.EndsWith("\\") == false && c_txtWowDirectory.Text.EndsWith("/") == false) { c_txtWowDirectory.Text = c_txtWowDirectory.Text + "\\"; } Settings.Instance._WowDirectory = c_txtWowDirectory.Text; } if (c_cbxEnableTBC.Checked == true) { if (WowUtility.IsValidWowDirectory(c_txtTBCWowDirectory.Text) == false) { if (Settings.HaveTBC == true) { var dialogResult = Utility.MessageBoxShow("The specified WoW The Burning Crusade Directory is not valid. Only valid WoW TBC Directory can be used. Use the old specified \"" + Settings.GetWowDirectory(WowVersionEnum.TBC) + "\"?", "Not valid Wow Directory", MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.No) { c_txtTBCWowDirectory.ForeColor = Color.Red; } else//if (dialogResult == System.Windows.Forms.DialogResult.Yes) { c_txtTBCWowDirectory.Text = Settings.GetWowDirectory(WowVersionEnum.TBC); } return; } else { var dialogResult = Utility.MessageBoxShow("The specified WoW The Burning Crusade Directory is not valid. Only valid WoW TBC Directory can be used. Disable the use of WoW TBC Directory?", "Not valid Wow Directory", MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.No) { c_txtTBCWowDirectory.ForeColor = Color.Red; } else//if (dialogResult == System.Windows.Forms.DialogResult.Yes) { c_txtTBCWowDirectory.ForeColor = Color.Black; c_cbxEnableTBC.Checked = false; c_txtTBCWowDirectory.Text = ""; } return; } } else { if (c_txtTBCWowDirectory.Text.EndsWith("\\") == false && c_txtTBCWowDirectory.Text.EndsWith("/") == false) { c_txtTBCWowDirectory.Text = c_txtTBCWowDirectory.Text + "\\"; } Settings.Instance._WowTBCDirectory = c_txtTBCWowDirectory.Text; } } else { Settings.Instance._WowTBCDirectory = ""; } Settings.Instance.RunWoWNotAdmin = c_cbxRunNotAdmin.Checked; Settings.Instance.AutoHideOldNews = c_cbxAutoHide.Checked; Settings.Instance.AutoUpdateVFAddons = c_cbAutoUpdateVF.Checked; //Settings.Instance.UseWoWNoDelay = c_cbxWoWNoDelay.Checked; Settings.Instance.AutoRefreshNews = c_cbAutoRefresh.Checked; Settings.Instance.NewsSources_Feenix = c_cbxFeenixNews.Checked; Settings.Instance.NewsSources_Nostalrius = c_cbxNostalriusNews.Checked; Settings.Instance.NewsSources_Kronos = c_cbxKronosNews.Checked; if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true) { Settings.Instance.ContributeRealmPlayers = c_cbContributeRealmPlayers.Checked; Settings.Instance.ContributeRaidStats = c_cbContributeRaidStats.Checked; Settings.Instance.Wait5SecondsAfterUpload = c_cbxWait5Seconds.Checked; } Close(); }
static void Main(string[] args) { g_LauncherApp = new WoWLauncherApp(); g_LauncherApp.InitiateMessageIDs(); try { try { StaticValues.StartupArguments = new CMDArguments(args); if (StaticValues.StartupArguments["RealmPlayersUploader"] != null) // /RealmPlayersUploader { Settings.Initialize(); ConsoleUtility.CreateConsole(); bool anyProblem = false; if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true) { bool sentAll = true; if (Settings.HaveClassic == true) { if (Settings.Instance.ContributeRealmPlayers == true) { Logger.ConsoleWriteLine("Starting to send VF_RealmPlayers Files", ConsoleColor.White); var sentRealmPlayersFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RealmPlayers", WowVersionEnum.Vanilla, "VF_RealmPlayersData", 50, out sentAll); foreach (var file in sentRealmPlayersFiles) { Logger.ConsoleWriteLine("Sent VF_RealmPlayers File \"" + file + "\"", ConsoleColor.Green); } if (sentAll == true) { InstalledAddons.ModifyInstalledAddon("VF_RealmPlayers", WowVersionEnum.Vanilla, "VF_RP_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\""); } else { anyProblem = true; } } if (Settings.Instance.ContributeRaidStats == true) { if (InstalledAddons.GetAddonInfo("VF_RaidStats", WowVersionEnum.Vanilla) != null) { Logger.ConsoleWriteLine("Starting to send VF_RaidStats Files", ConsoleColor.White); var sentRaidStatsFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RaidStats", WowVersionEnum.Vanilla, "VF_RaidStatsData", 5000, out sentAll); foreach (var file in sentRaidStatsFiles) { Logger.ConsoleWriteLine("Sent VF_RaidStats File \"" + file + "\"", ConsoleColor.Cyan); } if (sentAll == true) { InstalledAddons.ModifyInstalledAddon("VF_RaidStats", WowVersionEnum.Vanilla, "VF_RS_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\""); } else { anyProblem = true; } } else { Logger.ConsoleWriteLine("Starting to send VF_RaidDamage Files", ConsoleColor.White); var sentRaidDamageFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RaidDamage", WowVersionEnum.Vanilla, "VF_RaidDamageData", 5000, out sentAll); foreach (var file in sentRaidDamageFiles) { Logger.ConsoleWriteLine("Sent VF_RaidDamage File \"" + file + "\"", ConsoleColor.Cyan); } if (sentAll == true) { InstalledAddons.ModifyInstalledAddon("VF_RaidDamage", WowVersionEnum.Vanilla, "VF_RD_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\""); } else { anyProblem = true; } } } } if (Settings.HaveTBC == true) { if (Settings.Instance.ContributeRealmPlayers == true) { Logger.ConsoleWriteLine("Starting to send VF_RealmPlayersTBC Files", ConsoleColor.White); var sentRealmPlayersTBCFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RealmPlayersTBC", WowVersionEnum.TBC, "VF_RealmPlayersData", 50, out sentAll); foreach (var file in sentRealmPlayersTBCFiles) { Logger.ConsoleWriteLine("Sent VF_RealmPlayersTBC File \"" + file + "\"", ConsoleColor.Cyan); } if (sentAll == true) { InstalledAddons.ModifyInstalledAddon("VF_RealmPlayersTBC", WowVersionEnum.TBC, "VF_RP_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\""); } else { anyProblem = true; } } if (Settings.Instance.ContributeRaidStats == true) { Logger.ConsoleWriteLine("Starting to send VF_RaidStatsTBC Files", ConsoleColor.White); var sentRaidStatsTBCFiles = ServerComm.SendAddonData(Settings.UserID, "VF_RaidStatsTBC", WowVersionEnum.TBC, "VF_RaidStatsData", 5000, out sentAll); foreach (var file in sentRaidStatsTBCFiles) { Logger.ConsoleWriteLine("Sent VF_RaidStatsTBC File \"" + file + "\"", ConsoleColor.Cyan); } if (sentAll == true) { InstalledAddons.ModifyInstalledAddon("VF_RaidStatsTBC", WowVersionEnum.TBC, "VF_RS_LastUploadedData", "\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\""); } else { anyProblem = true; } } } ServerComm.SendAddonData_Dispose(); } else { anyProblem = true; Logger.ConsoleWriteLine("UserID: " + Settings.UserID + " was not a valid UserID!"); } if (anyProblem == true) { Logger.ConsoleWriteLine("Due to uploading problems, the window is closing in 10 seconds! Feel free to manually close it earlier. If this happens often and annoys you, please take a screenshot and make a thread on the realmplayers forum", ConsoleColor.White); System.Threading.Thread.Sleep(10000); } else { if (Settings.Instance.Wait5SecondsAfterUpload == true) { Logger.ConsoleWriteLine("Closing in 5 seconds!", ConsoleColor.White); System.Threading.Thread.Sleep(5000); } } return; } else if (StaticValues.StartupArguments["LaunchWow"] != null) { Settings.Initialize(); ConsoleUtility.CreateConsole(); string useRealm = StaticValues.StartupArguments["LaunchWow"]; string useConfigProfile = "Active Wow Config"; if (StaticValues.StartupArguments["ConfigProfile"] != null) { useConfigProfile = StaticValues.StartupArguments["ConfigProfile"]; } System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); if (Settings.Instance.RealmLists.ContainsKey(useRealm) == false) { return; } var realmInfo = Settings.Instance.RealmLists[useRealm]; if (realmInfo.WowVersion == WowVersionEnum.TBC) { useConfigProfile = "Active Wow Config"; if (Settings.Instance.ClearWDB == true) { Utility.DeleteDirectory(Settings.GetWowDirectory(realmInfo.WowVersion) + "Cache"); } } else { if (Settings.Instance.ClearWDB == true) { Utility.DeleteDirectory(Settings.GetWowDirectory(realmInfo.WowVersion) + "WDB"); } } if (RealmPlayersUploader.IsValidUserID(Settings.UserID) == true) { if (System.IO.File.Exists(StaticValues.LauncherToolsDirectory + "RunWowAndUploader.bat") == false || System.IO.File.ReadAllText(StaticValues.LauncherToolsDirectory + "RunWowAndUploader.bat") != StaticValues.RunWowAndUploaderBatFileData) { Utility.AssertDirectory(StaticValues.LauncherToolsDirectory); System.IO.File.WriteAllText(StaticValues.LauncherToolsDirectory + "RunWowAndUploader.bat", StaticValues.RunWowAndUploaderBatFileData); } if (Settings.Instance.RunWoWNotAdmin == false) { //startInfo.FileName = Settings.WowDirectory + "WoW.exe"; //startInfo.WorkingDirectory = Settings.WowDirectory; startInfo.FileName = StaticValues.LauncherToolsDirectory + "RunWowAndUploader.bat"; //startInfo.FileName = Settings.WowDirectory + "22VF_RealmPlayersUploader 1.5\\RunWoWAndUploaderNoCMDWindow.vbs"; //startInfo.WorkingDirectory = Settings.WowDirectory + "22VF_RealmPlayersUploader 1.5\\"; startInfo.Arguments = "\"" + Settings.GetWowDirectory(realmInfo.WowVersion) + "\""; } else { string slash = "\\\\"; string snuff = "\\\""; startInfo.FileName = StaticValues.LauncherToolsDirectory + "NotAdmin.exe"; startInfo.Arguments = "\"cmd.exe\" \".\\\\\" " + "\"/c " + snuff + snuff + StaticValues.LauncherWorkDirectory.Replace("\\", slash) + "/" + StaticValues.LauncherToolsDirectory.Replace("\\", slash) + "RunWowAndUploader.bat" + snuff + " " + snuff + Settings.GetWowDirectory(realmInfo.WowVersion) + "\\" + snuff + snuff + "\" nowindow"; } startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = false; startInfo.CreateNoWindow = true; } else { startInfo.FileName = Settings.GetWowDirectory(realmInfo.WowVersion) + "WoW.exe"; startInfo.WorkingDirectory = Settings.GetWowDirectory(realmInfo.WowVersion); } Logger.ConsoleWriteLine("Starting to Launch WoW for realm: \"" + useRealm + "\", with ConfigProfile: \"" + useConfigProfile + "\"", ConsoleColor.Green); LaunchFunctions.LaunchWow(useConfigProfile, useRealm, startInfo); Logger.ConsoleWriteLine("Done with Launching WoW! Closing console window in 5 seconds!", ConsoleColor.White); System.Threading.Thread.Sleep(5000); return; } g_AppMutex = new Mutex(true, "Local\\VF_WoWLauncher"); if (g_AppMutex == null || g_AppMutex.WaitOne(TimeSpan.Zero, true)) { Settings.Initialize(); if (Settings.DebugMode) { //ConsoleUtility.CreateConsole(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var launcherWindow = new LauncherWindow(); g_LauncherApp.HandleJumpListCommands(launcherWindow, StaticValues.StartupArguments); Application.Run(launcherWindow); if (g_AppMutex != null) { ForumReader.SaveForumSections(); Settings.Save(); ReleaseAppMutex(); } } else { g_AppMutex = null; g_LauncherApp.HandleJumpListCommands(null, StaticValues.StartupArguments); } } catch (Exception ex) { ReleaseAppMutex(); Utility.MessageBoxShow("Exception occured! Please printscreen this message and send to Dilatazu @ realmplayers forums:\r\n" + ex.ToString()); ConsoleUtility.CreateConsole(); Logger.LogException(ex); Logger.ConsoleWriteLine("Closing in 10 seconds!", ConsoleColor.White); System.Threading.Thread.Sleep(10000); } } catch (Exception ex) { ReleaseAppMutex(); Utility.MessageBoxShow("Very unexpected Exception occured! Please printscreen this message and send to Dilatazu @ realmplayers forums:\r\n" + ex.ToString()); } ReleaseAppMutex(); }
bool ValidateUserID(string _UserID) { if (_UserID.Contains("Unknown.123456") || _UserID == "") { Utility.MessageBoxShow("You must fill in the correct UserID"); return(false); } if (RealmPlayersUploader.IsValidUserID(c_txtUserID.Text) == false) { Utility.MessageBoxShow("UserID is not valid format, must be <name(a-z)>.<number> example of valid UserID: Unknown.123456"); return(false); } if (char.IsUpper(c_txtUserID.Text[0]) == false || c_txtUserID.Text.Last((char _Char) => char.IsUpper(_Char)) == c_txtUserID.Text[0]) { Utility.MessageBoxShow("UserID have to start with capital letter and not contain any other capital letters in the UserName section!"); return(false); } Socket tcpSocket = null; try { DateTime startConnectionTime = DateTime.Now; tcpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var ipAddress = System.Net.Dns.GetHostEntry(ServerComm.g_Host).AddressList[0]; IAsyncResult ar = tcpSocket.BeginConnect(ipAddress, 18374, null, null); System.Threading.WaitHandle waitHandle = ar.AsyncWaitHandle; try { for (int t = 0; t < 5; ++t) { if (waitHandle.WaitOne(TimeSpan.FromSeconds(1), false)) { break; } Application.DoEvents(); //Console.Write("."); } Console.Write("\r\n"); if (!waitHandle.WaitOne(TimeSpan.FromSeconds(1), false)) { tcpSocket.Close(); Utility.SoftThreadSleep(1000); waitHandle.Close(); Utility.MessageBoxShow("Could not validate UserID because connection to server failed, try again later."); return(false); } tcpSocket.EndConnect(ar); } finally { waitHandle.Close(); } tcpSocket.ReceiveTimeout = 5000; tcpSocket.SendTimeout = 5000; byte[] bytes = System.Text.Encoding.UTF8.GetBytes("NullNullNullNullNullNullNullNull"); byte[] header = System.Text.Encoding.UTF8.GetBytes("Command=UserCheck;UserID=" + _UserID + ";FileSize=" + bytes.Length + "%"); tcpSocket.Send(header); tcpSocket.Send(bytes); tcpSocket.Shutdown(SocketShutdown.Send); Byte[] readBuffer = new Byte[1024]; int i = 0; string data = ""; while ((i = tcpSocket.Receive(readBuffer, readBuffer.Length, SocketFlags.None)) != 0) { data += System.Text.Encoding.UTF8.GetString(readBuffer, 0, i); if ((DateTime.Now - startConnectionTime).TotalSeconds > 10) { throw new Exception("Transfer took longer than 10 seconds, should not be allowed, canceling"); } } bool wasSuccess = false; if (data.Contains(";") && data.Contains("=")) { string[] dataSplit = data.Split(';'); foreach (string currDataSplit in dataSplit) { if (currDataSplit.Contains("=")) { string[] currValue = currDataSplit.Split('='); if (currValue[0] == "VF_RPP_Success") { wasSuccess = ConvertBool(currValue[1]); } else if (currValue[0] == "Message") { Utility.MessageBoxShow(currValue[1]); } } } } if (wasSuccess == true) { Utility.MessageBoxShow("The UserID \"" + _UserID + "\" was valid and is now in use! The program will now start upload your inspected database automatically everytime you close wow(if started using the WowLauncher)."); return(true); } else { Utility.MessageBoxShow("The UserID \"" + _UserID + "\" is not valid. Please enter the correct UserID that was given to you."); } } catch (Exception ex) { Utility.MessageBoxShow("Could not validate UserID because of a connection error. Printscreen this message and PM to Dilatazu @ realmplayers forums or try again later.\r\nException:\r\n" + ex.ToString()); } return(false); }