From cb488c22cda48584972abeeb080f2ba6682398d0 Mon Sep 17 00:00:00 2001 From: Loginer von Web Date: Wed, 16 Sep 2015 13:17:08 +0200 Subject: [PATCH] Enforce auto-generated usernames --- Albedo/App.xaml.cs | 8 ++++++-- Albedo/Core/Setup.cs | 2 +- Albedo/DummyWindow.xaml.cs | 3 ++- Albedo/MainWindow.xaml.cs | 5 +++++ Albedo/SetupWindow.xaml | 2 +- Albedo/SetupWindow.xaml.cs | 30 +++++++++++++++++++++++------- 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Albedo/App.xaml.cs b/Albedo/App.xaml.cs index 132bbc9..b0d5f16 100644 --- a/Albedo/App.xaml.cs +++ b/Albedo/App.xaml.cs @@ -47,10 +47,14 @@ void AppStartup(object sender, StartupEventArgs e) Platform.WriteSetting("newVersion", false); Platform.SaveSettings(); } - - if (Platform.ReadSetting("bridgeIP") != "0.0.0.0") { + string username = Platform.ReadSetting("bridgeUserName"); + if (Platform.ReadSetting("bridgeIP") != "0.0.0.0" && !username.Contains("albedo")) { Storage.InitializeData(); } else { + if (username.Contains("albedo")) { //Usernames must be auto-generated by the end of 2015 + System.Windows.MessageBox.Show("Due to a software update that changes the way apps pair with the bridge, Albedo will need to re-run the pairing wizard.\nSorry for the inconvenience."); + } + WindowStorage.setupStorage = new SetupWindow(); WindowStorage.setupStorage.Show(); } diff --git a/Albedo/Core/Setup.cs b/Albedo/Core/Setup.cs index 3aa7201..552dcc4 100644 --- a/Albedo/Core/Setup.cs +++ b/Albedo/Core/Setup.cs @@ -23,7 +23,7 @@ async public static Task PairAttempt(string bridgeIP, string bridgeUser) { devicetype = devicetype.Substring(0, 40); } dynContent.devicetype = devicetype; - dynContent.username = bridgeUser; + //dynContent.username = bridgeUser; //OBSOLETE. Username is now assigned by the bridge. StringContent content = new StringContent(JsonParser.Serialize(dynContent)); Task postData = client.PostAsync(address, content); diff --git a/Albedo/DummyWindow.xaml.cs b/Albedo/DummyWindow.xaml.cs index 7385daa..1eaf752 100644 --- a/Albedo/DummyWindow.xaml.cs +++ b/Albedo/DummyWindow.xaml.cs @@ -56,7 +56,8 @@ public static void ToolTipUpdate() private bool Ready() { - if (Platform.ReadSetting("bridgeIP") == "0.0.0.0") { + string username = Platform.ReadSetting("bridgeUserName"); + if (Platform.ReadSetting("bridgeIP") != "0.0.0.0" && !username.Contains("albedo")) { return false; } else { return true; diff --git a/Albedo/MainWindow.xaml.cs b/Albedo/MainWindow.xaml.cs index dd0159b..5cc95ea 100644 --- a/Albedo/MainWindow.xaml.cs +++ b/Albedo/MainWindow.xaml.cs @@ -79,6 +79,11 @@ public void SetInfo() slidersAllowed = false; int i = 1; + string username = Platform.ReadSetting("bridgeUserName"); + if (username.Contains("albedo")) { + return; + } + //Populate Lights tab foreach (string lightLabel in Storage.groupData.lights) { if (i <= 5) { diff --git a/Albedo/SetupWindow.xaml b/Albedo/SetupWindow.xaml index 24552b8..5bf7f04 100644 --- a/Albedo/SetupWindow.xaml +++ b/Albedo/SetupWindow.xaml @@ -103,7 +103,7 @@