From 311d1cde294cde92b6eef3e98b51a1d7469a29ef Mon Sep 17 00:00:00 2001 From: Panagiotis Kanavos Date: Fri, 30 Mar 2012 23:33:15 +0300 Subject: [PATCH] Added silent install option Now allowing accounts with the same name from different servers --- trunk/NetSparkle/NetSparkle.cs | 2 +- .../Preferences/PreferencesView.xaml | 3 ++ .../Preferences/PreferencesViewModel.cs | 45 +++++++++++++------- trunk/Pithos.Client.WPF/Shell/ShellView.xaml | 10 ++++- trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs | 2 +- 5 files changed, 43 insertions(+), 19 deletions(-) diff --git a/trunk/NetSparkle/NetSparkle.cs b/trunk/NetSparkle/NetSparkle.cs index 8eddd83..e48ebdd 100644 --- a/trunk/NetSparkle/NetSparkle.cs +++ b/trunk/NetSparkle/NetSparkle.cs @@ -557,7 +557,7 @@ namespace AppLimit.NetSparkle // check if update is required NetSparkleAppCastItem latestVersion = null; bUpdateRequired = IsUpdateRequired(config, out latestVersion); - this.LatestVersion = latestVersion.Version; + this.LatestVersion = latestVersion.Version??""; if (!bUpdateRequired) goto WaitSection; diff --git a/trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml b/trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml index 8f15947..ebe6a29 100644 --- a/trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml +++ b/trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml @@ -73,7 +73,10 @@ + + + diff --git a/trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs b/trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs index 2857dc8..88ef03c 100644 --- a/trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs +++ b/trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs @@ -58,6 +58,7 @@ using Pithos.Core; using Pithos.Interfaces; using System; using System.Linq; +using MessageBox = System.Windows.MessageBox; using Screen = Caliburn.Micro.Screen; namespace Pithos.Client.WPF.Preferences @@ -243,7 +244,7 @@ namespace Pithos.Client.WPF.Preferences return; //The server will return credentials for a different account, not just the current account //We need to find the correct account first - var account = Accounts.First(act => act.AccountName == credentials.UserName && act.ServerUrl == ?? ); + var account = Accounts.First(act => act.AccountName == credentials.UserName && act.ServerUrl == CurrentAccount.ServerUrl); account.ApiKey = credentials.Password; account.IsExpired = false; Settings.Save(); @@ -379,20 +380,34 @@ namespace Pithos.Client.WPF.Preferences actualRootPath = String.Format("{0} {1}", initialRootPath, attempt++); } } - ### Check that the account does not already exist - - var newAccount = new AccountSettings - { - AccountName = wizard.AccountName, - ServerUrl=wizard.CurrentServer, - ApiKey=wizard.Token, - RootPath = actualRootPath, - IsActive=wizard.IsAccountActive - }; - _accountsToAdd.Add(newAccount); - var accountVm = new AccountViewModel(newAccount); - (Accounts as IProducerConsumerCollection).TryAdd(accountVm); - CurrentAccount = accountVm; + + + + var account = Accounts.FirstOrDefault(act => act.AccountName == wizard.AccountName && act.ServerUrl == wizard.CurrentServer); + if (account != null) + { + if (MessageBox.Show("The account you specified already exists. Do you want to update it?","The account exists") == MessageBoxResult.Yes) + { + account.ApiKey = wizard.Token; + account.IsExpired = false; + CurrentAccount = account; + } + } + else + { + var newAccount = new AccountSettings + { + AccountName = wizard.AccountName, + ServerUrl = wizard.CurrentServer, + ApiKey = wizard.Token, + RootPath = actualRootPath, + IsActive = wizard.IsAccountActive + }; + _accountsToAdd.Add(newAccount); + var accountVm = new AccountViewModel(newAccount); + (Accounts as IProducerConsumerCollection).TryAdd(accountVm); + CurrentAccount = accountVm; + } NotifyOfPropertyChange(() => Accounts); NotifyOfPropertyChange(() => Settings); } diff --git a/trunk/Pithos.Client.WPF/Shell/ShellView.xaml b/trunk/Pithos.Client.WPF/Shell/ShellView.xaml index fb2be4f..dcb8d66 100644 --- a/trunk/Pithos.Client.WPF/Shell/ShellView.xaml +++ b/trunk/Pithos.Client.WPF/Shell/ShellView.xaml @@ -41,8 +41,11 @@ + + + @@ -52,8 +55,11 @@ - + + + + diff --git a/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs index da44496..96a650c 100644 --- a/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs +++ b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs @@ -835,7 +835,7 @@ namespace Pithos.Client.WPF { account.SiteUri, Uri.EscapeDataString(account.Token), Uri.EscapeDataString(account.UserName)); - if (Accounts.All(item => item.UserName != account.UserName)) + if (!Accounts.Any(item => item.UserName == account.UserName && item.SiteUri == account.SiteUri)) Accounts.TryAdd(account); } -- 1.7.10.4