Added silent install option
authorPanagiotis Kanavos <pkanavos@gmail.com>
Fri, 30 Mar 2012 20:33:15 +0000 (23:33 +0300)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Fri, 30 Mar 2012 20:33:15 +0000 (23:33 +0300)
Now allowing accounts with the same name from different servers

trunk/NetSparkle/NetSparkle.cs
trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml
trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
trunk/Pithos.Client.WPF/Shell/ShellView.xaml
trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs

index 8eddd83..e48ebdd 100644 (file)
@@ -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;
 
index 8f15947..ebe6a29 100644 (file)
                                 <DataTemplate>
                                     <StackPanel Orientation="Horizontal">
                                     <Image Visibility="{Binding Converter={StaticResource BoolToVisible}, Path=IsExpired,Mode=OneWay}" Source="/PithosPlus;component/Images/SmallWarning.png" Margin="2,0"/>
+                                        <StackPanel>
                                     <TextBlock Text="{Binding AccountName}" />
+                                    <TextBlock Text="{Binding ServerUrl}" FontStyle="Italic" FontSize="10" />
+                                        </StackPanel>
                                     </StackPanel>
                                 </DataTemplate>
                             </ListBox.ItemTemplate>
index 2857dc8..88ef03c 100644 (file)
@@ -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<AccountViewModel>).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<AccountViewModel>).TryAdd(accountVm);
+                   CurrentAccount = accountVm;
+               }
                NotifyOfPropertyChange(() => Accounts);
                NotifyOfPropertyChange(() => Settings);   
            }
index fb2be4f..dcb8d66 100644 (file)
                     <MenuItem Header="{Binding OpenFolderCaption}" IsEnabled="{Binding HasAccounts}" x:Name="OpenPithosFolder" ItemsSource="{Binding Accounts}" >                        
                         <MenuItem.ItemTemplate>
                             <DataTemplate>
+                                <StackPanel>
                                 <TextBlock x:Name="AccountLink"  Text="{Binding Path=UserName}" cal:Message.Attach="[Event MouseLeftButtonUp]=[Action OpenPithosFolder($dataContext)]" 
                                            cal:Action.TargetWithoutContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=MenuItem, AncestorLevel=2}, Path=DataContext}" />
+                                    <TextBlock Text="{Binding Path=StorageUri}" FontStyle="Italic" FontSize="10" />
+                                </StackPanel>
                             </DataTemplate>
                         </MenuItem.ItemTemplate>                        
                         <MenuItem.Icon>
                     <MenuItem Header="Go to Account Site" x:Name="GoToSiteMenu" ItemsSource="{Binding Accounts}" Visibility="{Binding Path=HasAccounts, Converter={StaticResource BooleanToVisible}}" >
                         <MenuItem.ItemTemplate>
                             <DataTemplate>
-                                <TextBlock x:Name="AccountLink" Text="{Binding Path=UserName}" cal:Message.Attach="[Event MouseLeftButtonUp]=[Action GoToSite($dataContext)]" 
-                                           cal:Action.TargetWithoutContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=MenuItem, AncestorLevel=2}, Path=DataContext}" />
+                                <StackPanel>
+                                    <TextBlock x:Name="AccountLink" Text="{Binding Path=UserName}" cal:Message.Attach="[Event MouseLeftButtonUp]=[Action GoToSite($dataContext)]" 
+                                               cal:Action.TargetWithoutContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=MenuItem, AncestorLevel=2}, Path=DataContext}" />
+                                    <TextBlock Text="{Binding Path=StorageUri}" FontStyle="Italic" FontSize="10" />
+                                </StackPanel>
                             </DataTemplate>
                         </MenuItem.ItemTemplate>
                         <MenuItem.Icon>
index da44496..96a650c 100644 (file)
@@ -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);
 
                }