private void PSNLogin_FormClosing(object sender, FormClosingEventArgs e) { if (IniModel.GetPSNRefreshToken() == null) { Environment.Exit(-1); } }
public void RunPsnTask(Func <ArrayList, bool> callback) { if (PsnTask == null || PsnTask.Status == TaskStatus.RanToCompletion) { InitializePsnTask(); } else if (PsnTask.Status == TaskStatus.Running) { return; } PsnTask.ContinueWith((task) => { if (task.IsCanceled || task.IsFaulted) { PsnTaskTokenSource.Cancel(); return; } if (errorCount >= 3) { if (Network.CheckForInternetConnection()) { String[] TokenData = Platforms.PSN.AuthWithRefreshToken(IniModel.GetPSNRefreshToken()); if (TokenData[0] == null) { PsnTaskTokenSource.Cancel(); MessageBox.Show("An unknown error has occurred. Please try again later.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } Program.AccessToken = TokenData[0]; errorCount = 0; } else { PsnTaskTokenSource.Cancel(); MessageBox.Show("An unknown error has occurred. Please try again later.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } callback(lastActivityData); }); //PsnTaskTokenSource.Cancel(); PsnTask.Start(); }
private void Loader_Shown(object sender, EventArgs e) { this.Visible = false; updater.run(); String AccessToken = null; String PSNRefreshToken = IniModel.GetPSNRefreshToken(); if (PSNRefreshToken == null) { this.Hide(); PSN login = new PSN(); login.ShowDialog(); PSNRefreshToken = IniModel.GetPSNRefreshToken(); } try { AccessToken = Platforms.PSN.AuthWithRefreshToken(PSNRefreshToken)[0]; } catch (Exception) { MessageBox.Show("Unable to connect PlayStation Network.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(-1); } if (IniModel.GetSteamUsername() != null && IniModel.GetSteamLoginKey() != null) { Program.steam.manager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn); Program.steam.manager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected); Program.steam.Connect(IniModel.GetSteamUsername(), null); } /*else * { * this.Hide(); * SteamLogin steamLogin = new SteamLogin(); * steamLogin.ShowDialog(); * }*/ Program.AccessToken = AccessToken; this.Hide(); OnPS OnPSClient = new OnPS(); OnPSClient.ShowDialog(); }