Updated wizard and AccountInfo to include the server's URL. Added account validation...
authorPanagiotis Kanavos <pkanavos@gmail.com>
Tue, 13 Dec 2011 21:09:21 +0000 (23:09 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Tue, 13 Dec 2011 21:09:21 +0000 (23:09 +0200)
18 files changed:
trunk/Pithos.Client.WPF/App.xaml.cs
trunk/Pithos.Client.WPF/Configuration/PithosSettings.cs
trunk/Pithos.Client.WPF/FileProperties/FilePropertiesViewModel.cs
trunk/Pithos.Client.WPF/Preferences/AddAccountView.xaml
trunk/Pithos.Client.WPF/Preferences/AddAccountView.xaml.cs
trunk/Pithos.Client.WPF/Preferences/AddAccountViewModel.cs
trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
trunk/Pithos.Client.WPF/Properties/Settings.Designer.cs
trunk/Pithos.Client.WPF/Properties/Settings.settings
trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
trunk/Pithos.Client.WPF/app.config
trunk/Pithos.Interfaces/AccountSettings.cs
trunk/Pithos.Interfaces/IPithosSettings.cs
trunk/Pithos.Interfaces/PithosSettingsData.cs
trunk/Pithos.Network.Test/CloudFilesClientTest.cs
trunk/Pithos.ShellExtensions/Menus/FileContextMenu.cs
trunk/Pithos.ShellExtensions/ShellSettings.cs
trunk/Pithos.sln

index 9b262ed..7ffbacb 100644 (file)
@@ -21,23 +21,17 @@ namespace Pithos.Client.WPF
     /// </summary>
     public partial class App : Application
     {
-        private log4net.ILog Log = log4net.LogManager.GetLogger(typeof (App));
+        private readonly log4net.ILog _log = log4net.LogManager.GetLogger(typeof (App));
+
         public App()
         {
-            //var extensionController = new ShellExtensionController();
-            //extensionController.RegisterExtensions();
             log4net.Config.XmlConfigurator.Configure();            
-
+            
             this.DispatcherUnhandledException += OnUnhandledException;
             AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
             TaskScheduler.UnobservedTaskException += OnUnobservedException;
 
-/*
-            var appPatth =    Assembly.GetExecutingAssembly().Location;
-            Registry.LocalMachine.SetValue(@"Software\Pithos\AppPath",appPatth );            
-*/
             InitializeComponent();            
-            //Application.Current.ApplyTheme("BureauBlue");
         }
 
         private void OnUnobservedException(object sender, UnobservedTaskExceptionEventArgs e)
@@ -104,15 +98,7 @@ namespace Pithos.Client.WPF
         {
             var logMessage = CreateMessage(messages);
 
-            Log.Error(logMessage);
-        }
-
-        private async void SendMessages(IEnumerable<UserMessage> messages )
-        {
-            var logMessage = CreateMessage(messages);
-
-            var mailer = new SmtpClient();
-            await mailer.SendTaskAsync("pithos@grnet.gr", "support@pithos.grnet.gr", "Errors", logMessage);
+            _log.Error(logMessage);
         }
 
         private static string CreateMessage(IEnumerable<UserMessage> messages)
index 32218d9..7724632 100644 (file)
@@ -21,94 +21,101 @@ namespace Pithos.Client.WPF.Configuration
     [Export]
     public class PithosSettings :  IPithosSettings
     {
+        private readonly Settings _settings = Settings.Default;
+
         public bool UseDefaultProxy
         {
-            get { return Settings.Default.UseDefaultProxy; }
-            set { Settings.Default.UseDefaultProxy = value; }
+            get { return _settings.UseDefaultProxy; }
+            set { _settings.UseDefaultProxy = value; }
         }
 
         public bool UseManualProxy
         {
-            get { return Settings.Default.UseManualProxy; }
-            set { Settings.Default.UseManualProxy = value; }
+            get { return _settings.UseManualProxy; }
+            set { _settings.UseManualProxy = value; }
         }
 
         public bool UseNoProxy
         {
-            get { return Settings.Default.UseNoProxy; }
-            set { Settings.Default.UseNoProxy = value; }
+            get { return _settings.UseNoProxy; }
+            set { _settings.UseNoProxy = value; }
         }
 
         public string PithosPath
         {
-            get { return Settings.Default.PithosPath; }
-            set { Settings.Default.PithosPath = value; }
+            get { return _settings.PithosPath; }
+            set { _settings.PithosPath = value; }
         }
 
-        public string PithosSite
+      /*  public string PithosSite
         {
-            get { return Settings.Default.PithosSite; }
-        }
+            get { return _settings.PithosSite; }
+        }*/
 
         public string PithosLoginUrl
         {
-            get { return Settings.Default.PithosLoginUrl; }
+            get { return _settings.PithosLoginUrl; }
         }
 
         public string IconsPath
         {
-            get { return Settings.Default.IconPath; }
-            set { Settings.Default.IconPath = value; }
+            get { return _settings.IconPath; }
+            set { _settings.IconPath = value; }
         }
 
         public string UserName
         {
-            get { return Settings.Default.UserName; }
-            set { Settings.Default.UserName = value; }
+            get { return _settings.UserName; }
+            set { _settings.UserName = value; }
         }
 
         public string ApiKey
         {
-            get { return Settings.Default.ApiKey; }
-            set { Settings.Default.ApiKey = value; }
+            get { return _settings.ApiKey; }
+            set { _settings.ApiKey = value; }
         }
 
         public AccountsCollection Accounts
         {
-            get { return Settings.Default.Accounts; }
-            set { Settings.Default.Accounts = value; }
+            get
+            {
+                if (_settings.Accounts==null)
+                    _settings.Accounts=new AccountsCollection();
+                return _settings.Accounts;
+            }
+            set { _settings.Accounts = value; }
         }
 
         public string ProxyServer
         {
-            get { return Settings.Default.ProxyServer; }
-            set { Settings.Default.ProxyServer = value; }
+            get { return _settings.ProxyServer; }
+            set { _settings.ProxyServer = value; }
         }
 
         public int ProxyPort
         {
-            get { return Settings.Default.ProxyPort; }
-            set { Settings.Default.ProxyPort = value; }
+            get { return _settings.ProxyPort; }
+            set { _settings.ProxyPort = value; }
         }
 
         public string ProxyUsername
         {
-            get { return Settings.Default.ProxyUsername; }
-            set { Settings.Default.ProxyUsername = value; }
+            get { return _settings.ProxyUsername; }
+            set { _settings.ProxyUsername = value; }
         }
 
 
         public string ProxyPassword
         {
-            get { return Settings.Default.ProxyPassword; }
-            set { Settings.Default.ProxyPassword = value; }
+            get { return _settings.ProxyPassword; }
+            set { _settings.ProxyPassword = value; }
         }
 
         public bool ProxyAuthentication
         {
 
-            get { return Settings.Default.ProxyAuthentication; }
-            set { Settings.Default.ProxyAuthentication = value; }
+            get { return _settings.ProxyAuthentication; }
+            set { _settings.ProxyAuthentication = value; }
         }
 
         
@@ -116,26 +123,26 @@ namespace Pithos.Client.WPF.Configuration
         public bool ExtensionsActivated
         {
 
-            get { return Settings.Default.ExtensionsActivated; }
-            set { Settings.Default.ExtensionsActivated = value; }
+            get { return _settings.ExtensionsActivated; }
+            set { _settings.ExtensionsActivated = value; }
         }
 
         public bool ShowDesktopNotifications
         {
-            get { return Settings.Default.ShowDesktopNotifications; }
-            set { Settings.Default.ShowDesktopNotifications = value; }
+            get { return _settings.ShowDesktopNotifications; }
+            set { _settings.ShowDesktopNotifications = value; }
         }
 /*
         public override IEnumerable<string> GetDynamicMemberNames()
         {
-            return (from SettingsProperty property in Settings.Default.Properties
+            return (from SettingsProperty property in _settings.Properties
                         select property.Name);
         }
 
 
         private Lazy<ILookup<string, SettingsProperty>> _propertyNames = new Lazy<ILookup<string, SettingsProperty>>(
             () => (from SettingsProperty property in
-                       Settings.Default.Properties
+                       _settings.Properties
                    select property).ToLookup(property => property.Name));
 
         public override bool TryGetMember(GetMemberBinder binder, out object result)
@@ -143,19 +150,19 @@ namespace Pithos.Client.WPF.Configuration
             result = null;
             if (!_propertyNames.Value.Contains(binder.Name))
                 return false;
-            result=Settings.Default.Properties[binder.Name];
+            result=_settings.Properties[binder.Name];
             return true;
         }
 */
 
         public void Save()
         {
-            Settings.Default.Save();
+            _settings.Save();
         }
 
         public void Reload()
         {
-            Settings.Default.Reload();
+            _settings.Reload();
         }
     }
 }
index 7e3313f..cb3c577 100644 (file)
@@ -322,7 +322,7 @@ namespace Pithos.Client.WPF
                 Manifest = value.Manifest;
                 IsPublic = value.IsPublic;
                 if (IsPublic)
-                    PublicUrl = String.Format("{0}/v1{1}", Settings.Default.PithosSite ,value.PublicUrl);
+                    PublicUrl = String.Format("{0}/v1{1}", Shell.Accounts.First(account=>account.UserName==PithosFile.Account).SiteUri,value.PublicUrl);
 
                 using (var icon = Icon.ExtractAssociatedIcon(LocalFileName))
                 {
index c2d822d..97312c8 100644 (file)
         <extToolkit:WizardPage x:Name="IntroPage" 
                                    Title="Add new Pithos Account"
                                    Description="This Wizard will walk you through adding a new Pithos account and retrieving an authentication token" />
+        <extToolkit:WizardPage x:Name="ChooseServer" PageType="Interior"
+                                   Title="Where do you want to connect?"
+                                   Description="You can connect to the production or development server, or enter your own server URL"                               
+                                    CanSelectNextPage="{Binding IsValidServer}"
+                                    >
+            <StackPanel >
+                <Label Content="Pithos Server" Target="{Binding ElementName=Servers}"  />
+                <ComboBox x:Name="Servers" IsEditable="True" ItemsSource="{Binding Servers}"
+                          Text="{Binding CurrentServer,ValidatesOnExceptions=True, Mode=TwoWay}" >                        
+                    <Validation.ErrorTemplate>
+                        <ControlTemplate>
+                            <StackPanel>
+                                <AdornedElementPlaceholder />
+                                <TextBlock Foreground="Red" >Invalid Path</TextBlock>
+                            </StackPanel>
+                        </ControlTemplate>
+                    </Validation.ErrorTemplate>
+                </ComboBox>                
+            </StackPanel>
+        </extToolkit:WizardPage>
         <extToolkit:WizardPage x:Name="ChooseMethodPage" PageType="Interior"
                                    Title="How do you want to add the account?"
                                    Description="You can add an account either by logging in the Pithos Web Site or by entering your username and password manually"                               
         </extToolkit:WizardPage>
         <extToolkit:WizardPage x:Name="ManualAccountPage" PageType="Interior"
                                    Title="Add an account manually"
-                                   Description="This is the second page in the process"
+                                   Description="Please enter the account credentials and press &quot;Validate Credentials&quot;"
                                NextPage="{Binding ElementName=AccountPathPage}"                               
-                               CanSelectNextPage="{Binding HasCredentials}"
+                               CanSelectNextPage="{Binding HasValidCredentials}" 
                                >
-            <Grid>
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="Auto"/>
-                    <ColumnDefinition Width="91*"/>
-                </Grid.ColumnDefinitions>
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="Auto"/>
-                    <RowDefinition Height="Auto"/>
-                    <RowDefinition />
-                </Grid.RowDefinitions>
-                <Label Content="Account" Grid.Column="0" Grid.Row="0" Margin="0,5" HorizontalAlignment="Left"/>
-                <TextBox Name="AccountName" Grid.Column="1" Grid.Row="0" Margin="5"/>
-                <Label Content="API Key" Grid.Column="0" Grid.Row="1" Margin="0,5" HorizontalAlignment="Left"/>
-                <TextBox  Name="Token" Grid.Column="1" Grid.Row="1" Margin="5"/>
-            </Grid>
+            <extToolkit:BusyIndicator x:Name="ManualBusyIndicator" IsBusy="{Binding IsValidating,NotifyOnSourceUpdated=true}" DisplayAfter="0" >
+                <extToolkit:BusyIndicator.BusyContent>
+                    <TextBlock x:Name="ManualBusyMessage" Text="Validating credentials"  />
+                </extToolkit:BusyIndicator.BusyContent>
+                <extToolkit:BusyIndicator.Content>
+                    <Grid>
+                        <Grid.ColumnDefinitions>
+                            <ColumnDefinition Width="Auto"/>
+                            <ColumnDefinition Width="91*"/>
+                        </Grid.ColumnDefinitions>
+                        <Grid.RowDefinitions>
+                            <RowDefinition Height="Auto"/>
+                            <RowDefinition Height="Auto"/>
+                            <RowDefinition Height="Auto"/>
+                            <RowDefinition />
+                        </Grid.RowDefinitions>
+                        <Label Content="Account" Grid.Column="0" Grid.Row="0" Margin="0,5" HorizontalAlignment="Left"/>
+                        <TextBox Name="AccountName" Grid.Column="1" Grid.Row="0" Margin="5"/>
+                        <Label Content="API Key" Grid.Column="0" Grid.Row="1" Margin="0,5" HorizontalAlignment="Left"/>
+                        <TextBox  Name="Token" Grid.Column="1" Grid.Row="1" Margin="5"/>
+                        <Button x:Name="TestManualAccount" Content="Validate Credentials" IsEnabled="{Binding HasCredentials}" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" cal:Message.Attach="TestAccount" Margin="5"/>
+                    </Grid>
+                </extToolkit:BusyIndicator.Content>
+            </extToolkit:BusyIndicator>
         </extToolkit:WizardPage>
         <extToolkit:WizardPage x:Name="AutoAccountPage" PageType="Interior"
                                    Title="Add an account automatically"
                                    Description="By clicking on the button below you will be taken to the Pithos web site where you can login with your username and password."
                                NextPage="{Binding ElementName=AutoConfirmedPage}"                               
-                               CanSelectNextPage="{Binding IsConfirmed}"
+                               CanSelectNextPage="{Binding HasValidCredentials}"
                                cal:Message.Attach="[Event GotFocus] = [Action RetrieveCredentials()]"
                                >
             <extToolkit:BusyIndicator IsBusy="{Binding IsRetrieving}">
@@ -63,6 +92,7 @@
                         <Button Margin="5" Name="RetrieveCredentials" Content="Retrieve Credentials" Width="150"/>
 
                         <TextBlock Text="Credentials Retrieved Succesfully" Visibility="{Binding Converter={StaticResource BoolToVisible}, Path=HasCredentials}" Margin="10" HorizontalAlignment="Center"/>
+                        <Button x:Name="TestAutoAccount" Content="Validate Credentials" IsEnabled="{Binding HasCredentials}" HorizontalAlignment="Center" cal:Message.Attach="TestAccount" Margin="5"/>
                     </StackPanel>
                 </extToolkit:BusyIndicator.Content>
                 </extToolkit:BusyIndicator>
                     <RowDefinition Height="Auto"/>
                     <RowDefinition Height="Auto"/>
                     <RowDefinition Height="Auto"/>
+                    <RowDefinition Height="Auto"/>
                     <RowDefinition />
                 </Grid.RowDefinitions>
                 <Grid.ColumnDefinitions>
                 <TextBlock Text="{Binding Token}" Grid.Column="1" Grid.Row="1" Margin="5,2"/>
                 <TextBlock Text="Account Path:" Grid.Column="0" Grid.Row="2" Margin="5,2"/>
                 <TextBlock Text="{Binding AccountPath}" Grid.Column="1" Grid.Row="2" Margin="5,2"/>
-                
-            <CheckBox x:Name="IsAccountActive" Content="Start using the account immediatelly" Grid.ColumnSpan="2" Grid.Row="3" Margin="5"/>
+
+                <CheckBox x:Name="IsAccountActive" Content="Start using the account immediatelly" Grid.ColumnSpan="2" Grid.Row="4" Margin="5"/>
             </Grid>
         </extToolkit:WizardPage>
     </extToolkit:Wizard>
index 4ebb6e2..5f4aa9b 100644 (file)
@@ -21,9 +21,13 @@ namespace Pithos.Client.WPF.Preferences
     {
         public AddAccountView()
         {
-            InitializeComponent();            
+            InitializeComponent();
+            
+            //When the busy indicator changes, force a focus change. Workaround for delayed change of the Next button's visibility
+            ManualBusyMessage.IsVisibleChanged += (sender, evt) => Token.Focus(); ;
         }
 
+
         private void Automatic_Checked(object sender, RoutedEventArgs e)
         {
             ChooseMethodPage.NextPage = AutoAccountPage;
index d835cf4..c295e4b 100644 (file)
@@ -5,11 +5,14 @@ using System.ComponentModel.Composition;
 using System.IO;
 using System.Linq;
 using System.Text;
+using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Forms;
+using Caliburn.Micro;
 using Pithos.Client.WPF.Properties;
 using Pithos.Core;
+using Pithos.Network;
 using MessageBox = System.Windows.MessageBox;
 using Screen = Caliburn.Micro.Screen;
 
@@ -18,6 +21,45 @@ namespace Pithos.Client.WPF.Preferences
     [Export(typeof(AddAccountViewModel))]
     public class AddAccountViewModel:Screen
     {
+
+        private readonly List<string> _servers;
+
+        public List<string> Servers
+        {
+            get { return _servers; }
+        }
+
+        private bool _isValidServer;
+        public bool IsValidServer
+        {
+            get { return _isValidServer; }
+            set
+            {
+                _isValidServer = value;
+                NotifyOfPropertyChange(()=>IsValidServer);
+            }
+        }
+
+
+        private string _currentServer;
+        public string CurrentServer
+        {
+            get { return _currentServer; }
+            set
+            {
+                if (!Uri.IsWellFormedUriString(value, UriKind.Absolute))
+                {
+                    IsValidServer = false;
+                    throw new UriFormatException();
+                }
+                _currentServer = value;
+                IsValidServer = true;
+                HasValidCredentials = false;
+                IsConfirmed = false;
+                NotifyOfPropertyChange(()=>CurrentServer);
+            }
+        }
+
         private string _accountName;
         public string AccountName
         {
@@ -74,6 +116,7 @@ namespace Pithos.Client.WPF.Preferences
             set
             {
                 _isConfirmed = value;
+                HasValidCredentials = false;
                 NotifyOfPropertyChange(() => IsConfirmed);
             }
         }
@@ -139,7 +182,64 @@ namespace Pithos.Client.WPF.Preferences
             IsRetrieving = false;
 
         }
-        
+
+        public AddAccountViewModel()
+        {
+            _servers=new List<string>
+                         {
+                             Settings.Default.ProductionServer, 
+                             Settings.Default.DevelopmentServer
+                         };
+            CurrentServer = _servers[0];
+        }
+
+        private bool _hasValidCredentials;
+        public bool HasValidCredentials
+        {
+            get { return _hasValidCredentials; }
+            set
+            {
+                _hasValidCredentials = value;
+                NotifyOfPropertyChange(()=>HasValidCredentials);
+            }
+        }
+
+
+        private bool _isValidating;
+        public bool IsValidating
+        {
+            get { return _isValidating; }
+            set
+            {
+                _isValidating = value;
+                NotifyOfPropertyChange(()=>IsValidating);
+            }
+        }
+
+        public async void TestAccount()
+        {
+            try
+            {
+                IsValidating = true;
+                var client = new CloudFilesClient(AccountName, Token) {AuthenticationUrl = CurrentServer};                
+                var containers = await TaskEx.Run(()=>
+                                                      {
+                                                          client.Authenticate();
+                                                          return client.ListContainers(AccountName);
+                                                      });
+                HasValidCredentials = true;                
+            }
+            catch (Exception ex)
+            {
+                HasValidCredentials = false;
+                MessageBox.Show("The account is not valid", "Account Error", MessageBoxButton.OK, MessageBoxImage.Stop);
+                throw;
+            }
+            finally
+            {
+                IsValidating = false;
+            }
+        }
 
     }
 }
index 1a9602f..4092792 100644 (file)
@@ -85,6 +85,11 @@ namespace Pithos.Client.WPF
 
             Settings=settings;
             Accounts = new ObservableConcurrentCollection<AccountSettings>();
+            if (settings.Accounts == null)
+            {
+                settings.Accounts=new AccountsCollection();
+                settings.Save();
+            }
             Accounts.AddFromEnumerable(settings.Accounts);
             
             var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
@@ -232,6 +237,7 @@ namespace Pithos.Client.WPF
                var newAccount = new AccountSettings
                                     {
                                         AccountName = wizard.AccountName,
+                                        ServerUrl=new Uri(wizard.CurrentServer),
                                         ApiKey=wizard.Token,
                                         RootPath=wizard.AccountPath,
                                         IsActive=wizard.IsAccountActive,
index deca943..df2bd9e 100644 (file)
@@ -205,24 +205,6 @@ namespace Pithos.Client.WPF.Properties {
         
         [global::System.Configuration.ApplicationScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("http://pithos.dev.grnet.gr")]
-        public string PithosSite {
-            get {
-                return ((string)(this["PithosSite"]));
-            }
-        }
-        
-        [global::System.Configuration.ApplicationScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("https://pithos.dev.grnet.gr")]
-        public string PithosAuthenticationUrl {
-            get {
-                return ((string)(this["PithosAuthenticationUrl"]));
-            }
-        }
-        
-        [global::System.Configuration.ApplicationScopedSettingAttribute()]
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [global::System.Configuration.DefaultSettingValueAttribute("https://auth.api.rackspacecloud.com")]
         public string CloudfilesAuthenticationUrl {
             get {
@@ -260,10 +242,26 @@ namespace Pithos.Client.WPF.Properties {
             }
         }
         
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("http://plus.pithos.grnet.gr")]
+        public string ProductionServer {
+            get {
+                return ((string)(this["ProductionServer"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("http://pithos.dev.grnet.gr")]
+        public string DevelopmentServer {
+            get {
+                return ((string)(this["DevelopmentServer"]));
+            }
+        }
+        
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("\r\n          <ArrayOfAccountSettings xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-i" +
-            "nstance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" />\r\n        ")]
         public global::Pithos.Interfaces.AccountsCollection Accounts {
             get {
                 return ((global::Pithos.Interfaces.AccountsCollection)(this["Accounts"]));
index 163cf77..a0e270c 100644 (file)
     <Setting Name="UseManualProxy" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">False</Value>
     </Setting>
-    <Setting Name="PithosSite" Type="System.String" Scope="Application">
-      <Value Profile="(Default)">http://pithos.dev.grnet.gr</Value>
-    </Setting>
-    <Setting Name="PithosAuthenticationUrl" Type="System.String" Scope="Application">
-      <Value Profile="(Default)">https://pithos.dev.grnet.gr</Value>
-    </Setting>
     <Setting Name="CloudfilesAuthenticationUrl" Type="System.String" Scope="Application">
       <Value Profile="(Default)">https://auth.api.rackspacecloud.com</Value>
     </Setting>
     <Setting Name="FeedbackUri" Type="System.String" Scope="Application">
       <Value Profile="(Default)">http://pithos.dev.grnet.gr/tools/feedback</Value>
     </Setting>
-    <Setting Name="Accounts" Type="Pithos.Interfaces.AccountsCollection" Scope="User">
-      <Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
-&lt;ArrayOfAccountSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /&gt;</Value>
-    </Setting>
     <Setting Name="MustUpgrade" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">True</Value>
     </Setting>
+    <Setting Name="ProductionServer" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">http://plus.pithos.grnet.gr</Value>
+    </Setting>
+    <Setting Name="DevelopmentServer" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">http://pithos.dev.grnet.gr</Value>
+    </Setting>
+    <Setting Name="Accounts" Type="Pithos.Interfaces.AccountsCollection" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
   </Settings>
 </SettingsFile>
\ No newline at end of file
index da7cf3c..0ebfa5c 100644 (file)
@@ -131,7 +131,14 @@ namespace Pithos.Client.WPF {
         private async Task StartMonitoring()
         {
             try
-            {                
+            {
+                if (Settings.Accounts == null)
+                {
+                    Settings.Accounts=new AccountsCollection();
+                    Settings.Save();
+                    return;
+                }
+                  
                 foreach (var account in Settings.Accounts)
                 {
                     await MonitorAccount(account);
@@ -196,7 +203,7 @@ namespace Pithos.Client.WPF {
 
                 var appSettings = Properties.Settings.Default;
                 monitor.AuthenticationUrl = account.UsePithos
-                                                ? appSettings.PithosAuthenticationUrl
+                                                ? account.ServerUrl.ToString()
                                                 : appSettings.CloudfilesAuthenticationUrl;
 
                 _monitors[accountName] = monitor;
@@ -326,16 +333,18 @@ namespace Pithos.Client.WPF {
         }
 
         
+/*
         public void GoToSite()
         {            
             var site = Properties.Settings.Default.PithosSite;
             Process.Start(site);            
         }
+*/
 
         public void GoToSite(AccountInfo account)
         {
             var site = String.Format("{0}/ui/?token={1}&user={2}",
-                Properties.Settings.Default.PithosSite,account.Token,
+                account.SiteUri,account.Token,
                 account.UserName);
             Process.Start(site);
         }
@@ -624,7 +633,7 @@ namespace Pithos.Client.WPF {
                 return;
 
             account.SiteUri= String.Format("{0}/ui/?token={1}&user={2}",
-                Properties.Settings.Default.PithosSite, account.Token,
+                account.SiteUri, account.Token,
                 account.UserName);
 
             IProducerConsumerCollection<AccountInfo> accounts = Accounts;
index 02ad288..93fd18a 100644 (file)
       <setting name="UseManualProxy" serializeAs="String">
         <value>False</value>
       </setting>
-      <setting name="Accounts" serializeAs="Xml">
-        <value>
-          <ArrayOfAccountSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-            xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
-        </value>
-      </setting>
       <setting name="MustUpgrade" serializeAs="String">
         <value>True</value>
       </setting>
   </startup>
   <applicationSettings>
     <Pithos.Client.WPF.Properties.Settings>
-      <setting name="PithosSite" serializeAs="String">
-        <value>http://pithos.dev.grnet.gr</value>
-      </setting>
-      <setting name="PithosAuthenticationUrl" serializeAs="String">
-        <value>https://pithos.dev.grnet.gr</value>
-      </setting>
       <setting name="CloudfilesAuthenticationUrl" serializeAs="String">
         <value>https://auth.api.rackspacecloud.com</value>
       </setting>
       <setting name="FeedbackUri" serializeAs="String">
         <value>http://pithos.dev.grnet.gr/tools/feedback</value>
       </setting>
+      <setting name="ProductionServer" serializeAs="String">
+        <value>http://plus.pithos.grnet.gr</value>
+      </setting>
+      <setting name="DevelopmentServer" serializeAs="String">
+        <value>http://pithos.dev.grnet.gr</value>
+      </setting>
     </Pithos.Client.WPF.Properties.Settings>
   </applicationSettings>
   <log4net>
index ab70d85..8dbe346 100644 (file)
@@ -28,6 +28,8 @@ namespace Pithos.Interfaces
 
         public string RootPath { get; set; }
 
+        public Uri ServerUrl { get; set; }
+
         private StringCollection _selectiveFolders = new StringCollection();
 
         
index fa17661..40060ae 100644 (file)
@@ -8,7 +8,6 @@ namespace Pithos.Interfaces
     public interface IPithosSettings
     {
         string PithosPath { get; set; }
-        string PithosSite { get;  }
         string IconsPath { get; set; }
         string UserName { get; set; }
         string ApiKey { get; set; }
index a361762..fa56260 100644 (file)
@@ -45,7 +45,6 @@ namespace Pithos.Interfaces
             Contract.EndContractBlock();
 
             PithosPath = other.PithosPath;
-            PithosSite = other.PithosSite;
             IconsPath = other.IconsPath;
             UserName = other.UserName;
             ApiKey = other.ApiKey;
index d8d1af6..407c8c9 100644 (file)
@@ -27,6 +27,25 @@ namespace Pithos.Network.Test
 
             Assert.AreEqual(0,result.Count);
         }
+        
+        [Test]
+        public void TestAuthentication()
+        {
+            var account = "ikons@cslab.ece.ntua.gr";
+            var apiKey = "fKzKaRd7Uhov+xca4B4rOQ==";
+            var client = new CloudFilesClient(account, apiKey)
+            {
+                                 AuthenticationUrl = @"https://plus.pithos.grnet.gr", 
+                                 UsePithos = true
+                             };
+            var accountInfo=client.Authenticate();
+            var containers=client.ListContainers(accountInfo.UserName);
+            Assert.IsNotNull(containers);
+            var result=client.GetAccountPolicies(accountInfo);
+
+            Assert.IsNotNull(accountInfo);
+            Assert.IsNotNull(result);
+        }
 
 
        
index 7bca0e6..ca2740f 100644 (file)
@@ -152,7 +152,7 @@ namespace Pithos.ShellExtensions.Menus
             var settings = Context.Settings;
             var activeAccount = settings.Accounts.FirstOrDefault(acc =>  Context.CurrentFile.StartsWith(acc.RootPath,StringComparison.InvariantCultureIgnoreCase));
             var address = String.Format("{0}/ui/?token={1}&user={2}",
-                                        settings.PithosSite,
+                                        activeAccount.ServerUrl,
                                         activeAccount.ApiKey,
                                         Uri.EscapeUriString(activeAccount.AccountName));
 
index beb3046..5d315d8 100644 (file)
@@ -55,10 +55,12 @@ namespace Pithos.ShellExtensions
             set { _settings.Value.PithosPath = value; }
         }
 
+/*
         public string PithosSite
         {
             get { return _settings.Value.PithosSite; }
         }
+*/
 
         public string IconsPath
         {
index 4d8428b..af6065e 100644 (file)
@@ -494,7 +494,6 @@ Global
                {C6251981-3C49-404B-BB5B-9732887388D2}.Debug|Any CPU.ActiveCfg = Debug
                {C6251981-3C49-404B-BB5B-9732887388D2}.Debug|Mixed Platforms.ActiveCfg = Debug
                {C6251981-3C49-404B-BB5B-9732887388D2}.Debug|x64.ActiveCfg = Debug
-               {C6251981-3C49-404B-BB5B-9732887388D2}.Debug|x64.Build.0 = Debug
                {C6251981-3C49-404B-BB5B-9732887388D2}.Debug|x86.ActiveCfg = Debug
                {C6251981-3C49-404B-BB5B-9732887388D2}.Premium Debug|Any CPU.ActiveCfg = Premium Debug
                {C6251981-3C49-404B-BB5B-9732887388D2}.Premium Debug|Mixed Platforms.ActiveCfg = Premium Debug