Revision 311d1cde

b/trunk/NetSparkle/NetSparkle.cs
557 557
                // check if update is required
558 558
                NetSparkleAppCastItem latestVersion = null;
559 559
                bUpdateRequired = IsUpdateRequired(config, out latestVersion);
560
                this.LatestVersion = latestVersion.Version;                
560
                this.LatestVersion = latestVersion.Version??"";                
561 561
                if (!bUpdateRequired)
562 562
                    goto WaitSection;
563 563

  
b/trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml
73 73
                                <DataTemplate>
74 74
                                    <StackPanel Orientation="Horizontal">
75 75
                                    <Image Visibility="{Binding Converter={StaticResource BoolToVisible}, Path=IsExpired,Mode=OneWay}" Source="/PithosPlus;component/Images/SmallWarning.png" Margin="2,0"/>
76
                                        <StackPanel>
76 77
                                    <TextBlock Text="{Binding AccountName}" />
78
                                    <TextBlock Text="{Binding ServerUrl}" FontStyle="Italic" FontSize="10" />
79
                                        </StackPanel>
77 80
                                    </StackPanel>
78 81
                                </DataTemplate>
79 82
                            </ListBox.ItemTemplate>
b/trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
58 58
using Pithos.Interfaces;
59 59
using System;
60 60
using System.Linq;
61
using MessageBox = System.Windows.MessageBox;
61 62
using Screen = Caliburn.Micro.Screen;
62 63

  
63 64
namespace Pithos.Client.WPF.Preferences
......
243 244
                    return;
244 245
                //The server will return credentials for a different account, not just the current account
245 246
                //We need to find the correct account first
246
                var account = Accounts.First(act => act.AccountName == credentials.UserName && act.ServerUrl == ?? );
247
                var account = Accounts.First(act => act.AccountName == credentials.UserName && act.ServerUrl == CurrentAccount.ServerUrl);
247 248
                account.ApiKey = credentials.Password;                
248 249
                account.IsExpired = false;
249 250
                Settings.Save();
......
379 380
                       actualRootPath = String.Format("{0} {1}", initialRootPath, attempt++);
380 381
                   }
381 382
               }
382
               ### Check that the account does not already exist
383

  
384
               var newAccount = new AccountSettings
385
                                    {
386
                                        AccountName = wizard.AccountName,
387
                                        ServerUrl=wizard.CurrentServer,
388
                                        ApiKey=wizard.Token,
389
                                        RootPath = actualRootPath,
390
                                        IsActive=wizard.IsAccountActive
391
                                    };
392
               _accountsToAdd.Add(newAccount);
393
               var accountVm = new AccountViewModel(newAccount);
394
               (Accounts as IProducerConsumerCollection<AccountViewModel>).TryAdd(accountVm);
395
               CurrentAccount = accountVm;
383

  
384

  
385

  
386
               var account = Accounts.FirstOrDefault(act => act.AccountName == wizard.AccountName && act.ServerUrl == wizard.CurrentServer);
387
               if (account != null)
388
               {
389
                   if (MessageBox.Show("The account you specified already exists. Do you want to update it?","The account exists") == MessageBoxResult.Yes)
390
                   {
391
                       account.ApiKey = wizard.Token;
392
                       account.IsExpired = false;
393
                       CurrentAccount = account;
394
                   }
395
               }
396
               else
397
               {
398
                   var newAccount = new AccountSettings
399
                                        {
400
                                            AccountName = wizard.AccountName,
401
                                            ServerUrl = wizard.CurrentServer,
402
                                            ApiKey = wizard.Token,
403
                                            RootPath = actualRootPath,
404
                                            IsActive = wizard.IsAccountActive
405
                                        };
406
                   _accountsToAdd.Add(newAccount);
407
                   var accountVm = new AccountViewModel(newAccount);
408
                   (Accounts as IProducerConsumerCollection<AccountViewModel>).TryAdd(accountVm);
409
                   CurrentAccount = accountVm;
410
               }
396 411
               NotifyOfPropertyChange(() => Accounts);
397 412
               NotifyOfPropertyChange(() => Settings);   
398 413
           }
b/trunk/Pithos.Client.WPF/Shell/ShellView.xaml
41 41
                    <MenuItem Header="{Binding OpenFolderCaption}" IsEnabled="{Binding HasAccounts}" x:Name="OpenPithosFolder" ItemsSource="{Binding Accounts}" >                        
42 42
                        <MenuItem.ItemTemplate>
43 43
                            <DataTemplate>
44
                                <StackPanel>
44 45
                                <TextBlock x:Name="AccountLink"  Text="{Binding Path=UserName}" cal:Message.Attach="[Event MouseLeftButtonUp]=[Action OpenPithosFolder($dataContext)]" 
45 46
                                           cal:Action.TargetWithoutContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=MenuItem, AncestorLevel=2}, Path=DataContext}" />
47
                                    <TextBlock Text="{Binding Path=StorageUri}" FontStyle="Italic" FontSize="10" />
48
                                </StackPanel>
46 49
                            </DataTemplate>
47 50
                        </MenuItem.ItemTemplate>                        
48 51
                        <MenuItem.Icon>
......
52 55
                    <MenuItem Header="Go to Account Site" x:Name="GoToSiteMenu" ItemsSource="{Binding Accounts}" Visibility="{Binding Path=HasAccounts, Converter={StaticResource BooleanToVisible}}" >
53 56
                        <MenuItem.ItemTemplate>
54 57
                            <DataTemplate>
55
                                <TextBlock x:Name="AccountLink" Text="{Binding Path=UserName}" cal:Message.Attach="[Event MouseLeftButtonUp]=[Action GoToSite($dataContext)]" 
56
                                           cal:Action.TargetWithoutContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=MenuItem, AncestorLevel=2}, Path=DataContext}" />
58
                                <StackPanel>
59
                                    <TextBlock x:Name="AccountLink" Text="{Binding Path=UserName}" cal:Message.Attach="[Event MouseLeftButtonUp]=[Action GoToSite($dataContext)]" 
60
                                               cal:Action.TargetWithoutContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=MenuItem, AncestorLevel=2}, Path=DataContext}" />
61
                                    <TextBlock Text="{Binding Path=StorageUri}" FontStyle="Italic" FontSize="10" />
62
                                </StackPanel>
57 63
                            </DataTemplate>
58 64
                        </MenuItem.ItemTemplate>
59 65
                        <MenuItem.Icon>
b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
835 835
				account.SiteUri, Uri.EscapeDataString(account.Token),
836 836
				Uri.EscapeDataString(account.UserName));
837 837

  
838
			if (Accounts.All(item => item.UserName != account.UserName))
838
			if (!Accounts.Any(item => item.UserName == account.UserName && item.SiteUri == account.SiteUri))
839 839
				Accounts.TryAdd(account);
840 840

  
841 841
		}

Also available in: Unified diff