void client_Error(object sender, XmppErrorEventArgs e) { string uiMessage; switch (e.Type) { case XmppErrorType.SocketError: uiMessage = "Unable to contact server. "; break; case XmppErrorType.AuthUserNotAuthorized: uiMessage = "Unauthorized. Probably the username and password you entered are incorrect. "; break; case XmppErrorType.AuthModeNotSupported: uiMessage = "Unable to authenticate: no methods available. "; break; case XmppErrorType.ClientNotConnected: uiMessage = "Hey you're not connected :-( "; break; case XmppErrorType.RecvTooManyInvalidStream: uiMessage = "Ouch ouch ouch stream was messed up :-( "; break; case XmppErrorType.ConnectionClosedByServer: uiMessage = "Ouch ouch ouch server closed stream, end of games :-( "; break; case XmppErrorType.SocketStartSSLError: uiMessage = "Ouch ouch ouch SSL was messed up :-( "; break; case XmppErrorType.XmppStreamError: uiMessage = "Ohu nooo I've received a stream error for you :-( "; break; default: uiMessage = "Unknown error :-( Something has happened ... "; break; } if (!string.IsNullOrWhiteSpace(e.ErrorDescriptor)) { uiMessage += Environment.NewLine + Environment.NewLine + e.ErrorDescriptor; } if (!string.IsNullOrWhiteSpace(e.Message)) { uiMessage += Environment.NewLine + Environment.NewLine + e.Message; } DialogUtils.ShowError(this, uiMessage); Disconnect(); }
private async void CheckForUpdate() { try { IsUpdateAvailable = await UpdateUtil.IsUpdateAvailable(); } catch (Exception exception) { IsUpdateAvailable = false; string errorMessage = "Failed to check for updates. If this error persists, please check " + "https://github.com/matortheeternal/mod-analyzer/releases for updates.\n\n" + exception.ToString(); DialogUtils.ShowError("Update check failed", errorMessage); } }
private void AvatarImg_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { XmppVCard vCard = UserSetting.VCard; if (Guard.AlertIfNull(vCard, this, "Unable to set avatar now, vCard not retrieved yet from the server. If the problem persists, the server may not support this feature.")) { return; } string fileName = DialogUtils.SelectFileToOpen("All Avatar types (*.jpg,*.jpeg,*.gif,*.png)|*.jpg;*.jpeg;*.gif;*.png", null); if (string.IsNullOrWhiteSpace(fileName)) { return; } string hash = null; try { Avatar.GenerateFromFile(fileName, out hash); vCard.PhotoType = "image/png"; vCard.PhotoBinVal = Avatar.GetData(hash); } catch (Exception ex) { DialogUtils.ShowException(this, "Unable to set avatar :-( Internal error.", ex); return; } Log("avatar updating"); int id = client.SendVCardUpdate(vCard); Signals.Register(id, (par) => { if (par.Type == XmppIqType.Result) { UpdateAvatar(hash); Log("avatar updated"); } else if (par.Type == XmppIqType.Error) { DialogUtils.ShowError(this, string.Format("Unable to set avatar :-( Server error, be sad! {0} {0} {1}", Environment.NewLine, ParseStreamError(par.xStream))); } }); }
public static void LoadSettings() { if (File.Exists("settings.json")) { LogService.GroupMessage("settings", "Found settings file."); try { string json = File.ReadAllText("settings.json"); Settings = JsonConvert.DeserializeObject <ProgramSetting>(json); } catch (Exception x) { LogService.GroupMessage("settings", "Exception loading settings: " + x.Message); DialogUtils.ShowError(x.Message, "Exception loading settings"); DefaultSettings(); } } else { LogService.GroupMessage("settings", "No settings file found, initializing defaults."); NewSettings = true; DefaultSettings(); } }