Account page changes
authorPanagiotis Kanavos <pkanavos@gmail.com>
Wed, 7 Mar 2012 18:48:45 +0000 (20:48 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Wed, 7 Mar 2012 18:48:45 +0000 (20:48 +0200)
trunk/Pithos.Client.WPF/PithosAccount.cs
trunk/Pithos.Client.WPF/Preferences/AddAccountView.xaml
trunk/Pithos.Client.WPF/Preferences/AddAccountViewModel.cs
trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
trunk/Pithos.Core/Agents/StatusAgent.cs

index a384eb2..7da6f2b 100644 (file)
@@ -87,7 +87,7 @@ namespace Pithos.Client.WPF
             //TODO:Force logout here to take care of existing cookies
 
 
-            var listenerUrl = String.Format("http://127.0.0.1:{0}/", port);
+            var listenerUrl = String.Format("http://127.0.0.1:{0}", port);
 
             
 
@@ -97,7 +97,7 @@ namespace Pithos.Client.WPF
             var logoutProcess=Process.Start(logoutUrl);            
             TaskEx.Delay(2000).Wait();
             var uriBuilder=new UriBuilder(loginUrl);                       
-            uriBuilder.Query="next=" + listenerUrl;
+            uriBuilder.Query=String.Format("next={0}&force=", listenerUrl);
 
             var retrieveUri = uriBuilder.Uri;
             Log.InfoFormat("[RETRIEVE] Open Browser at {0}", retrieveUri);
index ac31199..8af7754 100644 (file)
                                    Title="Add new Pithos Account"
                                    Description="This Wizard will walk you through adding a new Pithos account and retrieving an authentication token" 
                                BackButtonVisibility="Collapsed"
-                               FinishButtonVisibility="Collapsed"/>
+                               FinishButtonVisibility="Collapsed"
+                               />
         <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"                               
                                FinishButtonVisibility="Collapsed"
                                     CanSelectNextPage="{Binding IsValidServer}"
+                               
                                     >
             <StackPanel >
                 <Label Content="Pithos Server" Target="{Binding ElementName=Servers}"  />
@@ -40,7 +42,8 @@
                                    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"                               
                                FinishButtonVisibility="Collapsed"
-                                    CanSelectNextPage="False">
+                                    CanSelectNextPage="False"
+                               >
             <StackPanel >
                 <RadioButton x:Name="Automatic" Content="By logging to Pithos" Checked="Automatic_Checked" Margin="5"/>
                 <RadioButton x:Name="Manually" Content="Manually" Checked="Manually_Checked" Margin="5"/>
@@ -53,6 +56,7 @@
                                FinishButtonVisibility="Collapsed"
                                CanSelectNextPage="{Binding HasValidCredentials,NotifyOnTargetUpdated=True}" 
                                TargetUpdated="OnTargetUpdated"
+                               
                                >
             <extToolkit:BusyIndicator x:Name="ManualBusyIndicator" IsBusy="{Binding IsWorking,NotifyOnSourceUpdated=true}" DisplayAfter="0" >
                 <extToolkit:BusyIndicator.BusyContent>
@@ -86,6 +90,7 @@
                                FinishButtonVisibility="Collapsed"
                                CanSelectNextPage="{Binding HasValidCredentials,NotifyOnTargetUpdated=true}"                               
                                TargetUpdated="OnTargetUpdated"
+                               
                                >
             <extToolkit:BusyIndicator x:Name="AutoBusyIndicator" IsBusy="{Binding IsWorking}" DisplayAfter="0">
                 <extToolkit:BusyIndicator.BusyContent>
             <StackPanel>
                 <Label Content="Path:" Target="{Binding ElementName=AccountPath}"/>
                 <Grid HorizontalAlignment="Stretch">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="Auto"/>
+                        <RowDefinition/>
+                    </Grid.RowDefinitions>
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition />
                         <ColumnDefinition Width="Auto" />
                     </Grid.ColumnDefinitions>
-                    <TextBox x:Name="AccountPath" HorizontalAlignment="Stretch" Grid.Column="0" >
+                    <TextBox x:Name="AccountPath" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="0">
                         <TextBox.Text>
                             <Binding Path="AccountPath" Mode="TwoWay">
                                 <Binding.ValidationRules>
                             </ControlTemplate>
                         </Validation.ErrorTemplate>
                     </TextBox>
-                    <Button x:Name="SelectAccount" Content="Select ..." HorizontalAlignment="Right" Grid.Column="1"/>
+                    <Button x:Name="SelectAccount" Content="Select ..." HorizontalAlignment="Right" Grid.Column="1" Grid.Row="0"/>
+                    <CheckBox x:Name="ShouldCreateOkeanosFolder"  Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" >
+                        <CheckBox.Content>
+                            <TextBlock TextWrapping="Wrap">
+                               Create an Okeanos folder below the selected folder
+                                <LineBreak/>
+                               Clear this setting to use the currently selected folder and synchronize its contents
+                            </TextBlock>
+                        </CheckBox.Content>
+                    </CheckBox>
                 </Grid>
             </StackPanel>
         </extToolkit:WizardPage>
         <extToolkit:WizardPage x:Name="LastPage" PageType="Interior"
                                    Title="Finish"
                                    Description="Press finish to create the account"
-                                   CanFinish="True">
+                                   CanFinish="True"
+                               >
             <Grid>
                 <Grid.RowDefinitions>
                     <RowDefinition Height="Auto"/>
index 9f02a55..18688b9 100644 (file)
@@ -42,6 +42,8 @@
 using System;
 using System.Collections.Generic;
 using System.ComponentModel.Composition;
+using System.IO;
+using System.Linq;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Forms;
@@ -168,6 +170,18 @@ namespace Pithos.Client.WPF.Preferences
             }
         }
 
+
+        private bool _shouldCreateOkeanosFolder;
+        public bool ShouldCreateOkeanosFolder
+        {
+            get { return _shouldCreateOkeanosFolder; }
+            set
+            {
+                _shouldCreateOkeanosFolder = value;
+                NotifyOfPropertyChange(()=>ShouldCreateOkeanosFolder);
+            }
+        }
+
         public void SelectAccount()
         {
             using (var dlg = new FolderBrowserDialog{Description=Resources.AddAccountViewModel_SelectAccount_Please_select_a_folder})
@@ -179,6 +193,8 @@ namespace Pithos.Client.WPF.Preferences
                     return;
 
                 AccountPath= dlg.SelectedPath;
+
+                ShouldCreateOkeanosFolder=Directory.EnumerateFileSystemEntries(AccountPath).Any();                
             }
         }
 
index c432009..ef32110 100644 (file)
@@ -302,6 +302,7 @@ namespace Pithos.Client.WPF.Preferences
             foreach (var account in _accountsToRemove)
             {
                 Shell.RemoveMonitor(account.AccountName);
+                Shell.RemoveAccountFromDatabase(account);
             }
 
             foreach (var account in Settings.Accounts)
@@ -345,12 +346,17 @@ namespace Pithos.Client.WPF.Preferences
            if (_windowManager.ShowDialog(wizard) == true)
            {
                string selectedPath = wizard.AccountPath;
-               var initialRootPath = Path.Combine(selectedPath, "Okeanos");
+               var initialRootPath = wizard.ShouldCreateOkeanosFolder?
+                   Path.Combine(selectedPath, "Okeanos")
+                   :selectedPath;
                var actualRootPath= initialRootPath;
-               int attempt = 1;
-               while (Directory.Exists(actualRootPath) || File.Exists(actualRootPath))
+               if (wizard.ShouldCreateOkeanosFolder)
                {
-                   actualRootPath = String.Format("{0} {1}", initialRootPath,attempt++);
+                   int attempt = 1;
+                   while (Directory.Exists(actualRootPath) || File.Exists(actualRootPath))
+                   {
+                       actualRootPath = String.Format("{0} {1}", initialRootPath, attempt++);
+                   }
                }
 
                var newAccount = new AccountSettings
index da70074..44be087 100644 (file)
@@ -989,5 +989,11 @@ namespace Pithos.Client.WPF {
                        var status=statusKeeper.GetFileStatus(localFileName);
                        return status;
                }
+
+           public void RemoveAccountFromDatabase(AccountSettings account)
+           {
+            var statusKeeper = IoC.Get<IStatusKeeper>();
+            statusKeeper.ClearFolderStatus(account.RootPath);          
+           }
        }
 }
index 8efda7b..27b92b7 100644 (file)
@@ -803,7 +803,7 @@ namespace Pithos.Core.Agents
                     
                     using (var connection = GetConnection())
                     {
-                        var command = new SQLiteCommand("delete from FileState where FilePath = :path or FilePath like :path + '/%'  COLLATE NOCASE",
+                        var command = new SQLiteCommand(@"delete from FileState where FilePath = :path or FilePath like :path || '\%'  COLLATE NOCASE",
                                                         connection);
 
                         command.Parameters.AddWithValue("path", filePath);