Fixed bug that didn't record skipped uploads, resulting in repeated upload attempts...
authorpkanavos <pkanavos@gmail.com>
Thu, 10 May 2012 20:22:40 +0000 (23:22 +0300)
committerpkanavos <pkanavos@gmail.com>
Thu, 10 May 2012 20:22:40 +0000 (23:22 +0300)
Modified File Properties dialog to look more like Window Properties

trunk/Pithos.Client.WPF/FileProperties/FilePropertiesView.xaml
trunk/Pithos.Client.WPF/FileProperties/FilePropertiesViewModel.cs
trunk/Pithos.Client.WPF/FileProperties/Permission.cs
trunk/Pithos.Core/Agents/Uploader.cs
trunk/Pithos.Installer/PithosPlus.iss
trunk/Pithos.Network/CloudFilesClient.cs

index 7e7bf93..90e1244 100644 (file)
@@ -6,7 +6,8 @@
         xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" mc:Ignorable="d" 
              d:DesignHeight="300" d:DesignWidth="400"  Width="400"
          Height="400" Icon="/PithosPlus;component/Images/PithosTaskbar.png"
-        Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}" WindowStartupLocation="CenterScreen" Topmost="False">
+        Background="{StaticResource {x:Static SystemColors.ControlBrushKey}}" WindowStartupLocation="CenterScreen" Topmost="False"
+        x:Name="ThisView">
     <Window.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
@@ -68,6 +69,9 @@
                             <RowDefinition Height="Auto"/>
                             <RowDefinition Height="Auto"/>
                             <RowDefinition Height="Auto"/>
+                            <RowDefinition Height="Auto"/>
+                            <RowDefinition Height="Auto"/>
+                            <RowDefinition Height="Auto"/>
                         </Grid.RowDefinitions>
                         <TextBlock Text="Kind :" Grid.Row="0" Grid.Column="0" Style="{StaticResource ResourceKey=NameColumnStyle}"/>
                         <TextBlock Text="Size :" Grid.Row="1" Grid.Column="0" Style="{StaticResource ResourceKey=NameColumnStyle}"/>
                     </Grid>
                 </TabItem>
                 <TabItem Header="Metadata">
-                    <DataGrid ItemsSource="{Binding Tags}" x:Name="Tags"
-                    AutoGenerateColumns="False" CanUserAddRows="True" >
-                        <DataGrid.Columns>
-                            <DataGridTemplateColumn >
-                                <DataGridTemplateColumn.CellTemplate>
-                                    <DataTemplate>
-                                        <Button Content=" - " Command="DataGrid.DeleteCommand"/>
-                                    </DataTemplate>
-                                </DataGridTemplateColumn.CellTemplate>
-                            </DataGridTemplateColumn>
-                            <DataGridTextColumn Binding="{Binding Name}" Header="Key" />
-                            <DataGridTextColumn Binding="{Binding Value}" Header="Value"  />
-                        </DataGrid.Columns>
-                    </DataGrid>
+                    <StackPanel>
+                        <StackPanel Orientation="Horizontal">
+                            <TextBox x:Name="CurrentTag_Name" Width="150" Margin="5" Grid.Row="6"/>
+                            <TextBox x:Name="CurrentTag_Value" Width="150" Margin="5" Grid.Row="6"/>
+                            <Button x:Name="AddTag" Content="Add" Margin="5"/>
+                        </StackPanel>
+                        <DataGrid ItemsSource="{Binding Tags}" x:Name="Tags"
+                    AutoGenerateColumns="False" GridLinesVisibility="None" IsReadOnly="True" >
+                            <DataGrid.Columns>
+                                <DataGridTextColumn Binding="{Binding Name}" Header="Key" MinWidth="150" />
+                                <DataGridTextColumn Binding="{Binding Value}" Header="Value"  MinWidth="100"/>
+                            </DataGrid.Columns>
+                        </DataGrid>
+                    </StackPanel>
                 </TabItem>
                 <TabItem Header="Permissions">
                     <StackPanel>
+                        <CheckBox x:Name="IsPublic" Content="Public" Margin="5"/>
                         <StackPanel Orientation="Horizontal">
-                            <TextBox x:Name="PermissionName" Width="200" Margin="5"/>
-                            <RadioButton x:Name="PermissionRead" Content="Read" Margin="5"/>
-                            <RadioButton x:Name="PermissionWrite" Content="Write" Margin="5"/>
+                            <TextBox x:Name="PermissionName" Width="200" Margin="5" Grid.Row="6"/>
+                            <RadioButton x:Name="PermissionRead" Content="Read" Margin="5" Grid.Row="7"/>
+                            <RadioButton x:Name="PermissionWrite" Content="Write" Margin="5" Grid.Row="8"/>
                             <Button x:Name="AddPermission" Content="Add" Margin="5"/>
                         </StackPanel>
                         <TextBlock Margin="5" Visibility="{Binding Path=IsPublic,FallbackValue=Collapsed, Converter={StaticResource BoolToVisible}}">
                 <Run Text="Public URL:" />
                 <Run Text="{Binding PublicUrl,FallbackValue='http://someurl'}" />
                         </TextBlock>
-                        <CheckBox x:Name="IsPublic" Content="Public" Margin="5"/>
-                        <DataGrid x:Name="Permissions" ItemsSource="{Binding Permissions}" 
-                AutoGenerateColumns="False" CanUserAddRows="True">
+                        <DataGrid x:Name="Permissions" AutoGenerateColumns="False" GridLinesVisibility="None" IsReadOnly="True" >
                             <DataGrid.Columns>
-                                <DataGridTemplateColumn >
-                                    <DataGridTemplateColumn.CellTemplate>
-                                        <DataTemplate>
-                                            <Button Content=" - " Command="DataGrid.DeleteCommand"/>
-                                        </DataTemplate>
-                                    </DataGridTemplateColumn.CellTemplate>
-                                </DataGridTemplateColumn>
-                                <DataGridTextColumn Binding="{Binding UserName}" Header="Name"  />
-                                <DataGridCheckBoxColumn Binding="{Binding Read,Mode=TwoWay}" Header="Read"/>
-                                <DataGridCheckBoxColumn Binding="{Binding Write,Mode=TwoWay}" Header="Write"/>
+                                <DataGridTextColumn Binding="{Binding UserName}" Header="Name"  MinWidth="150" />
+                                <DataGridTextColumn Binding="{Binding Value}" Header="Permission"/>
                             </DataGrid.Columns>
                         </DataGrid>
                     </StackPanel>
index dc0f098..dfadea3 100644 (file)
@@ -281,6 +281,7 @@ namespace Pithos.Client.WPF
             {
                 _permissionName = value;
                 NotifyOfPropertyChange(()=>PermissionName);
+                NotifyOfPropertyChange(() => CanAddPermission);
             }
         }
 
@@ -291,12 +292,16 @@ namespace Pithos.Client.WPF
             set
             {
                 _currentPermission = value;
+                PermissionName = CurrentPermission.UserName;
+                PermissionRead = CurrentPermission.Read;
+
                 NotifyOfPropertyChange(()=>CurrentPermission);
+                NotifyOfPropertyChange(() => PermissionName);
             }
         }
 
 
-        private bool _permissionRead;
+        private bool _permissionRead=true;
         public bool PermissionRead
         {
             get { return _permissionRead; }
@@ -304,18 +309,20 @@ namespace Pithos.Client.WPF
             {
                 _permissionRead = value;
                 NotifyOfPropertyChange(()=>PermissionRead);
-                if (CurrentPermission != null)
-                {
-                    CurrentPermission.Read = value;
-                }
+                NotifyOfPropertyChange(() => PermissionWrite);
             }
         }
+
         public bool PermissionWrite
         {
-            get { return CurrentPermission.Write; }
+            get
+            {
+                return !PermissionRead;
+            }
             set
             {
-                CurrentPermission.Write = value;
+                _permissionRead = !value;
+                NotifyOfPropertyChange(() => PermissionRead);
                 NotifyOfPropertyChange(()=>PermissionWrite);
             }
         }
@@ -330,6 +337,16 @@ namespace Pithos.Client.WPF
             Permissions.Add(new Permission{Read=PermissionRead,UserName=PermissionName,Write=!PermissionRead});   
         }
 
+        public bool CanAddTag
+        {
+            get { return CurrentTag!=null && !String.IsNullOrWhiteSpace(CurrentTag.Name); }
+        }
+
+        public void AddTag()
+        {
+            Tags.Add(CurrentTag);   
+        }
+
 
         public bool TagsChanged { get; private set; }
         public bool PermissionsChanged { get; private set; }
@@ -453,6 +470,16 @@ namespace Pithos.Client.WPF
             }
         }
 
+        private MetaValue _currentTag;
+        public MetaValue CurrentTag
+        {
+            get { return _currentTag; }
+            set
+            {
+                _currentTag = value;
+                NotifyOfPropertyChange(()=>CurrentTag);
+            }
+        }
 
         private readonly ObservableCollection<MetaValue> _tags ;
         public ObservableCollection<MetaValue> Tags
index 435b0a4..aca98f3 100644 (file)
@@ -64,10 +64,11 @@ namespace Pithos.Client.WPF
             get { return _read; }
             set
             {
-                _read = value;
-                if (_read)
-                    Write = false;
-                NotifyOfPropertyChange(()=>Read);
+                _read = value;                
+                _write = !value;
+                NotifyOfPropertyChange(() => Write);
+                NotifyOfPropertyChange(() => Read);
+                NotifyOfPropertyChange(() => Value);
             }
         }
 
@@ -79,9 +80,10 @@ namespace Pithos.Client.WPF
             set
             {
                 _write = value;
-                if (_write)
-                    Read = false;
+                _read = !value;
                 NotifyOfPropertyChange(()=>Write);
+                NotifyOfPropertyChange(() => Read);
+                NotifyOfPropertyChange(() => Value);
             }
         }
 
index c6e7441..1506dad 100644 (file)
@@ -106,17 +106,23 @@ namespace Pithos.Core.Agents
                             //If this a shared file\r
                             if (!cloudFile.Account.Equals(action.AccountInfo.UserName,StringComparison.InvariantCultureIgnoreCase))\r
                             {\r
-                                //If this is a read-only file, do not upload changes\r
+                                \r
+/*\r
                                 if (!cloudInfo.IsWritable(action.AccountInfo.UserName))\r
                                 {\r
                                     MakeFileReadOnly(fullFileName);\r
+                                    StatusKeeper.SetFileState(fullFileName, FileStatus.Unchanged, FileOverlayStatus.Normal, "");\r
                                     return;\r
                                 }\r
+*/\r
 \r
-                                //If the file is new, can we upload it?\r
-                                if ( !cloudInfo.Exists && !client.CanUpload(account, cloudFile))\r
+                                //If this is a read-only file, do not upload changes\r
+                                if ( !cloudInfo.IsWritable(action.AccountInfo.UserName) ||\r
+                                    //If the file is new, but we can't upload it\r
+                                    (!cloudInfo.Exists && !client.CanUpload(account, cloudFile)) )\r
                                 {\r
                                     MakeFileReadOnly(fullFileName);\r
+                                    StatusKeeper.SetFileState(fullFileName, FileStatus.Unchanged, FileOverlayStatus.Normal, "");\r
                                     return;\r
                                 }\r
 \r
@@ -219,7 +225,7 @@ namespace Pithos.Core.Agents
             //Do not make any modifications if not necessary\r
             if (attributes.HasFlag(FileAttributes.ReadOnly))\r
                 return;\r
-            File.SetAttributes(fullFileName, attributes | FileAttributes.ReadOnly);\r
+            File.SetAttributes(fullFileName, attributes | FileAttributes.ReadOnly);            \r
         }\r
 \r
         private static AccountInfo GetSharerAccount(string relativePath, AccountInfo accountInfo)\r
index 9b64b97..30f7e23 100644 (file)
@@ -100,7 +100,6 @@ Source: "..\Pithos.Client.WPF\bin\Debug\log4net.dll"; DestDir: {app}; Flags: res
 Source: "..\Pithos.Client.WPF\bin\Debug\Newtonsoft.Json.dll"; DestDir: {app}; Flags: restartreplace ignoreversion; Components: RequiredFiles; Languages: english french german spanish greek\r
 Source: "..\Pithos.Client.WPF\bin\Debug\NHibernate.ByteCode.Castle.dll"; DestDir: {app}; Flags: restartreplace ignoreversion; Components: RequiredFiles; Languages: english french german spanish greek\r
 Source: "..\Pithos.Client.WPF\bin\Debug\NHibernate.dll"; DestDir: {app}; Flags: restartreplace ignoreversion; Components: RequiredFiles; Languages: english french german spanish greek\r
-Source: "..\Pithos.Client.WPF\bin\Debug\NHibernate.Search.dll"; DestDir: {app}; Flags: restartreplace ignoreversion; Components: RequiredFiles; Languages: english french german spanish greek\r
 Source: "..\Pithos.Client.WPF\bin\Debug\ParallelExtensionsExtras.dll"; DestDir: {app}; Flags: restartreplace ignoreversion; Components: RequiredFiles; Languages: english french german spanish greek\r
 Source: "..\Pithos.Client.WPF\bin\Debug\Pithos.Core.dll"; DestDir: {app}; Flags: restartreplace ignoreversion; Components: RequiredFiles; Languages: english french german spanish greek\r
 Source: "..\Pithos.Client.WPF\bin\Debug\Pithos.Interfaces.dll"; DestDir: {app}; Flags: restartreplace ignoreversion; Components: RequiredFiles; Languages: english french german spanish greek\r
index 2b11626..c4496c9 100644 (file)
@@ -1110,6 +1110,13 @@ namespace Pithos.Network
 
                 var builder = client.GetAddressBuilder(container, relativeUrl.ToString());
                 var uri = builder.Uri;
+                
+                client.DownloadProgressChanged += (sender, args) =>
+                                  Log.DebugFormat("[GET PROGRESS] {0} {1}% {2} of {3}",
+                                                 uri.Segments.Last(), args.ProgressPercentage,
+                                                 args.BytesReceived,
+                                                 args.TotalBytesToReceive);
+
 
                 var result = await client.DownloadDataTaskAsync(uri, cancellationToken);
                 return result;