diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9961c47..2316b11c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,7 +68,7 @@ jobs: - name: Build App id: create_app_package - uses: .\repo\.github\workflows\actions\app-build + uses: ./repo/.github/workflows/actions/app-build with: build_configuration: 'debug' output_directory: '${{env.BuildDirectory}}' diff --git a/.sonarlint/OpenHAB.Windows.slconfig b/.sonarlint/OpenHAB.Windows.slconfig new file mode 100644 index 00000000..704efb31 --- /dev/null +++ b/.sonarlint/OpenHAB.Windows.slconfig @@ -0,0 +1,15 @@ +{ + "ServerUri": "https://sonarcloud.io/", + "Organization": { + "Key": "openhab", + "Name": "openHAB" + }, + "ProjectKey": "openhab_openhab-windows", + "ProjectName": "openhab-windows", + "Profiles": { + "CSharp": { + "ProfileKey": "AXflIL33YGfeNt47qUY1", + "ProfileTimestamp": "2021-11-22T10:44:23Z" + } + } +} \ No newline at end of file diff --git a/.sonarlint/openhab_openhab-windows/CSharp/SonarLint.xml b/.sonarlint/openhab_openhab-windows/CSharp/SonarLint.xml new file mode 100644 index 00000000..90bc98df --- /dev/null +++ b/.sonarlint/openhab_openhab-windows/CSharp/SonarLint.xml @@ -0,0 +1,89 @@ + + + + + sonar.cs.analyzeGeneratedCode + false + + + sonar.cs.file.suffixes + .cs + + + sonar.cs.ignoreHeaderComments + true + + + sonar.cs.roslyn.ignoreIssues + false + + + + + S107 + + + max + 7 + + + + + S110 + + + max + 5 + + + + + S1479 + + + maximum + 30 + + + + + S2342 + + + flagsAttributeFormat + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ + + + format + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ + + + + + S2436 + + + max + 2 + + + maxMethod + 3 + + + + + S3776 + + + propertyThreshold + 3 + + + threshold + 15 + + + + + \ No newline at end of file diff --git a/.sonarlint/openhab_openhab-windowscsharp.ruleset b/.sonarlint/openhab_openhab-windowscsharp.ruleset new file mode 100644 index 00000000..79df8173 --- /dev/null +++ b/.sonarlint/openhab_openhab-windowscsharp.ruleset @@ -0,0 +1,370 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/openHAB.Core/Messages/ConnectionStatusChanged.cs b/src/openHAB.Core/Messages/ConnectionStatusChanged.cs new file mode 100644 index 00000000..43775079 --- /dev/null +++ b/src/openHAB.Core/Messages/ConnectionStatusChanged.cs @@ -0,0 +1,25 @@ +using OpenHAB.Core.Common; +using OpenHAB.Core.Model; + +namespace OpenHAB.Core.Messages +{ + /// + /// Event for connection state updates. + /// + public class ConnectionStatusChanged + { + /// Initializes a new instance of the class. + /// The connection state. + public ConnectionStatusChanged(ConnectionState state) + { + State = state; + } + + /// Gets or sets the state. + /// The state. + public ConnectionState State + { + get; set; + } + } +} diff --git a/src/openHAB.Core/Model/OpenHABUrlState.cs b/src/openHAB.Core/Model/ConnectionState.cs similarity index 83% rename from src/openHAB.Core/Model/OpenHABUrlState.cs rename to src/openHAB.Core/Model/ConnectionState.cs index 9d5050d7..b3a07a46 100644 --- a/src/openHAB.Core/Model/OpenHABUrlState.cs +++ b/src/openHAB.Core/Model/ConnectionState.cs @@ -1,9 +1,9 @@ namespace OpenHAB.Core.Model { /// - /// Reflects the State for an url check. + /// Reflects the State for an connection. /// - public enum OpenHABUrlState + public enum ConnectionState { /// /// OpenHAB instance is reachable via url diff --git a/src/openHAB.Core/Model/OpenHABItem.cs b/src/openHAB.Core/Model/OpenHABItem.cs index 3b1c0a1d..cbf47601 100644 --- a/src/openHAB.Core/Model/OpenHABItem.cs +++ b/src/openHAB.Core/Model/OpenHABItem.cs @@ -1,8 +1,9 @@ +using System; using System.Globalization; using System.Text.RegularExpressions; using System.Xml.Linq; -using GalaSoft.MvvmLight; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Toolkit.Uwp.Helpers; using Newtonsoft.Json; using OpenHAB.Core.Messages; @@ -47,19 +48,16 @@ public string Type get => _type; set { - if (value != null) + if (value != null && value.Contains(":", System.StringComparison.OrdinalIgnoreCase) && _state != null) { - if (value.Contains(":", System.StringComparison.OrdinalIgnoreCase) && _state != null) + int spaceIndex = _state.LastIndexOf(' '); + if (spaceIndex > 0) { - int spaceIndex = _state.LastIndexOf(' '); - if (spaceIndex > 0) - { - Unit = _state.Substring(spaceIndex, _state.Length - spaceIndex); - } + Unit = _state.Substring(spaceIndex, _state.Length - spaceIndex); } } - Set(ref _type, value); + SetProperty(ref _type, value); } } @@ -79,16 +77,13 @@ public string State get => _state; set { - if ((_type != null) && (Unit == null)) + if ((_type != null) && (Unit == null) && _type.Contains(":", System.StringComparison.OrdinalIgnoreCase) && value != null && value.Contains(" ")) { - if (_type.Contains(":", System.StringComparison.OrdinalIgnoreCase) && value != null && value.Contains(" ")) - { - int spaceIndex = value.LastIndexOf(' '); - Unit = value.Substring(spaceIndex, value.Length - spaceIndex); - } + int spaceIndex = value.LastIndexOf(' '); + Unit = value.Substring(spaceIndex, value.Length - spaceIndex); } - Set(ref _state, value); + SetProperty(ref _state, value); } } @@ -122,10 +117,10 @@ public OpenHABCommandDescription CommandDescription /// public OpenHABItem() { - Messenger.Default.Register(this, HandleUpdateItemMessage); + StrongReferenceMessenger.Default.Register(this, HandleUpdateItemMessage); } - private void HandleUpdateItemMessage(UpdateItemMessage message) + private void HandleUpdateItemMessage(object recipient, UpdateItemMessage message) { if (message.ItemName != Name) { @@ -183,7 +178,7 @@ public void UpdateValue(object value) if (value != null) { string newValue = value.ToString() + this.Unit; - Messenger.Default.Send(new TriggerCommandMessage(this, newValue)); + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(this, newValue)); _state = newValue; } } diff --git a/src/openHAB.Core/Model/OpenHABWidgetFactory.cs b/src/openHAB.Core/Model/OpenHABWidgetFactory.cs deleted file mode 100644 index fc8ba452..00000000 --- a/src/openHAB.Core/Model/OpenHABWidgetFactory.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using System.Xml.Linq; -using Newtonsoft.Json; - -namespace OpenHAB.Core.Model -{ - /// - /// Factory class for OpenHAB widgets. - /// - public class OpenHABWidgetFactory - { - public static OpenHABWidget Parse(XElement startNode) - { - return ParseNode(startNode); - } - - private static OpenHABWidget ParseNode(XElement startNode) - { - if (!startNode.HasElements) - { - return null; - } - - OpenHABWidget widget = new OpenHABWidget() - { - WidgetId = startNode.Element("widgetId")?.Value, - Type = startNode.Element("type")?.Value, - Label = startNode.Element("label")?.Value, - State = startNode.Element("state")?.Value, - Icon = startNode.Element("icon")?.Value, - Url = startNode.Element("url")?.Value, - Children = new List(), - }; - - XElement linkedPage = startNode.Element("linkedPage"); - if (linkedPage != null) - { - ParseLinkedPage(linkedPage, widget); - } - - ParseItem(startNode.Element("item"), widget); - ParseChildren(startNode, widget); - ParseMappings(startNode, widget); - - return widget; - } - - private static void ParseMappings(XElement startNode, OpenHABWidget widget) - { - widget.Mappings = new List(); - - foreach (XElement childNode in startNode.Elements("mapping")) - { - string command = childNode.Element("command")?.Value; - string label = childNode.Element("label")?.Value; - widget.Mappings.Add(new OpenHABWidgetMapping(command, label)); - } - } - - private static void ParseLinkedPage(XElement linkedPage, OpenHABWidget parentWidget) - { - parentWidget.LinkedPage = new OpenHABSitemap(linkedPage) { Widgets = new List() }; - foreach (XElement childNode in linkedPage.Elements("widget")) - { - var widget = Parse(childNode); - widget.Parent = parentWidget; - widget.LinkedPage.Widgets.Add(widget); - } - } - - private static void ParseChildren(XElement startNode, OpenHABWidget parentWidget) - { - foreach (XElement childNode in startNode.Elements("widget")) - { - var widget = Parse(childNode); - widget.Parent = parentWidget; - widget.Children.Add(widget); - - XElement linkedPage = childNode.Element("linkedPage"); - - if (linkedPage != null) - { - ParseLinkedPage(linkedPage, widget); - } - } - } - - private static void ParseItem(XElement element, OpenHABWidget widget) - { - if (element == null) - { - return; - } - - widget.Item = new OpenHABItem(element); - } - } -} diff --git a/src/openHAB.Core/Model/ServerInfo.cs b/src/openHAB.Core/Model/ServerInfo.cs new file mode 100644 index 00000000..33562ba8 --- /dev/null +++ b/src/openHAB.Core/Model/ServerInfo.cs @@ -0,0 +1,18 @@ +namespace OpenHAB.Core.Model +{ + /// Information about openHAB server. + public class ServerInfo + { + /// Gets the openHAB major version. + /// The version. + public OpenHABVersion Version { get; internal set; } + + /// Gets the build. + /// The build. + public string Build { get; internal set; } + + /// Gets the runtime version. + /// The runtime version. + public string RuntimeVersion { get; internal set; } + } +} \ No newline at end of file diff --git a/src/openHAB.Core/Openhab.Core.csproj b/src/openHAB.Core/Openhab.Core.csproj index cb68cc2f..688edd88 100644 --- a/src/openHAB.Core/Openhab.Core.csproj +++ b/src/openHAB.Core/Openhab.Core.csproj @@ -28,8 +28,7 @@ x86 false prompt - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset bin\x86\Debug\OpenHAB.Core.XML @@ -42,8 +41,7 @@ x86 false prompt - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset ARM @@ -55,8 +53,7 @@ ARM false prompt - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset ARM @@ -68,8 +65,7 @@ ARM false prompt - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset x64 @@ -81,8 +77,7 @@ x64 false prompt - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset x64 @@ -94,8 +89,7 @@ x64 false prompt - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset @@ -113,6 +107,7 @@ + @@ -144,8 +139,7 @@ - - + @@ -158,6 +152,7 @@ + @@ -174,37 +169,37 @@ + + 7.1.2 + - 5.0.3 + 6.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all - 5.0.1 + 6.0.0 - 6.2.12 + 6.2.13 10.1901.28001 - 7.0.2 + 7.1.2 - 7.0.2 + 7.1.2 2.6.0-prerelease.210129001 - - 5.4.1.1 - 13.0.1 - 1.7.3 + 1.7.4 1.1.118 @@ -232,6 +227,16 @@ + + + openhab_openhab-windowscsharp.ruleset + + + + + SonarLint.xml + + 14.0 diff --git a/src/openHAB.Core/SDK/IOpenHAB.cs b/src/openHAB.Core/SDK/IOpenHAB.cs index 3080a694..d7f194d0 100644 --- a/src/openHAB.Core/SDK/IOpenHAB.cs +++ b/src/openHAB.Core/SDK/IOpenHAB.cs @@ -13,10 +13,17 @@ namespace OpenHAB.Core.SDK public interface IOpenHAB { /// - /// Is the server running OpenHAB 1 or OpenHAB 2?. + /// Gets information about the openHAB server. /// - /// Server main version of OpenHAB. - Task GetOpenHABVersion(); + /// Server information about openHAB instance. + Task> GetOpenHABServerInfo(); + + /// + /// Gets information about the openHAB server. + /// + /// Connection information. + /// Server information about openHAB instance. + Task> GetOpenHABServerInfo(OpenHABConnection connection); /// /// Gets the openHAB item by name from Server. diff --git a/src/openHAB.Core/SDK/OpenHABClient.cs b/src/openHAB.Core/SDK/OpenHABClient.cs index 0d78751c..74612028 100644 --- a/src/openHAB.Core/SDK/OpenHABClient.cs +++ b/src/openHAB.Core/SDK/OpenHABClient.cs @@ -6,7 +6,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Xml.Linq; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.Logging; using Microsoft.Toolkit.Uwp.Connectivity; using Newtonsoft.Json; @@ -68,50 +68,34 @@ public async Task> CheckUrlReachability(OpenHABConnecti connection.Url = connection.Url + "/"; } - try + OpenHABHttpClient.BaseUrl = connection.Url; + HttpResponseResult result = await GetOpenHABServerInfo(connection).ConfigureAwait(false); + if (result.Content == null) { - Settings settings = _settingsService.Load(); - var client = _openHABHttpClient.DisposableClient(connection, settings); - var result = await client.GetAsync(connection.Url + "rest").ConfigureAwait(false); - - if (!result.IsSuccessStatusCode) - { - _logger.LogError($"Http request for command failed, ErrorCode:'{result.StatusCode}'"); - } - - return new HttpResponseResult(result.IsSuccessStatusCode, result.StatusCode); + return new HttpResponseResult(false, null, result.Exception); } - catch (InvalidOperationException ex) + else { - _logger.LogError(ex, "CheckUrlReachability failed"); - - return new HttpResponseResult(false, null, ex); + return new HttpResponseResult(true, result.StatusCode); } - catch (HttpRequestException ex) - { - _logger.LogError(ex, "CheckUrlReachability failed"); + } - return new HttpResponseResult(false, null, ex); - } - catch (Exception ex) - { - _logger.LogError(ex, "CheckUrlReachability failed."); - return new HttpResponseResult(false, null, ex); - } + /// + public async Task> GetOpenHABServerInfo() + { + return await GetOpenHABServerInfo(_connection); } /// - public async Task GetOpenHABVersion() + public async Task> GetOpenHABServerInfo(OpenHABConnection connection) { try { var settings = _settingsService.Load(); - var httpClient = _openHABHttpClient.Client(_connection, settings); + var httpClient = _openHABHttpClient.DisposableClient(connection, settings); + httpClient.BaseAddress = new Uri(connection.Url); - if (httpClient == null) - { - return OpenHABVersion.None; - } + ServerInfo serverInfo = new ServerInfo(); HttpResponseMessage result = await httpClient.GetAsync(Constants.API.ServerInformation).ConfigureAwait(false); if (!result.IsSuccessStatusCode) @@ -125,7 +109,8 @@ public async Task GetOpenHABVersion() OpenHABAPIInfo apiInfo = JsonConvert.DeserializeObject(responseBody); if (apiInfo.Version < 4) { - return OpenHABVersion.Three; + serverInfo.Version = OpenHABVersion.Two; + return new HttpResponseResult(serverInfo, result.StatusCode); } string runtimeversion = Regex.Replace(apiInfo?.RuntimeInfo.Version, "[^.0-9]", string.Empty); @@ -139,12 +124,33 @@ public async Task GetOpenHABVersion() OpenHABVersion openHABVersion = (OpenHABVersion)serverVersion.Major; - return openHABVersion; + serverInfo.Version = openHABVersion; + serverInfo.RuntimeVersion = apiInfo?.RuntimeInfo.Version; + serverInfo.Build = apiInfo.RuntimeInfo.BuildString; + + return new HttpResponseResult(serverInfo, result.StatusCode); } catch (ArgumentNullException ex) { throw new OpenHABException("Invalid call", ex); } + catch (InvalidOperationException ex) + { + _logger.LogError(ex, "GetOpenHABServerInfo failed"); + + return new HttpResponseResult(null, null, ex); + } + catch (HttpRequestException ex) + { + _logger.LogError(ex, "GetOpenHABServerInfo failed"); + + return new HttpResponseResult(null, null, ex); + } + catch (Exception ex) + { + _logger.LogError(ex, "GetOpenHABServerInfo failed."); + return new HttpResponseResult(null, null, ex); + } } /// @@ -165,16 +171,16 @@ public async Task> LoadItemsFromSitemap(OpenHABSitema string resultString = await result.Content.ReadAsStringAsync().ConfigureAwait(false); ICollection items = null; - if (version == OpenHABVersion.One) + if (version == OpenHABVersion.Two || version == OpenHABVersion.Three) { - // V1 = xml - items = ParseWidgets(resultString); + var jsonObject = JObject.Parse(resultString); + items = JsonConvert.DeserializeObject>(jsonObject["homepage"]["widgets"].ToString()); } else { - // V2 = JSON - var jsonObject = JObject.Parse(resultString); - items = JsonConvert.DeserializeObject>(jsonObject["homepage"]["widgets"].ToString()); + string message = "openHAB version is not supported."; + _logger.LogError(message); + throw new OpenHABException(message); } _logger.LogInformation($"Loaded '{items.Count}' sitemaps items from server"); @@ -247,22 +253,6 @@ public async Task> LoadSiteMaps(OpenHABVersion versi string resultString = await result.Content.ReadAsStringAsync().ConfigureAwait(false); var sitemaps = new List(); - - // V1 = xml - if (version == OpenHABVersion.One) - { - XDocument xml = XDocument.Parse(resultString); - - foreach (XElement xElement in xml.Element("sitemaps").Elements()) - { - var sitemap = new OpenHABSitemap(xElement); - sitemaps.Add(sitemap); - } - - return sitemaps; - } - - // V2 = JSON sitemaps = JsonConvert.DeserializeObject>(resultString); _logger.LogInformation($"Loaded '{sitemaps.Count}' sitemaps from server"); @@ -408,18 +398,6 @@ await Task.Run((Func)(async () => })).ConfigureAwait(false); } - private ICollection ParseWidgets(string resultString) - { - var xml = XDocument.Parse(resultString); - - return - xml.Element("sitemap") - .Element("homepage") - .Elements("widget") - .Select(xElement => OpenHABWidgetFactory.Parse(xElement)) - .ToList(); - } - private async Task SetValidUrl(Settings settings) { _logger.LogInformation("Validate Url"); @@ -465,12 +443,6 @@ private async Task SetValidUrl(Settings settings) HttpResponseResult result = await CheckUrlReachability(settings.LocalConnection).ConfigureAwait(false); _logger.LogInformation($"OpenHab server is reachable: {result.Content}"); - if (!result.Content) - { - Messenger.Default.Send(new FireErrorMessage(AppResources.Errors.GetString("ConnectionTestFailed"))); - return false; - } - if (result.Content) { OpenHABHttpClient.BaseUrl = settings.LocalConnection.Url; @@ -483,7 +455,7 @@ private async Task SetValidUrl(Settings settings) // If remote URL is configured if (string.IsNullOrWhiteSpace(settings.RemoteConnection?.Url)) { - Messenger.Default.Send(new FireErrorMessage(AppResources.Errors.GetString("ConnectionTestFailed"))); + StrongReferenceMessenger.Default.Send(new FireErrorMessage(AppResources.Errors.GetString("ConnectionTestFailed"))); _logger.LogWarning($"OpenHab server url is not valid"); return false; @@ -492,7 +464,7 @@ private async Task SetValidUrl(Settings settings) result = await CheckUrlReachability(settings.RemoteConnection).ConfigureAwait(false); if (!result.Content) { - Messenger.Default.Send(new FireErrorMessage(AppResources.Errors.GetString("ConnectionTestFailed"))); + StrongReferenceMessenger.Default.Send(new FireErrorMessage(AppResources.Errors.GetString("ConnectionTestFailed"))); _logger.LogWarning($"OpenHab server url is not valid"); return false; diff --git a/src/openHAB.Core/Services/IconCaching.cs b/src/openHAB.Core/Services/IconCaching.cs index f3cbff24..f4ef0898 100644 --- a/src/openHAB.Core/Services/IconCaching.cs +++ b/src/openHAB.Core/Services/IconCaching.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Net.Http; -using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -35,16 +31,17 @@ public async Task ResolveIconPath(string iconUrl, string iconFormat) { Match iconName = Regex.Match(iconUrl, "icon/[0-9a-zA-Z]*"); Match iconState = Regex.Match(iconUrl, "state=[0-9a-zA-Z=]*"); + if (!iconName.Success) { throw new OpenHABException("Can not resolve icon name from url"); } + if (!iconState.Success) { throw new OpenHABException("Can not resolve icon state from url"); } - if (!iconState.Success) { throw new OpenHABException("Can not resolve icon state from url"); diff --git a/src/openHAB.Core/Services/Notification/NotificationManager.cs b/src/openHAB.Core/Services/Notification/NotificationManager.cs index 26239b19..dc5b1e40 100644 --- a/src/openHAB.Core/Services/Notification/NotificationManager.cs +++ b/src/openHAB.Core/Services/Notification/NotificationManager.cs @@ -1,5 +1,5 @@ using System.Globalization; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Toolkit.Uwp.Notifications; using OpenHAB.Core.Common; using OpenHAB.Core.Contracts.Services; @@ -24,14 +24,14 @@ public class NotificationManager : INotificationManager /// Application Settings. public NotificationManager(IItemManager itemStateManager, ISettingsService settingsService, Settings settings) { - Messenger.Default.Register(this, HandleUpdateItemMessage); + StrongReferenceMessenger.Default.Register(this, HandleUpdateItemMessage); _itemManager = itemStateManager; _iconFormat = settings.UseSVGIcons ? "svg" : "png"; _settingsService = settingsService; _notficationCounter = 0; } - private void HandleUpdateItemMessage(ItemStateChangedMessage obj) + private void HandleUpdateItemMessage(object receipts, ItemStateChangedMessage obj) { Settings settings = _settingsService.Load(); diff --git a/src/openHAB.Core/Services/SettingsService.cs b/src/openHAB.Core/Services/SettingsService.cs index fd4f0ff5..4517c7ca 100644 --- a/src/openHAB.Core/Services/SettingsService.cs +++ b/src/openHAB.Core/Services/SettingsService.cs @@ -39,8 +39,6 @@ public OpenHABVersion ServerVersion /// public Settings Load() { - _logger.LogInformation("Load settings from disk"); - EnsureSettingsContainer(); if (!_settingsContainer.Values.ContainsKey(Constants.Local.SettingsKey)) diff --git a/src/openHAB.Core/Strings/de-de/Resources.resw b/src/openHAB.Core/Strings/de-de/Resources.resw index c3c6f217..e51f46df 100644 --- a/src/openHAB.Core/Strings/de-de/Resources.resw +++ b/src/openHAB.Core/Strings/de-de/Resources.resw @@ -252,7 +252,7 @@ Bitte wählen Sie den Demo Modus oder die Lokalen/Remote Verbindunsinformation z Zurück - Log + Log: App Einstellungen @@ -305,4 +305,13 @@ Bitte wählen Sie den Demo Modus oder die Lokalen/Remote Verbindunsinformation z Benachrichtigungen + + Build: + + + openHAB Server Information + + + Version: + \ No newline at end of file diff --git a/src/openHAB.Core/Strings/en-us/Resources.resw b/src/openHAB.Core/Strings/en-us/Resources.resw index d358ccce..670fc53d 100644 --- a/src/openHAB.Core/Strings/en-us/Resources.resw +++ b/src/openHAB.Core/Strings/en-us/Resources.resw @@ -256,7 +256,7 @@ Please select demo mode or configure local/remote connection. Back - Log + Log: App Settings @@ -306,4 +306,13 @@ Please select demo mode or configure local/remote connection. Notifications + + Build: + + + openHAB Server Information + + + Version: + \ No newline at end of file diff --git a/src/openHAB.Windows/App.xaml.cs b/src/openHAB.Windows/App.xaml.cs index d6c3303b..13b5c17f 100644 --- a/src/openHAB.Windows/App.xaml.cs +++ b/src/openHAB.Windows/App.xaml.cs @@ -97,6 +97,8 @@ protected override async void OnLaunched(LaunchActivatedEventArgs e) if (settings.StartAppMinimized.HasValue && settings.StartAppMinimized.Value) { + _logger.LogInformation($"Settings:StartAppMinimized value is set to '{settings.StartAppMinimized.Value}'"); + IList infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); AppDiagnosticInfo appDiagnosticInfo = infos.FirstOrDefault(); @@ -104,6 +106,8 @@ protected override async void OnLaunched(LaunchActivatedEventArgs e) { IList resourceInfos = appDiagnosticInfo.GetResourceGroups(); await resourceInfos[0].StartSuspendAsync(); + + _logger.LogInformation("Start App in susp ended mode."); } } } diff --git a/src/openHAB.Windows/Controls/ColorWidget.xaml.cs b/src/openHAB.Windows/Controls/ColorWidget.xaml.cs index 218e8183..0c5caae0 100644 --- a/src/openHAB.Windows/Controls/ColorWidget.xaml.cs +++ b/src/openHAB.Windows/Controls/ColorWidget.xaml.cs @@ -1,7 +1,7 @@ using System; using System.Globalization; using System.Text.RegularExpressions; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.Logging; using OpenHAB.Core.Messages; using OpenHAB.Windows.Services; @@ -53,9 +53,9 @@ internal override void SetState() string rgbString = Widget.Item?.State; string[] rgbSegements = Widget.Item?.State.Split(','); - Regex rgbRegEx = new Regex(@"(\d{1,3}),(\d{1,3}),(\d{1,3})"); + Regex rgbRegEx = new Regex(@"^(([1-9][\.\d]*)(,)){2}([1-9][\.\d]*)"); - if (rgbString == null || rgbString.Length == 0 || !rgbRegEx.IsMatch(rgbString)) + if (rgbString == null || rgbString.Length == 0 || !rgbRegEx.IsMatch(rgbString) || rgbSegements == null) { _logger.LogWarning($"Item state '{rgbString}' is not a valid RGB value"); return; @@ -102,7 +102,7 @@ private void BrightnessSlider_ValueChanged(object sender, global::Windows.UI.Xam private void ColorChanged() { var hsvclr = Microsoft.Toolkit.Uwp.Helpers.ColorHelper.ToHsv(ClrPicker.Color); - Messenger.Default.Send(new TriggerCommandMessage(Widget.Item, $"{hsvclr.H.ToString(CultureInfo.InvariantCulture)},{(hsvclr.S * 100).ToString(CultureInfo.InvariantCulture)}, {BrightnessSlider.Value.ToString(CultureInfo.InvariantCulture)}")); + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(Widget.Item, $"{hsvclr.H.ToString(CultureInfo.InvariantCulture)},{(hsvclr.S * 100).ToString(CultureInfo.InvariantCulture)}, {BrightnessSlider.Value.ToString(CultureInfo.InvariantCulture)}")); } } } diff --git a/src/openHAB.Windows/Controls/FrameWidget.xaml.cs b/src/openHAB.Windows/Controls/FrameWidget.xaml.cs index 08a4d986..8af0d47d 100644 --- a/src/openHAB.Windows/Controls/FrameWidget.xaml.cs +++ b/src/openHAB.Windows/Controls/FrameWidget.xaml.cs @@ -1,4 +1,4 @@ -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using OpenHAB.Core.Messages; using OpenHAB.Core.Model; using Windows.UI.Xaml.Controls; @@ -20,7 +20,7 @@ public FrameWidget() private void OnItemClick(object sender, ItemClickEventArgs e) { - Messenger.Default.Send(new WidgetClickedMessage(e.ClickedItem as OpenHABWidget)); + StrongReferenceMessenger.Default.Send(new WidgetClickedMessage(e.ClickedItem as OpenHABWidget)); } internal override void SetState() diff --git a/src/openHAB.Windows/Controls/ImageLabel.xaml.cs b/src/openHAB.Windows/Controls/ImageLabel.xaml.cs index 16c285fb..b3c47e70 100644 --- a/src/openHAB.Windows/Controls/ImageLabel.xaml.cs +++ b/src/openHAB.Windows/Controls/ImageLabel.xaml.cs @@ -28,7 +28,9 @@ public ImageLabel() public static readonly DependencyProperty IconPathProperty = DependencyProperty.Register( "IconPath", typeof(string), typeof(ImageLabel), new PropertyMetadata(default(string), IconChangedCallback)); +#pragma warning disable S3168 // "async" methods should not return "void" private static async void IconChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) +#pragma warning restore S3168 // "async" methods should not return "void" { var control = (ImageLabel)dependencyObject; if (control == null) diff --git a/src/openHAB.Windows/Controls/RollershutterWidget.xaml.cs b/src/openHAB.Windows/Controls/RollershutterWidget.xaml.cs index 0f2ceb37..45dd9a37 100644 --- a/src/openHAB.Windows/Controls/RollershutterWidget.xaml.cs +++ b/src/openHAB.Windows/Controls/RollershutterWidget.xaml.cs @@ -1,4 +1,4 @@ -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using OpenHAB.Core.Messages; using OpenHAB.Core.Model; using Windows.UI.Xaml; @@ -25,17 +25,17 @@ public RollershutterWidget() private void ButtonUp_Click(object sender, RoutedEventArgs e) { - Messenger.Default.Send(new TriggerCommandMessage(Widget.Item, OpenHABCommands.UpCommand)); + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(Widget.Item, OpenHABCommands.UpCommand)); } private void ButtonStop_Click(object sender, RoutedEventArgs e) { - Messenger.Default.Send(new TriggerCommandMessage(Widget.Item, OpenHABCommands.StopCommand)); + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(Widget.Item, OpenHABCommands.StopCommand)); } private void ButtonDown_Click(object sender, RoutedEventArgs e) { - Messenger.Default.Send(new TriggerCommandMessage(Widget.Item, OpenHABCommands.DownCommand)); + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(Widget.Item, OpenHABCommands.DownCommand)); } internal override void SetState() diff --git a/src/openHAB.Windows/Controls/SectionSwitchWidget.xaml.cs b/src/openHAB.Windows/Controls/SectionSwitchWidget.xaml.cs index 7b120f96..d362c7e4 100644 --- a/src/openHAB.Windows/Controls/SectionSwitchWidget.xaml.cs +++ b/src/openHAB.Windows/Controls/SectionSwitchWidget.xaml.cs @@ -1,5 +1,5 @@ using System.Linq; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using OpenHAB.Core.Messages; using OpenHAB.Core.Model; using Windows.UI.Xaml; @@ -49,6 +49,11 @@ internal override void SetState() private void Button_OnClick(object sender, TappedRoutedEventArgs e) { ToggleButton button = sender as ToggleButton; + if(button == null) + { + return; + } + if (string.CompareOrdinal(button?.Tag?.ToString(), Widget.Item.State) == 0) { SetState(); @@ -58,7 +63,7 @@ private void Button_OnClick(object sender, TappedRoutedEventArgs e) UncheckEverything(); button.IsChecked = true; - Messenger.Default.Send(new TriggerCommandMessage(Widget.Item, button?.Tag.ToString())); + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(Widget.Item, button?.Tag.ToString())); } private void UncheckEverything() diff --git a/src/openHAB.Windows/Controls/SelectionWidget.xaml.cs b/src/openHAB.Windows/Controls/SelectionWidget.xaml.cs index 4b2c4a95..960e674e 100644 --- a/src/openHAB.Windows/Controls/SelectionWidget.xaml.cs +++ b/src/openHAB.Windows/Controls/SelectionWidget.xaml.cs @@ -1,5 +1,5 @@ using System.Linq; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Toolkit.Uwp.Helpers; using OpenHAB.Core.Messages; using OpenHAB.Core.Model; @@ -76,7 +76,7 @@ private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArg } Widget.Item.State = mapping.Command; - Messenger.Default.Send(new TriggerCommandMessage(Widget.Item, mapping.Command)); + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(Widget.Item, mapping.Command)); } /// diff --git a/src/openHAB.Windows/Controls/SliderWidget.xaml.cs b/src/openHAB.Windows/Controls/SliderWidget.xaml.cs index 762ea566..c3b76811 100644 --- a/src/openHAB.Windows/Controls/SliderWidget.xaml.cs +++ b/src/openHAB.Windows/Controls/SliderWidget.xaml.cs @@ -1,6 +1,5 @@ using System; using System.Globalization; -using GalaSoft.MvvmLight.Messaging; using OpenHAB.Core.Messages; using OpenHAB.Core.Model; using Windows.UI.Xaml; diff --git a/src/openHAB.Windows/Controls/SwitchWidget.xaml.cs b/src/openHAB.Windows/Controls/SwitchWidget.xaml.cs index e1306454..c77f4f2c 100644 --- a/src/openHAB.Windows/Controls/SwitchWidget.xaml.cs +++ b/src/openHAB.Windows/Controls/SwitchWidget.xaml.cs @@ -1,4 +1,4 @@ -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using OpenHAB.Core.Messages; using OpenHAB.Core.Model; using Windows.UI.Xaml; @@ -65,7 +65,7 @@ internal override void SetState() private void OnToggle() { IsOn = !IsOn; - Messenger.Default.Send(new TriggerCommandMessage(Widget.Item, IsOn ? OpenHABCommands.OnCommand : OpenHABCommands.OffCommand)); + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(Widget.Item, IsOn ? OpenHABCommands.OnCommand : OpenHABCommands.OffCommand)); } private void OnToggle(object sender, TappedRoutedEventArgs e) diff --git a/src/openHAB.Windows/Controls/ToggleWidget.xaml.cs b/src/openHAB.Windows/Controls/ToggleWidget.xaml.cs index 0818c0ef..a6ef8cb7 100644 --- a/src/openHAB.Windows/Controls/ToggleWidget.xaml.cs +++ b/src/openHAB.Windows/Controls/ToggleWidget.xaml.cs @@ -1,4 +1,4 @@ -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using OpenHAB.Core.Messages; using OpenHAB.Core.Model; using Windows.UI.Xaml; @@ -75,8 +75,7 @@ private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e) if (string.CompareOrdinal(currentValue, Widget?.Item?.State) != 0) { Widget.Item.State = currentValue; - Messenger.Default.Send(new TriggerCommandMessage(Widget.Item, currentValue)); - return; + StrongReferenceMessenger.Default.Send(new TriggerCommandMessage(Widget.Item, currentValue)); } } } diff --git a/src/openHAB.Windows/Converters/OpenHabUrlStateToGlyph.cs b/src/openHAB.Windows/Converters/OpenHabUrlStateToGlyph.cs index 2a84754d..9809fbbc 100644 --- a/src/openHAB.Windows/Converters/OpenHabUrlStateToGlyph.cs +++ b/src/openHAB.Windows/Converters/OpenHabUrlStateToGlyph.cs @@ -12,11 +12,11 @@ namespace OpenHAB.Windows.Converters /// public class OpenHabUrlStateToGlyph : IValueConverter { - private static Dictionary _stateToGlyphMapping = new Dictionary() + private static Dictionary _stateToGlyphMapping = new Dictionary() { - { OpenHABUrlState.Unknown, "\uF142" }, - { OpenHABUrlState.OK, "\uF13E" }, - { OpenHABUrlState.Failed, "\uF13D" }, + { ConnectionState.Unknown, "\uF142" }, + { ConnectionState.OK, "\uF13E" }, + { ConnectionState.Failed, "\uF13D" }, }; /// Converts the specified value. @@ -27,7 +27,7 @@ public class OpenHabUrlStateToGlyph : IValueConverter /// Returns a glyph for an url state. public object Convert(object value, Type targetType, object parameter, string language) { - OpenHABUrlState state = (OpenHABUrlState)value; + ConnectionState state = (ConnectionState)value; _stateToGlyphMapping.TryGetValue(state, out string glyph); return glyph; diff --git a/src/openHAB.Windows/DIService.cs b/src/openHAB.Windows/DIService.cs index dba7fa2a..a335097a 100644 --- a/src/openHAB.Windows/DIService.cs +++ b/src/openHAB.Windows/DIService.cs @@ -1,5 +1,4 @@ -using GalaSoft.MvvmLight.Messaging; -using GalaSoft.MvvmLight.Views; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Config; @@ -46,7 +45,7 @@ private void RegisterServices() loggingBuilder.AddNLog(GetLoggingConfiguration()); }); - _services.AddSingleton(Messenger.Default); + _services.AddSingleton(StrongReferenceMessenger.Default); _services.AddSingleton(); _services.AddSingleton(); _services.AddTransient(x => @@ -55,7 +54,7 @@ private void RegisterServices() return settingsService.Load(); }); - _services.AddSingleton(); + //_services.AddSingleton(); _services.AddSingleton(); _services.AddSingleton(); _services.AddSingleton(); diff --git a/src/openHAB.Windows/GlobalSuppressions.cs b/src/openHAB.Windows/GlobalSuppressions.cs deleted file mode 100644 index 64cf28ca..00000000 --- a/src/openHAB.Windows/GlobalSuppressions.cs +++ /dev/null @@ -1,9 +0,0 @@ -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. - -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1407:Arithmetic expressions must declare precedence", Justification = "", Scope = "member", Target = "~M:OpenHAB.Windows.Controls.RadialSlider.ScalePoint(System.Double,System.Double)~Windows.Foundation.Point")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1407:Arithmetic expressions must declare precedence", Justification = "", Scope = "member", Target = "~M:OpenHAB.Windows.Controls.RadialSlider.ValueToAngle(System.Double)~System.Double")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1407:Arithmetic expressions must declare precedence", Justification = "", Scope = "member", Target = "~M:OpenHAB.Windows.Controls.RadialSlider.OnApplyTemplate")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1407:Arithmetic expressions must declare precedence", Justification = "", Scope = "member", Target = "~M:OpenHAB.Windows.Controls.RadialSlider.OnValueChanged(Windows.UI.Xaml.DependencyObject)")] \ No newline at end of file diff --git a/src/openHAB.Windows/Styles/DefaultTheme.xaml b/src/openHAB.Windows/Styles/DefaultTheme.xaml index d1517ddf..8aeb8fb7 100644 --- a/src/openHAB.Windows/Styles/DefaultTheme.xaml +++ b/src/openHAB.Windows/Styles/DefaultTheme.xaml @@ -23,15 +23,15 @@ - + - + - + + + + - + Color="{StaticResource DarkColor}" />--> + + + + - diff --git a/src/openHAB.Windows/View/MainPage.xaml.cs b/src/openHAB.Windows/View/MainPage.xaml.cs index 32c50a76..00604365 100644 --- a/src/openHAB.Windows/View/MainPage.xaml.cs +++ b/src/openHAB.Windows/View/MainPage.xaml.cs @@ -1,5 +1,6 @@ using System; -using GalaSoft.MvvmLight.Messaging; +using System.Threading.Tasks; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.Logging; using OpenHAB.Core; using OpenHAB.Core.Messages; @@ -51,8 +52,8 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => /// protected override async void OnNavigatedTo(NavigationEventArgs e) { - Messenger.Default.Register(this, msg => ShowErrorMessage(msg)); - Messenger.Default.Register(this, msg => ShowInfoMessage(msg)); + StrongReferenceMessenger.Default.Register(this, async (recipient, msg) => await ShowErrorMessage(recipient, msg)); + StrongReferenceMessenger.Default.Register(this, async (recipient, msg) => await ShowInfoMessage(recipient, msg)); await Vm.LoadSitemapsAndItemData().ConfigureAwait(false); } @@ -60,14 +61,16 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) /// protected override void OnNavigatedFrom(NavigationEventArgs e) { - Messenger.Default.Unregister(this, msg => ShowErrorMessage(msg)); - Messenger.Default.Unregister(this, msg => ShowInfoMessage(msg)); + StrongReferenceMessenger.Default.Unregister(this); + StrongReferenceMessenger.Default.Unregister(this); ErrorNotification.IsOpen = false; InfoNotification.IsOpen = false; } - private async void ShowErrorMessage(FireErrorMessage message) +#pragma warning disable S1172 // Unused method parameters should be removed + private async Task ShowErrorMessage(object recipient, FireErrorMessage message) +#pragma warning restore S1172 // Unused method parameters should be removed { try { @@ -95,7 +98,9 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => } } - private async void ShowInfoMessage(FireInfoMessage msg) +#pragma warning disable S1172 // Unused method parameters should be removed + private async Task ShowInfoMessage(object recipient, FireInfoMessage msg) +#pragma warning restore S1172 // Unused method parameters should be removed { try { @@ -127,7 +132,7 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => private void MasterListView_OnItemClick(object sender, ItemClickEventArgs e) { - Messenger.Default.Send(new WidgetClickedMessage(e.ClickedItem as OpenHABWidget)); + StrongReferenceMessenger.Default.Send(new WidgetClickedMessage(e.ClickedItem as OpenHABWidget)); } private void SitemapNavigation_SelectionChanged( diff --git a/src/openHAB.Windows/View/SettingsPage.xaml b/src/openHAB.Windows/View/SettingsPage.xaml index 0f34b914..9e3ff978 100644 --- a/src/openHAB.Windows/View/SettingsPage.xaml +++ b/src/openHAB.Windows/View/SettingsPage.xaml @@ -56,28 +56,19 @@ + + + - + + - - - - - - - - - - - + - - - - - - + + + + + + + + + + + - + diff --git a/src/openHAB.Windows/View/SettingsPage.xaml.cs b/src/openHAB.Windows/View/SettingsPage.xaml.cs index bf4ef80d..c26a65dd 100644 --- a/src/openHAB.Windows/View/SettingsPage.xaml.cs +++ b/src/openHAB.Windows/View/SettingsPage.xaml.cs @@ -1,5 +1,5 @@ using System; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.Logging; using OpenHAB.Core; using OpenHAB.Core.Messages; @@ -32,13 +32,12 @@ public SettingsPage() InitializeComponent(); _settingsViewModel = (SettingsViewModel)DIService.Instance.Services.GetService(typeof(SettingsViewModel)); - DataContext = _settingsViewModel; - _logger = (ILogger)DIService.Instance.Services.GetService(typeof(ILogger)); + _appManager = (IAppManager)DIService.Instance.Services.GetService(typeof(IAppManager)); - SettingOptionsListView.SelectedIndex = 0; + DataContext = _settingsViewModel; - _appManager = (IAppManager)DIService.Instance.Services.GetService(typeof(IAppManager)); + SettingOptionsListView.SelectedIndex = 0; } #region Page Navigation @@ -46,17 +45,8 @@ public SettingsPage() /// protected override async void OnNavigatedTo(NavigationEventArgs e) { - Messenger.Default.Register(this, msg => HandleSettingsUpdate(msg), true); - Messenger.Default.Register(this, msg => NotificationSettingsValidation(msg), true); - - var autostartEnabled = await _appManager.IsStartupEnabled().ConfigureAwait(false); - var canAppAutostartEnabled = await _appManager.CanEnableAutostart().ConfigureAwait(false); - - await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => - { - _settingsViewModel.Settings.IsAppAutostartEnabled = autostartEnabled; - _settingsViewModel.Settings.CanAppAutostartEnabled = canAppAutostartEnabled; - }); + StrongReferenceMessenger.Default.Register(this, (recipient, msg) => HandleSettingsUpdate(recipient, msg)); + StrongReferenceMessenger.Default.Register(this, (recipient, msg) => NotificationSettingsValidation(recipient, msg)); AppAutostartSwitch.Toggled += AppAutostartSwitch_Toggled; } @@ -64,8 +54,8 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => /// protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { - Messenger.Default.Unregister(this, msg => HandleSettingsUpdate(msg)); - Messenger.Default.Unregister(this, msg => NotificationSettingsValidation(msg)); + StrongReferenceMessenger.Default.Unregister(this); + StrongReferenceMessenger.Default.Unregister(this); AppAutostartSwitch.Toggled -= AppAutostartSwitch_Toggled; } @@ -97,7 +87,9 @@ private void ConnectionSettingsListViewItem_Tapped(object sender, TappedRoutedEv ConnectionSettings.Visibility = Visibility.Visible; } - private void HandleSettingsUpdate(SettingsUpdatedMessage msg) +#pragma warning disable S1172 // Unused method parameters should be removed + private void HandleSettingsUpdate(object recipient, SettingsUpdatedMessage msg) +#pragma warning restore S1172 // Unused method parameters should be removed { try { @@ -115,7 +107,9 @@ private void HandleSettingsUpdate(SettingsUpdatedMessage msg) } } - private void NotificationSettingsValidation(SettingsValidationMessage msg) +#pragma warning disable S1172 // Unused method parameters should be removed + private void NotificationSettingsValidation(object recipient, SettingsValidationMessage msg) +#pragma warning restore S1172 // Unused method parameters should be removed { try { @@ -155,12 +149,19 @@ private async void OpenRemoteConnectionButton_Click(object sender, RoutedEventAr private async void AppAutostartSwitch_Toggled(object sender, RoutedEventArgs e) { - await _appManager.ToggleAutostart(); + ToggleSwitch toggleSwitch = (ToggleSwitch)e.OriginalSource; + bool toggleIsOn = toggleSwitch.IsOn; var autostartEnabled = await _appManager.IsStartupEnabled().ConfigureAwait(false); - await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => + + await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => { - _settingsViewModel.Settings.IsAppAutostartEnabled = autostartEnabled; + if (autostartEnabled != toggleIsOn) + { + await _appManager.ToggleAutostart(); + } + + _settingsViewModel.Settings.IsAppAutostartEnabled = toggleIsOn; }); } } diff --git a/src/openHAB.Windows/ViewModel/ConfigurationViewModel.cs b/src/openHAB.Windows/ViewModel/ConfigurationViewModel.cs index a109e7d1..14d21a96 100644 --- a/src/openHAB.Windows/ViewModel/ConfigurationViewModel.cs +++ b/src/openHAB.Windows/ViewModel/ConfigurationViewModel.cs @@ -1,12 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Microsoft.Extensions.Logging; using OpenHAB.Core.Contracts.Services; +using OpenHAB.Core.Messages; using OpenHAB.Core.Model; using OpenHAB.Core.Model.Connection; using OpenHAB.Core.SDK; using OpenHAB.Core.Services; +using Windows.ApplicationModel.Core; +using Windows.UI.Core; namespace OpenHAB.Windows.ViewModel { @@ -17,6 +21,7 @@ public class ConfigurationViewModel : ViewModelBase { private readonly ILogger _logger; private readonly Settings _settings; + private readonly IAppManager _appManager; private readonly ISettingsService _settingsService; private List _appLanguages; private bool? _canAppAutostartEnabled; @@ -34,12 +39,13 @@ public class ConfigurationViewModel : ViewModelBase /// /// Initializes a new instance of the class. /// - public ConfigurationViewModel(ISettingsService settingsService, IOpenHAB openHabsdk, ILogger logger, Settings settings) + public ConfigurationViewModel(ISettingsService settingsService, IAppManager appManager, IOpenHAB openHabsdk, ILogger logger, Settings settings) : base(new object()) { _settingsService = settingsService; _logger = logger; _settings = settings; + _appManager = appManager; _localConnection = new ConnectionDialogViewModel(_settings.LocalConnection, openHabsdk, OpenHABHttpClientType.Local); _localConnection.PropertyChanged += ConnectionPropertyChanged; @@ -53,6 +59,25 @@ public ConfigurationViewModel(ISettingsService settingsService, IOpenHAB openHab _startAppMinimized = _settings.StartAppMinimized; _notificationsEnable = _settings.NotificationsEnable; + CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; + Task taskCanEnableAutostart = _appManager.CanEnableAutostart(); + taskCanEnableAutostart.ContinueWith(result => + { + dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => + { + CanAppAutostartEnabled = result.Result; + }); + }); + + Task taskStartupEnbabled = _appManager.IsStartupEnabled(); + taskStartupEnbabled.ContinueWith(result => + { + dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => + { + IsAppAutostartEnabled = result.Result; + }); + }); + _appLanguages = InitalizeAppLanguages(); _selectedAppLanguage = _appLanguages.FirstOrDefault(x => string.Compare(x.Code, _settings.AppLanguage, StringComparison.InvariantCultureIgnoreCase) == 0); @@ -272,8 +297,8 @@ public bool UseSVGIcons public bool IsConnectionConfigValid() { bool validConfig = IsRunningInDemoMode.Value || - (!string.IsNullOrEmpty(LocalConnection?.Url) && LocalConnection?.State == OpenHABUrlState.OK) || - (!string.IsNullOrEmpty(RemoteConnection?.Url) && RemoteConnection?.State == OpenHABUrlState.OK); + (!string.IsNullOrEmpty(LocalConnection?.Url) && LocalConnection?.Status.State == ConnectionState.OK) || + (!string.IsNullOrEmpty(RemoteConnection?.Url) && RemoteConnection?.Status.State == ConnectionState.OK); _logger.LogInformation($"Valid application configuration: {validConfig}"); @@ -297,7 +322,7 @@ public bool Save() private void ConfigurationViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { - if (e.PropertyName != nameof(IsDirty)) + if (e.PropertyName != nameof(IsDirty) && e.PropertyName != nameof(CanAppAutostartEnabled) && e.PropertyName != nameof(IsAppAutostartEnabled)) { OnPropertyChanged(nameof(IsDirty)); } @@ -305,7 +330,7 @@ private void ConfigurationViewModel_PropertyChanged(object sender, System.Compon private void ConnectionPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { - OnPropertyChanged(nameof(IsDirty)); + OnPropertyChanged(nameof(IsDirty)); } private List InitalizeAppLanguages() diff --git a/src/openHAB.Windows/ViewModel/ConnectionDialogViewModel.cs b/src/openHAB.Windows/ViewModel/ConnectionDialogViewModel.cs index 3bc3f948..c5da8fca 100644 --- a/src/openHAB.Windows/ViewModel/ConnectionDialogViewModel.cs +++ b/src/openHAB.Windows/ViewModel/ConnectionDialogViewModel.cs @@ -2,17 +2,14 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Threading.Tasks; using System.Windows.Input; -using GalaSoft.MvvmLight.Command; +using CommunityToolkit.Mvvm.Input; using OpenHAB.Core; using OpenHAB.Core.Common; using OpenHAB.Core.Contracts; using OpenHAB.Core.Model; using OpenHAB.Core.Model.Connection; using OpenHAB.Core.SDK; -using Windows.ApplicationModel.Core; -using Windows.UI.Core; namespace OpenHAB.Windows.ViewModel { @@ -21,7 +18,6 @@ namespace OpenHAB.Windows.ViewModel /// public class ConnectionDialogViewModel : ViewModelBase { - private readonly IOpenHAB _openHabsdk; private readonly OpenHABHttpClientType _type; private string _password; private ConnectionProfileViewModel _profile; @@ -29,7 +25,7 @@ public class ConnectionDialogViewModel : ViewModelBase private ICommand _selectProfile; private string _url; private ICommand _urlCheckCommand; - private OpenHABUrlState _connectionState; + private ConnectionStatusViewModel _connectionStatus; private string _username; private bool? _willIgnoreSSLCertificate; private bool? _willIgnoreSSLHostname; @@ -43,9 +39,7 @@ public class ConnectionDialogViewModel : ViewModelBase public ConnectionDialogViewModel(OpenHABConnection connectionConfig, IOpenHAB openHabsdk, OpenHABHttpClientType type) : base(connectionConfig) { - _openHabsdk = openHabsdk; _type = type; - _connectionState = OpenHABUrlState.Unknown; List list = new List(Settings.ConnectionProfiles.Where(x => x.Type == _type).OrderBy(x => x.Id).Select(x => new ConnectionProfileViewModel(x))); @@ -57,10 +51,18 @@ List list _profile = list.FirstOrDefault(x => x.Id == Model.Profile.Id); } + _connectionStatus = new ConnectionStatusViewModel(openHabsdk); + if (!string.IsNullOrEmpty(Model?.Url)) { - CheckConnectionSettings(Model.Url); + CheckConnectionSettings(null); } + + _username = Model?.Username; + _password = Model?.Password; + _url = Model?.Url; + _willIgnoreSSLHostname = Model?.WillIgnoreSSLHostname; + _willIgnoreSSLCertificate = Model?.WillIgnoreSSLCertificate; } /// Gets a value indicating whether [host URL] value can be modified. @@ -92,11 +94,7 @@ public bool AllowIgnoreSSLHostname /// public string Password { - get - { - return Model?.Password; - } - + get => _password; set { Set(ref _password, value, true); @@ -108,11 +106,7 @@ public string Password /// The profile. public ConnectionProfileViewModel Profile { - get - { - return _profile; - } - + get => _profile; set { Set(ref _profile, value); @@ -124,15 +118,22 @@ public ConnectionProfileViewModel Profile } } - /// Gets or sets the available connection profiles. - /// The profiles. - public ObservableCollection Profiles + /// Gets or sets the connection status. + /// The connection status. + public ConnectionStatusViewModel Status { - get + get => _connectionStatus; + set { - return _profiles; + Set(ref _connectionStatus, value); } + } + /// Gets or sets the available connection profiles. + /// The profiles. + public ObservableCollection Profiles + { + get => _profiles; set { Set(ref _profiles, value); @@ -173,11 +174,7 @@ public string Subtitle /// public string Url { - get - { - return Model?.Url; - } - + get => _url; set { string tempUrl; @@ -203,26 +200,12 @@ public string Url /// The local URL check command. public ICommand UrlCheckCommand => _urlCheckCommand ?? (_urlCheckCommand = new RelayCommand(CheckConnectionSettings)); - /// - /// Gets or sets the state for OpenHab connection. - /// - /// The state of the connection. - public OpenHABUrlState State - { - get => _connectionState; - set => Set(ref _connectionState, value); - } - /// /// Gets or sets the username for the local OpenHAB server connection. /// public string Username { - get - { - return Model?.Username; - } - + get => _username; set { Set(ref _username, value, true); @@ -235,11 +218,7 @@ public string Username /// public bool? WillIgnoreSSLCertificate { - get - { - return Model?.WillIgnoreSSLCertificate; - } - + get => _willIgnoreSSLCertificate; set { Set(ref _willIgnoreSSLCertificate, value, true); @@ -252,11 +231,7 @@ public bool? WillIgnoreSSLCertificate /// public bool? WillIgnoreSSLHostname { - get - { - return Model?.WillIgnoreSSLHostname; - } - + get => _willIgnoreSSLHostname; set { Set(ref _willIgnoreSSLHostname, value, true); @@ -266,32 +241,7 @@ public bool? WillIgnoreSSLHostname private void CheckConnectionSettings(object parameter) { - if (parameter == null) - { - return; - } - - string url = parameter.ToString(); - - Task> result = _openHabsdk.CheckUrlReachability(this.Model); - result.ContinueWith(async (task) => - { - OpenHABUrlState urlState = OpenHABUrlState.Unknown; - if (task.IsCompletedSuccessfully && task.Result.Content) - { - urlState = OpenHABUrlState.OK; - } - else - { - urlState = OpenHABUrlState.Failed; - } - - CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; - await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => - { - State = urlState; - }); - }); + _connectionStatus.CheckConnectionSettings(Model.Url, Model); } private void CreateProfile(IConnectionProfile value) diff --git a/src/openHAB.Windows/ViewModel/ConnectionStatusViewModel.cs b/src/openHAB.Windows/ViewModel/ConnectionStatusViewModel.cs new file mode 100644 index 00000000..a054a86a --- /dev/null +++ b/src/openHAB.Windows/ViewModel/ConnectionStatusViewModel.cs @@ -0,0 +1,100 @@ +using System; +using System.Threading.Tasks; +using CommunityToolkit.Mvvm.Messaging; +using OpenHAB.Core.Common; +using OpenHAB.Core.Messages; +using OpenHAB.Core.Model; +using OpenHAB.Core.Model.Connection; +using OpenHAB.Core.SDK; +using Windows.ApplicationModel.Core; +using Windows.UI.Core; + +namespace OpenHAB.Windows.ViewModel +{ + /// + /// ViewModel for OpenHAB connection status. + /// + public class ConnectionStatusViewModel : ViewModelBase + { + private readonly IOpenHAB _openHabsdk; + + private ConnectionState _connectionState; + + private string _runtimeVersion; + private string _build; + + /// + /// Initializes a new instance of the class. + /// + /// OpenHABSDK class. + public ConnectionStatusViewModel(IOpenHAB openHabsdk) + : base(null) + { + _openHabsdk = openHabsdk; + _connectionState = ConnectionState.Unknown; + } + + /// + /// Gets or sets the state for OpenHab connection. + /// + /// The state of the connection. + public ConnectionState State + { + get => _connectionState; + set => Set(ref _connectionState, value); + } + + /// Gets or sets the runtime version. + /// The runtime version. + public string RuntimeVersion + { + get => _runtimeVersion; + set => Set(ref _runtimeVersion, value, true); + } + + /// Gets or sets the build. + /// The build. + public string Build + { + get => _build; + set => Set(ref _build, value, true); + } + + /// Checks the connection settings. + /// The URL. + /// The connection. + public void CheckConnectionSettings(string url, OpenHABConnection connection) + { + Task> result = _openHabsdk.GetOpenHABServerInfo(connection); + result.ContinueWith(async (task) => + { + ConnectionState connectionState = ConnectionState.Unknown; + string runtimeVersion = string.Empty; + string build = string.Empty; + + if (task.IsCompletedSuccessfully && task.Result.Content != null) + { + ServerInfo serverInfo = task.Result.Content; + + runtimeVersion = serverInfo.RuntimeVersion; + build = serverInfo.Build; + connectionState = ConnectionState.OK; + } + else + { + connectionState = ConnectionState.Failed; + } + + CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; + await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => + { + State = connectionState; + RuntimeVersion = runtimeVersion; + Build = build; + }); + + StrongReferenceMessenger.Default.Send(new ConnectionStatusChanged(connectionState)); + }); + } + } +} diff --git a/src/openHAB.Windows/ViewModel/LogsViewModel.cs b/src/openHAB.Windows/ViewModel/LogsViewModel.cs index cf8e3285..62fb4749 100644 --- a/src/openHAB.Windows/ViewModel/LogsViewModel.cs +++ b/src/openHAB.Windows/ViewModel/LogsViewModel.cs @@ -63,6 +63,21 @@ public string LogFilePath } } + /// Gets the log file name including extension. + /// The log file. + public string LogFile + { + get + { + if (_logFile != null) + { + return _logFile.Name; + } + + return string.Empty; + } + } + private async Task LoadLogfileAsync() { await LoadLogFileContent().ConfigureAwait(false); diff --git a/src/openHAB.Windows/ViewModel/MainViewModel.cs b/src/openHAB.Windows/ViewModel/MainViewModel.cs index 4fd03cde..64d09488 100644 --- a/src/openHAB.Windows/ViewModel/MainViewModel.cs +++ b/src/openHAB.Windows/ViewModel/MainViewModel.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.Logging; using Microsoft.Services.Store.Engagement; using OpenHAB.Core; @@ -37,7 +37,7 @@ public class MainViewModel : ViewModelBase private OpenHABWidget _selectedWidget; private ObservableCollection _sitemaps; private string _subtitle; - private OpenHABVersion _version; + private ServerInfo _serverInfo; private object _selectedMenuItem; private ActionCommand _reloadSitemapCommand; @@ -58,10 +58,12 @@ public MainViewModel(IOpenHAB openHabsdk, ISettingsService settingsService, ILog _feedbackLauncher = StoreServicesFeedbackLauncher.GetDefault(); _cancellationTokenSource = new CancellationTokenSource(); - Messenger.Default.Register(this, async msg => await TriggerCommand(msg).ConfigureAwait(false)); - Messenger.Default.Register(this, msg => OnWidgetClickedAsync(msg.Widget)); + StrongReferenceMessenger.Default.Register(this, async (recipient, msg) => await TriggerCommand(recipient, msg).ConfigureAwait(false)); + StrongReferenceMessenger.Default.Register(this, (recipient, msg) => OnWidgetClickedAction(recipient, msg.Widget)); } + + /// /// Gets or sets the widgets currently on screen. /// @@ -199,22 +201,30 @@ private bool CanExecuteRefreshCommand(object arg) return !IsDataLoading; } +#pragma warning disable S3168 // "async" methods should not return "void" private async void ExecuteFeedbackCommand(object obj) +#pragma warning restore S3168 // "async" methods should not return "void" { await _feedbackLauncher.LaunchAsync(); } +#pragma warning disable S3168 // "async" methods should not return "void" private async void ExecuteRefreshCommandAsync(object obj) +#pragma warning restore S3168 // "async" methods should not return "void" { await LoadSitemapsAndItemData().ConfigureAwait(false); } +#pragma warning disable S3168 // "async" methods should not return "void" private async void ExecuteReloadSitemapCommand(object obj) +#pragma warning restore S3168 // "async" methods should not return "void" { await ReloadSitemap().ConfigureAwait(false); } - private async Task TriggerCommand(TriggerCommandMessage message) +#pragma warning disable S1172 // Unused method parameters should be removed + private async Task TriggerCommand(object recipient, TriggerCommandMessage message) +#pragma warning restore S1172 // Unused method parameters should be removed { HttpResponseResult result = await _openHabsdk.SendCommand(message.Item, message.Command).ConfigureAwait(false); if (!result.Content) @@ -222,10 +232,17 @@ private async Task TriggerCommand(TriggerCommandMessage message) string errorMessage = AppResources.Errors.GetString("CommandFailed"); errorMessage = string.Format(errorMessage, message.Command, message.Item?.Name); - Messenger.Default.Send(new FireErrorMessage(errorMessage)); + StrongReferenceMessenger.Default.Send(new FireErrorMessage(errorMessage)); } } +#pragma warning disable S1172 // Unused method parameters should be removed + private async void OnWidgetClickedAction(object recipient, OpenHABWidget widget) +#pragma warning restore S1172 // Unused method parameters should be removed + { + await OnWidgetClickedAsync(widget); + } + #endregion #region Load sitemap and Data @@ -272,7 +289,9 @@ await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => }); } +#pragma warning disable S3168 // "async" methods should not return "void" private async void CancelSyncCallbackAsync() +#pragma warning restore S3168 // "async" methods should not return "void" { CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => @@ -310,24 +329,26 @@ await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => if (settings.LocalConnection == null && settings.RemoteConnection == null && (!settings.IsRunningInDemoMode.HasValue || !settings.IsRunningInDemoMode.Value)) { - Messenger.Default.Send(new FireInfoMessage(MessageType.NotConfigured)); + StrongReferenceMessenger.Default.Send(new FireInfoMessage(MessageType.NotConfigured)); } bool isSuccessful = await _openHabsdk.ResetConnection().ConfigureAwait(false); if (!isSuccessful) { - Messenger.Default.Send(new FireInfoMessage(MessageType.NotConfigured)); + StrongReferenceMessenger.Default.Send(new FireInfoMessage(MessageType.NotConfigured)); return; } - _version = await _openHabsdk.GetOpenHABVersion().ConfigureAwait(false); - if (_version == OpenHABVersion.None) + var result = await _openHabsdk.GetOpenHABServerInfo().ConfigureAwait(false); + _serverInfo = result?.Content; + + if (_serverInfo == null || _serverInfo.Version == OpenHABVersion.None) { - Messenger.Default.Send(new FireInfoMessage(MessageType.NotConfigured)); + StrongReferenceMessenger.Default.Send(new FireInfoMessage(MessageType.NotConfigured)); return; } - _settingsService.ServerVersion = _version; + _settingsService.ServerVersion = _serverInfo.Version; if (cancellationToken.IsCancellationRequested) { @@ -370,7 +391,7 @@ await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => catch (OpenHABException ex) { _logger.LogError(ex, "Load data failed."); - Messenger.Default.Send(new FireErrorMessage(ex.Message)); + StrongReferenceMessenger.Default.Send(new FireErrorMessage(ex.Message)); } catch (Exception ex) { @@ -399,7 +420,7 @@ private async Task> LoadSitemaps(Settings settings) filters.Add(defaultSitemapFilter); } - ICollection sitemaps = await _openHabsdk.LoadSiteMaps(_version, filters).ConfigureAwait(false); + ICollection sitemaps = await _openHabsdk.LoadSiteMaps(_serverInfo.Version, filters).ConfigureAwait(false); List sitemapViewModels = new List(); sitemaps.ToList().ForEach(x => sitemapViewModels.Add(new SitemapViewModel(x))); @@ -458,7 +479,7 @@ private async Task LoadWidgets() CurrentWidgets.Clear(); IsDataLoading = true; - await SelectedSitemap.LoadWidgets(_version).ConfigureAwait(false); + await SelectedSitemap.LoadWidgets(_serverInfo.Version).ConfigureAwait(false); CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => diff --git a/src/openHAB.Windows/ViewModel/SettingsViewModel.cs b/src/openHAB.Windows/ViewModel/SettingsViewModel.cs index 67279e23..42e3ed34 100644 --- a/src/openHAB.Windows/ViewModel/SettingsViewModel.cs +++ b/src/openHAB.Windows/ViewModel/SettingsViewModel.cs @@ -1,5 +1,5 @@ using System; -using GalaSoft.MvvmLight.Messaging; +using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.Logging; using OpenHAB.Core.Common; using OpenHAB.Core.Messages; @@ -31,6 +31,8 @@ public SettingsViewModel(ConfigurationViewModel configurationViewModel, IIconCac _iconCaching = iconCaching; _logger = logger; + + StrongReferenceMessenger.Default.Register(this, (recipient, msg) => SaveCommand.InvokeCanExecuteChanged(null)); } /// @@ -83,7 +85,7 @@ public void PersistSettings(object obj) if (validConnectionConfig) { bool savedSuccessful = _configuration.Save(); - Messenger.Default.Send(new SettingsUpdatedMessage(validConnectionConfig, savedSuccessful)); + StrongReferenceMessenger.Default.Send(new SettingsUpdatedMessage(validConnectionConfig, savedSuccessful)); } } @@ -101,7 +103,7 @@ private bool CanClearIcons(object arg) private bool CanPersistSettings(object arg) { bool validConnectionConfig = CheckForValidConnectionConfig(); - Messenger.Default.Send(new SettingsValidationMessage(validConnectionConfig)); + StrongReferenceMessenger.Default.Send(new SettingsValidationMessage(validConnectionConfig)); return validConnectionConfig && _configuration.IsDirty; } diff --git a/src/openHAB.Windows/ViewModel/SitemapViewModel.cs b/src/openHAB.Windows/ViewModel/SitemapViewModel.cs index 814948ab..c49a27f5 100644 --- a/src/openHAB.Windows/ViewModel/SitemapViewModel.cs +++ b/src/openHAB.Windows/ViewModel/SitemapViewModel.cs @@ -79,6 +79,11 @@ public ObservableCollection Widgets } } + /// + /// Loads widgets for sitemap. + /// + /// OH version. + /// Task for async processing. public async Task LoadWidgets(OpenHABVersion version) { Widgets.Clear(); diff --git a/src/openHAB.Windows/openHAB.Windows.csproj b/src/openHAB.Windows/openHAB.Windows.csproj index 53098bc8..ec5b62ef 100644 --- a/src/openHAB.Windows/openHAB.Windows.csproj +++ b/src/openHAB.Windows/openHAB.Windows.csproj @@ -39,8 +39,7 @@ false prompt true - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset bin\x86\Debug\OpenHAB.Windows.XML false false @@ -56,8 +55,7 @@ prompt true true - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset true @@ -69,8 +67,7 @@ false prompt true - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset false @@ -84,8 +81,7 @@ prompt true true - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset true @@ -97,8 +93,7 @@ false prompt true - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset false @@ -112,8 +107,7 @@ prompt true true - - + ..\..\.sonarlint\openhab_openhab-windowscsharp.ruleset @@ -129,6 +123,9 @@ Strings\en-us\Errors.resw + + openhab_openhab-windowscsharp.ruleset + @@ -212,8 +209,8 @@ - + @@ -240,6 +237,9 @@ + + SonarLint.xml + @@ -423,22 +423,25 @@ + + 7.1.2 + - 5.0.3 + 6.0.0 runtime; build; native; contentfiles; analyzers; buildtransitive all - 5.0.1 + 6.0.0 - 6.2.12 + 6.2.13 10.1901.28001 - 7.0.2 + 7.1.2 2.6.0-prerelease.210129001 @@ -446,11 +449,8 @@ 2.0.1 - - 5.4.1.1 - - 1.7.3 + 1.7.4 1.1.118