Added Polling interval property and setting
authorPanagiotis Kanavos <pkanavos@gmail.com>
Fri, 20 Jan 2012 16:12:38 +0000 (18:12 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Fri, 20 Jan 2012 16:12:38 +0000 (18:12 +0200)
16 files changed:
trunk/Pithos.Client.WPF/AppBootstrapper.cs
trunk/Pithos.Client.WPF/Configuration/PithosSettings.cs
trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml
trunk/Pithos.Client.WPF/Properties/Settings.Designer.cs
trunk/Pithos.Client.WPF/Properties/Settings.settings
trunk/Pithos.Client.WPF/Shell/ShellView.xaml
trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
trunk/Pithos.Client.WPF/app.config
trunk/Pithos.Core.Test/MockSettings.cs
trunk/Pithos.Core/Agents/NetworkAgent.cs
trunk/Pithos.Core/PithosMonitor.cs
trunk/Pithos.Interfaces/IPithosSettings.cs
trunk/Pithos.Interfaces/PithosSettingsData.cs
trunk/Pithos.ShellExtensions.Test/TestPithosSettings.cs
trunk/Pithos.ShellExtensions/ShellSettings.cs
trunk/Pithos.ShellExtensions/TestPithosSettings.cs

index e6aa872..2bc226e 100644 (file)
@@ -3,6 +3,7 @@ using System.Windows.Controls;
 using System.Windows.Navigation;
 using Caliburn.Micro;
 using Caliburn.Micro.Logging;
+using Microsoft.Windows.Controls;
 using Pithos.Client.WPF.Properties;
 using Pithos.Core;
 using Pithos.Network;
@@ -69,6 +70,7 @@ namespace Pithos.Client.WPF
                        container.Compose(batch);
 
             ConventionManager.AddElementConvention<MenuItem>(ItemsControl.ItemsSourceProperty, "DataContext", "Click");
+               ConventionManager.AddElementConvention<IntegerUpDown>(IntegerUpDown.ValueProperty, "Value", "ValueChanged");
                }
 
                protected override object GetInstance(Type serviceType, string key)
index 838ed40..05ef20d 100644 (file)
@@ -168,6 +168,18 @@ namespace Pithos.Client.WPF.Configuration
             get { return _settings.ShowDesktopNotifications; }
             set { _settings.ShowDesktopNotifications = value; }
         }
+
+
+        public int PollingInterval
+        {
+            get { return _settings.PollingInterval; }
+            set
+            {
+                if (value <= 0)
+                    throw new ArgumentOutOfRangeException();
+                _settings.PollingInterval = value;
+            }
+        }
 /*
         public override IEnumerable<string> GetDynamicMemberNames()
         {
index 24573da..35b6b7d 100644 (file)
                 <TabItem.Header>
                     <StackPanel>
                         <Image Source="/Pithos.Client.WPF;component/Images/Advanced.png" Stretch="Uniform" Height="32"/>
-                        <TextBlock Text="Advanced"/>
+                        <TextBlock Text="Advanced"/>                        
                     </StackPanel>
                 </TabItem.Header>
                 <StackPanel>
                     <CheckBox Content="Activate Shell Extensions" Height="16" HorizontalAlignment="Left" Margin="5" Name="ExtensionsActivated" VerticalAlignment="Top" />
                     <Button Content="Refresh Overlays" Name="RefreshOverlays" HorizontalAlignment="Left" Margin="5" Style="{StaticResource ButtonStyle}" Width="Auto" />
+                    <TextBlock Text="Polling Interval (secs)" Margin="5"/>
+                    <extToolkit:IntegerUpDown x:Name="Settings_PollingInterval" HorizontalAlignment="Left" Width="100" Margin="5,0" Watermark="Enter seconds" Minimum="10" />                    
                 </StackPanel>
             </TabItem>
         </TabControl>
index df2bd9e..dd1fe77 100644 (file)
@@ -270,5 +270,17 @@ namespace Pithos.Client.WPF.Properties {
                 this["Accounts"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("10")]
+        public int PollingInterval {
+            get {
+                return ((int)(this["PollingInterval"]));
+            }
+            set {
+                this["PollingInterval"] = value;
+            }
+        }
     }
 }
index a0e270c..62f529b 100644 (file)
@@ -68,5 +68,8 @@
     <Setting Name="Accounts" Type="Pithos.Interfaces.AccountsCollection" Scope="User">
       <Value Profile="(Default)" />
     </Setting>
+    <Setting Name="PollingInterval" Type="System.Int32" Scope="User">
+      <Value Profile="(Default)">10</Value>
+    </Setting>
   </Settings>
 </SettingsFile>
\ No newline at end of file
index 9d277d0..74d07be 100644 (file)
@@ -64,6 +64,7 @@
                             </DataTemplate>
                         </MenuItem.ItemTemplate>
                     </MenuItem>
+                    <MenuItem Header="Synch Now" x:Name="SynchNow"/>
                     <Separator  />                    
                     <MenuItem Header="Usage" x:Name="Usages" ItemsSource="{Binding Accounts}">
                         <MenuItem.ItemTemplate>
index 068621d..d0ca919 100644 (file)
@@ -404,6 +404,9 @@ namespace Pithos.Client.WPF {
                        _windowManager.ShowWindow(containerProperties);
                }
 
+        public void SynchNow()
+        {}
+
                public ObjectInfo RefreshObjectInfo(ObjectInfo currentInfo)
                {
                        if (currentInfo==null)
index 7d7adfb..596bdef 100644 (file)
@@ -75,6 +75,9 @@
       <setting name="MustUpgrade" serializeAs="String">
         <value>True</value>
       </setting>
+      <setting name="PollingInterval" serializeAs="String">
+        <value>10</value>
+      </setting>
     </Pithos.Client.WPF.Properties.Settings>
   </userSettings>
   <connectionStrings>
index 21ae46d..734647d 100644 (file)
@@ -36,6 +36,8 @@ namespace Pithos.Core.Test
         public bool ProxyAuthentication { get; set; }
         public bool ExtensionsActivated { get; set; }
 
+        public int PollingInterval { get; set; }
+
 
         public void Save()
         {
index 8f46ded..3c688ac 100644 (file)
@@ -76,6 +76,8 @@ namespace Pithos.Core.Agents
 
         private readonly ConcurrentBag<AccountInfo> _accounts = new ConcurrentBag<AccountInfo>();
 
+        [System.ComponentModel.Composition.Import]
+        public IPithosSettings Settings { get; set; }
 
         private bool _firstPoll = true;
         public void Start()
@@ -431,9 +433,9 @@ namespace Pithos.Core.Agents
         
 
         //Remote files are polled periodically. Any changes are processed
-        public async Task ProcessRemoteFiles(DateTime? since = null)
+        public async Task PollRemoteFiles(DateTime? since = null)
         {            
-            await TaskEx.Delay(TimeSpan.FromSeconds(10),_agent.CancellationToken);
+            await TaskEx.Delay(TimeSpan.FromSeconds(Settings.PollingInterval),_agent.CancellationToken);
 
             using (log4net.ThreadContext.Stacks["Retrieve Remote"].Push("All accounts"))
             {
@@ -450,13 +452,13 @@ namespace Pithos.Core.Agents
                     await TaskEx.WhenAll(tasks.ToList());
 
                     _firstPoll = false;
-                    ProcessRemoteFiles(nextSince);
+                    PollRemoteFiles(nextSince);
                 }
                 catch (Exception ex)
                 {
                     Log.ErrorFormat("Error while processing accounts\r\n{0}",ex);
                     //In case of failure retry with the same parameter
-                    ProcessRemoteFiles(since);
+                    PollRemoteFiles(since);
                 }
                 
 
@@ -547,22 +549,22 @@ namespace Pithos.Core.Agents
                         ProcessTrashedFiles(accountInfo, realTrash);
 
 
-                        var cleanRemotes = from info in remoteObjects
+                        var cleanRemotes = (from info in remoteObjects
                                      //.Union(sharedObjects)
                                      let name = info.Name
                                      where !name.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase) &&
                                            !name.StartsWith(FolderConstants.CacheFolder + "/",
                                                             StringComparison.InvariantCultureIgnoreCase)
-                                     select info;
+                                     select info).ToList();
 
 
-                        
 
+                        ProcessDeletedFiles(accountInfo, cleanRemotes, pollTime);
 
                         //Create a list of actions from the remote files
                         var allActions = ObjectsToActions(accountInfo, cleanRemotes);
 
-                        ProcessDeletedFiles(accountInfo, cleanRemotes, pollTime);
+                        
                         //var relativePath = objectInfo.RelativeUrlToFilePath(accountInfo.UserName);
 
                         //And remove those that are already being processed by the agent
index c7fdd50..c34d70e 100644 (file)
@@ -346,7 +346,7 @@ namespace Pithos.Core
                         
             NetworkAgent.Start();
 
-            NetworkAgent.ProcessRemoteFiles();
+            NetworkAgent.PollRemoteFiles();
         }
 
         //Make sure a hidden cache folder exists to store partial downloads
index 40060ae..f1235b4 100644 (file)
@@ -35,6 +35,8 @@ namespace Pithos.Interfaces
 
         bool ExtensionsActivated { get; set; }
 
+        int PollingInterval { get; set; }
+
         void Save();
         void Reload();
     }
index da44083..f94a406 100644 (file)
@@ -64,6 +64,7 @@ namespace Pithos.Interfaces
         public string ProxyPassword { get; set; }
         public bool ProxyAuthentication { get; set; }
         public bool ExtensionsActivated { get; set; }
+        public int PollingInterval { get; set; }
 
         public PithosSettingsData()
         {
@@ -89,6 +90,7 @@ namespace Pithos.Interfaces
             ProxyPassword = other.ProxyPassword;
             ProxyAuthentication = other.ProxyAuthentication;
             ExtensionsActivated = other.ExtensionsActivated;
+            PollingInterval = other.PollingInterval;
         }
 
         public virtual void Save()
index 3e079fa..9f585e1 100644 (file)
@@ -49,6 +49,9 @@ namespace Pithos.ShellExtensions.Test
         public bool ProxyAuthentication { get; set; }
 
         public bool ExtensionsActivated { get; set; }
+
+        public int PollingInterval { get; set; }
+
         public void Save()
         {
             
index 259982d..9f1f849 100644 (file)
@@ -155,6 +155,12 @@ namespace Pithos.ShellExtensions
             get { return _settings.Value.ExtensionsActivated; }
             set { _settings.Value.ExtensionsActivated = value; }
         }
+
+        public int PollingInterval
+        {
+            get { return _settings.Value.PollingInterval; }
+            set { _settings.Value.PollingInterval = value; }
+        }
         public void Save()
         {
            
index c44aae2..8f589ac 100644 (file)
@@ -48,6 +48,8 @@ namespace Pithos.ShellExtensions.Test
 
         public bool ExtensionsActivated { get; set; }
 
+        public int PollingInterval { get; set; }
+
 
         public bool ProxyAuthentication { get; set; }
         public void Save()