private async Task OnDiscoResponseMessage(DiscoResponseMessage disco, CheckDiscoFeaturesAsync action, string discoTarget) { // Print a list of all supported features: if (Logger.logLevel >= LogLevel.DEBUG) { StringBuilder sb = new StringBuilder("The server for '"); sb.Append(CONNECTION.account.getBareJid()); sb.Append("' supports the following features:\n"); foreach (string s in disco.FEATURES.Select(x => x.VAR)) { sb.Append(s); sb.Append("\n"); } Logger.Debug(sb.ToString()); } switch (disco.DISCO_TYPE) { case DiscoType.ITEMS: break; case DiscoType.INFO: await action(disco.FEATURES, discoTarget); break; default: break; } }
private async Task CheckDiscoFeaturesDomainPartAsync(DiscoResponseMessage disco, string discoTarget) { AddFeaturesForTarget(disco.FEATURES, discoTarget); DicoFeaturesDicovered?.Invoke(this, new DicoFeaturesDicoveredEventArgs(DISCO_INFO_RESULT[discoTarget], discoTarget)); if (CONNECTION.account.connectionConfiguration.disableMessageCarbons) { CONNECTION.account.CONNECTION_INFO.msgCarbonsState = MessageCarbonsState.DISABLED; Logger.Info("No need to enable message carbons for '" + CONNECTION.account.getBareJid() + "' - message carbons are disabled."); return; } // Check if the server supports 'XEP-0280: Message Carbons': bool supportsCarbons = HasFeature(Consts.XML_XEP_0280_NAMESPACE, discoTarget); if (supportsCarbons) { await CONNECTION.EnableMessageCarbonsAsync(); } else { CONNECTION.account.CONNECTION_INFO.msgCarbonsState = MessageCarbonsState.NOT_SUPPORTED; Logger.Warn("Unable to enable message carbons for '" + CONNECTION.account.getBareJid() + "' - not supported by the server."); } }
private void showResultDisco(DiscoResponseMessage disco) { rooms.Clear(); messageResponseHelper?.Dispose(); messageResponseHelper = null; if (disco == null || disco.ITEMS == null || disco.ITEMS.Count <= 0) { // Show non found in app notification: noneFound_notification.Show("None found. Please retry!"); } else { foreach (DiscoItem i in disco.ITEMS) { rooms.Add(new MUCRoomTemplate() { client = Client, roomInfo = new MUCRoomInfo() { jid = i.JID ?? "", name = i.NAME ?? (i.JID ?? "") } }); } } loading_grid.Visibility = Visibility.Collapsed; main_grid.Visibility = Visibility.Visible; }
private void showResultDisco(DiscoResponseMessage disco) { rooms.Clear(); messageResponseHelper?.Dispose(); messageResponseHelper = null; if (disco is null || disco.ITEMS is null || disco.ITEMS.Count <= 0) { // Show non found in app notification: noneFound_notification.Show("None found. Please retry!"); }
private async Task OnDiscoResponseMessage(DiscoResponseMessage disco, CheckDiscoResponseAsync action, string discoTarget) { // Print a list of all supported features: if (Logger.logLevel >= LogLevel.DEBUG) { StringBuilder sb = new StringBuilder("Disco#"); sb.Append(disco.DISCO_TYPE); sb.Append(" for '"); sb.Append(CONNECTION.account.getBareJid()); if (disco.DISCO_TYPE == DiscoType.INFO) { sb.Append("' reported the following features:\n"); foreach (string s in disco.FEATURES.Select(x => x.VAR)) { sb.Append(s); sb.Append("\n"); } } else { sb.Append("' reported the following items:\n"); foreach (DiscoItem i in disco.ITEMS) { sb.Append(i.JID); if (!string.IsNullOrEmpty(i.NODE)) { sb.Append(" -> "); sb.Append(i.NODE); } if (!string.IsNullOrEmpty(i.NAME)) { sb.Append($" ({i.NAME})"); } sb.Append("\n"); } } Logger.Debug(sb.ToString()); } await action(disco, discoTarget); }
private void showDiscoResult(DiscoResponseMessage disco) { loading_spnl.Visibility = Visibility.Collapsed; if (disco.ERROR_RESULT != null) { items_icon.Visibility = Visibility.Collapsed; if (disco.DISCO_TYPE == DiscoType.UNKNOWN) { noneFound_tblck.Text = "Server responded with an invalid answer! View the logs for more information."; } else { noneFound_tblck.Text = "Server responded with an error of type: " + disco.ERROR_RESULT.TYPE + "\n and content:\n" + disco.ERROR_RESULT.CONTENT; } noneFound_tblck.Visibility = Visibility.Visible; } else { foreach (DiscoFeature f in disco.FEATURES) { if (!string.IsNullOrWhiteSpace(f.VAR)) { SERVER_FEATURES.Add(new ServerFeaturesTemplate() { name = f.VAR }); } } foreach (DiscoItem i in disco.ITEMS) { if (!string.IsNullOrWhiteSpace(i.JID)) { SERVER_FEATURES.Add(new ServerFeaturesTemplate() { name = i.NAME ?? i.JID }); } } items_icon.Visibility = Visibility.Visible; } }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously private async Task CheckDiscoFeaturesBareJidAsync(DiscoResponseMessage disco, string discoTarget) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { AddFeaturesForTarget(disco.FEATURES, discoTarget); DicoFeaturesDicovered?.Invoke(this, new DicoFeaturesDicoveredEventArgs(DISCO_INFO_RESULT[discoTarget], discoTarget)); }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously private async Task CheckDiscoItemsAsync(DiscoResponseMessage disco, string discoTarget) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { DISCO_ITEM_RESULT[discoTarget] = disco.ITEMS; Logger.Info($"Disco items for '{discoTarget}' updated."); }
private void showResultDisco(DiscoResponseMessage disco) { loading_spnl.Visibility = Visibility.Collapsed; if (disco == null) { items_icon.Visibility = Visibility.Collapsed; noneFound_tblck.Text = "Server didn't answer in time!"; noneFound_tblck.Visibility = Visibility.Visible; } else if (discoItemsId == null && discoInfosId == null) { if (featuresList.Count <= 0) { items_icon.Visibility = Visibility.Collapsed; noneFound_tblck.Text = "None"; noneFound_tblck.Visibility = Visibility.Visible; } } else if (disco.ERROR_RESULT != null) { items_icon.Visibility = Visibility.Collapsed; if (disco.DISCO_TYPE == DiscoType.UNKNOWN) { noneFound_tblck.Text = "Server responded with an invalid answer! View the logs for more information."; } else { noneFound_tblck.Text = "Server responded with an error of type: " + disco.ERROR_RESULT.TYPE + "\n and content:\n" + disco.ERROR_RESULT.CONTENT; } noneFound_tblck.Visibility = Visibility.Visible; } else { foreach (DiscoFeature f in disco.FEATURES) { if (!string.IsNullOrWhiteSpace(f.VAR)) { featuresList.Add(new ServerFeaturesTemplate() { name = f.VAR }); } } foreach (DiscoItem i in disco.ITEMS) { if (!string.IsNullOrWhiteSpace(i.JID)) { featuresList.Add(new ServerFeaturesTemplate() { name = i.NAME ?? i.JID }); } } items_icon.Visibility = Visibility.Visible; switch (disco.DISCO_TYPE) { case DiscoType.ITEMS: discoItemsId = null; break; case DiscoType.INFO: discoInfosId = null; break; } } }
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\ #region --Constructors-- /// <summary> /// Basic Constructor /// </summary> /// <history> /// 28/11/2017 Created [Fabian Sauter] /// </history> public NewDiscoResponseMessageEventArgs(DiscoResponseMessage disco) { this.DISCO = disco; }