Adding a new account now forces a logout to clear any stale Pithos cookies
authorpkanavos <pkanavos@gmail.com>
Tue, 1 May 2012 16:18:48 +0000 (19:18 +0300)
committerpkanavos <pkanavos@gmail.com>
Tue, 1 May 2012 16:18:48 +0000 (19:18 +0300)
15 files changed:
trunk/Pithos.Client.WPF/App.xaml.cs
trunk/Pithos.Client.WPF/Diagnostics/log4netForwarder.cs
trunk/Pithos.Client.WPF/FileProperties/ConflictsView.xaml
trunk/Pithos.Client.WPF/FileProperties/ConflictsViewModel.cs
trunk/Pithos.Client.WPF/PithosAccount.cs
trunk/Pithos.Client.WPF/Preferences/AddAccountViewModel.cs
trunk/Pithos.Client.WPF/Preferences/LoginView.xaml
trunk/Pithos.Client.WPF/Preferences/LoginView.xaml.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.Core/Agents/PollAgent.cs
trunk/Pithos.Interfaces/AccountSettings.cs

index f18643c..c44afb1 100644 (file)
@@ -52,6 +52,7 @@ using System.Windows;
 using Caliburn.Micro;
 using Pithos.Client.WPF.Configuration;
 using Pithos.Client.WPF.Properties;
+using Pithos.Interfaces;
 using log4net.Appender;
 using log4net.Core;
 using log4net.Repository.Hierarchy;
@@ -75,7 +76,6 @@ namespace Pithos.Client.WPF
         {
 
             //var instanceMutex=new Mutex()
-
             InitializeLogging();
 
             ///Register Application in the Restartmanager service
index 670c975..615116c 100644 (file)
@@ -131,13 +131,13 @@ namespace Pithos.Client.WPF.Diagnostics
                     level = Level.Verbose;
                     break;
                 case TraceEventType.Warning:
-                    level = Level.Warn;
+                    level = Level.Info;
                     break;
                 case TraceEventType.Critical:
-                    level = Level.Critical;
+                    level = Level.Info;
                     break;
                 case TraceEventType.Error:
-                    level = Level.Error;
+                    level = Level.Info;
                     break;
             }
             return level;
index 4e2e0e6..acd9509 100644 (file)
@@ -48,7 +48,9 @@
                 </DataGridTemplateColumn>
             </DataGrid.Columns>
         </DataGrid>
-        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" Visibility="{Binding Converter={StaticResource BoolToInvisible}, Path=HasConflicts}" FontWeight="Bold">There are no conflicts.</TextBlock>
+        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" 
+                   Visibility="{Binding Converter={StaticResource BoolToVisible}, Path=HasNoConflicts}"
+                   FontWeight="Bold">There are no conflicts.</TextBlock>
         <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Right">
             <Button Name="Apply" Content="OK" Margin="5,5,10,5" Style="{StaticResource ButtonStyle}" IsDefault="False" />
             <Button Name="Cancel" Content="Cancel" Margin="5,5,10,5" Style="{StaticResource ButtonStyle}" IsCancel="True" />
index 611bf38..2ad1941 100644 (file)
@@ -100,6 +100,11 @@ namespace Pithos.Client.WPF.FileProperties
             get { return Conflicts!=null && Conflicts.Count > 0; }
         }
 
+        public bool HasNoConflicts
+        {
+            get { return !HasConflicts; }
+        }
+
         public string[]  Actions
         {
             get { return new[] {"Keep Local", "Keep Server", "Keep Both"}; }
index 4549b11..fb72c8c 100644 (file)
@@ -46,6 +46,7 @@
 using System.IO;
 using System.Reflection;
 using Pithos.Client.WPF.Preferences;
+using Pithos.Client.WPF.Properties;
 using Pithos.Network;
 using log4net;
 
@@ -105,8 +106,13 @@ namespace Pithos.Client.WPF
 
             var retrieveUri = uriBuilder.Uri;
 
+            var logoutUrl= (from server in Settings.Default.Servers
+                           where server.LoginUri == loginUrl
+                               select new Uri(server.LogoutUri)).FirstOrDefault();
 
-            var browser = new LoginView(retrieveUri,accountName);            
+
+
+            var browser = new LoginView(retrieveUri,logoutUrl,accountName);            
             if (true == browser.ShowDialog())
             {
                 return new NetworkCredential(browser.Account, browser.Token);
index e9b30e8..42adca0 100644 (file)
@@ -62,7 +62,7 @@ namespace Pithos.Client.WPF.Preferences
 
         public List<string> Servers
         {
-            get { return _servers; }
+            get { return Settings.Default.Servers.Select(server => server.ServerUri).ToList(); }
         }
 
         private bool _isValidServer;
index d6606bf..e062949 100644 (file)
@@ -4,6 +4,9 @@
         xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
         Title="Astakos Login" Height="800" Width="1024" Icon="/PithosPlus;component/Images/PithosTaskbar.png"
         x:Name="TheView">
+    <Window.Resources>
+        <BooleanToVisibilityConverter x:Key="BoolToVisible" />
+    </Window.Resources>
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition Height="Auto"/>
             <TextBox Text="{Binding Path=Uri,ElementName=TheView}" Grid.Column="2" Margin="5,0,5,0" IsReadOnly="true"/>
             <Button Content="Retry" Grid.Column="3" x:Name="Retry" Click="Retry_Click" Padding="2"/>
         </Grid>
-        <extToolkit:BusyIndicator Grid.Row="1" x:Name="IsBusy">
-        <WebBrowser HorizontalAlignment="Stretch" Margin="5" Name="LoginBrowser" VerticalAlignment="Stretch" Navigating="LoginBrowser_Navigating" Navigated="LoginBrowser_Navigated" />
+        <extToolkit:BusyIndicator Grid.Row="1" x:Name="IsBusy" IsBusy="True" BusyContent="Connecting ...">
+        <WebBrowser HorizontalAlignment="Stretch" Margin="5" Name="LoginBrowser" VerticalAlignment="Stretch" 
+                    Navigating="LoginBrowser_Navigating" 
+                    Navigated="LoginBrowser_Navigated" 
+                    />
         </extToolkit:BusyIndicator>
     </Grid>
 </Window>
index a9ee875..c0aa6a9 100644 (file)
@@ -5,6 +5,7 @@ using System.Linq;
 using System.Linq.Expressions;
 using System.Reflection;
 using System.Text;
+using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Data;
@@ -14,6 +15,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Shapes;
 using Caliburn.Micro;
+using Pithos.Client.WPF.Properties;
 
 
 namespace Pithos.Client.WPF.Preferences
@@ -26,6 +28,9 @@ namespace Pithos.Client.WPF.Preferences
         private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
         private Uri _uri;
+        private Uri _logoutUri;
+        private bool _loggingOut;
+
         public Uri Uri
         {
             get
@@ -47,15 +52,20 @@ namespace Pithos.Client.WPF.Preferences
             }
         }
 
-        public LoginView(Uri uri,string account=null)
+        public LoginView(Uri loginUri, Uri logoutUri, string account = null)
         {
             InitializeComponent();
             if (String.IsNullOrWhiteSpace(account))
                 this.Title = "Retrieve Pithos credentials";
             else
                 this.Title = "Retrieve Pithos credentials for " + account;
-            Uri = uri;
-            LoginBrowser.Navigate(uri);
+            Uri = loginUri;
+
+            
+            _logoutUri = logoutUri;
+
+            _loggingOut = true;
+            LoginBrowser.Navigate(logoutUri ?? loginUri);
         }
 
 
@@ -66,7 +76,10 @@ namespace Pithos.Client.WPF.Preferences
         private void LoginBrowser_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e)
         {
             IsBusy.IsBusy = true;
-            Log.Debug(e.ToString());
+            LoginBrowser.Visibility=Visibility.Hidden;
+
+            if (Log.IsDebugEnabled)
+                Log.Debug(e.ToString());
 
             if (e.Uri.Scheme == "pithos")
             {
@@ -101,7 +114,17 @@ namespace Pithos.Client.WPF.Preferences
 
         private void LoginBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
         {
-            IsBusy.IsBusy = false;
+            if (_loggingOut)
+            {
+                _loggingOut = false;
+                IsBusy.BusyContent = "Opening login screen";
+                LoginBrowser.Navigate(Uri);
+            }
+            else
+            {
+                IsBusy.IsBusy = false;
+                LoginBrowser.Visibility = Visibility.Visible;
+            }
         }
     }
 }
index ef9310e..bf22074 100644 (file)
@@ -229,6 +229,17 @@ namespace Pithos.Client.WPF.Preferences
             }
         }
 
+       /* private bool _networkTracing;
+        public bool NetworkTracing
+        {
+            get { return _networkTracing; }
+            set
+            {
+                _networkTracing = value;
+                
+            }
+        }*/
+
         public void RefreshApiKey()
         {
             //_events.Publish(new Notification { Title = "Authorization failed", Message = "Your API Key has probably expired. You will be directed to a page where you can renew it", Level = TraceLevel.Error });
index 3f754ec..51314d3 100644 (file)
@@ -386,5 +386,13 @@ namespace Pithos.Client.WPF.Properties {
                 this["IgnoreCertificateErrors"] = value;
             }
         }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::Pithos.Interfaces.ServersCollection Servers {
+            get {
+                return ((global::Pithos.Interfaces.ServersCollection)(this["Servers"]));
+            }
+        }
     }
 }
index eb7e09f..82de532 100644 (file)
@@ -98,5 +98,8 @@
     <Setting Name="IgnoreCertificateErrors" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">False</Value>
     </Setting>
+    <Setting Name="Servers" Type="Pithos.Interfaces.ServersCollection" Scope="Application">
+      <Value Profile="(Default)" />
+    </Setting>
   </Settings>
 </SettingsFile>
\ No newline at end of file
index 20e941a..14d43b6 100644 (file)
@@ -983,22 +983,23 @@ namespace Pithos.Client.WPF {
                #region Event Handlers
                
                public void Handle(SelectiveSynchChanges message)
-        {
-            PithosMonitor monitor;
-            if (Monitors.TryGetValue(message.Account.AccountKey, out monitor))
-            {
-                monitor.SetSelectivePaths(message.Uris, message.Added, message.Removed);
-
-            }
-
-            var account = Accounts.FirstOrDefault(acc => acc.AccountKey == message.Account.AccountKey);
-            if (account!=null)
-            {
-                this._pollAgent.SetSelectivePaths(account, message.Added, message.Removed);
-            }
-
+               {
+                   TaskEx.Run(() =>
+                   {
+                       PithosMonitor monitor;
+                       if (Monitors.TryGetValue(message.Account.AccountKey, out monitor))
+                       {
+                           monitor.SetSelectivePaths(message.Uris, message.Added, message.Removed);
+                       }
+
+                       var account = Accounts.FirstOrDefault(acc => acc.AccountKey == message.Account.AccountKey);
+                       if (account != null)
+                       {
+                           this._pollAgent.SetSelectivePaths(account, message.Added, message.Removed);
+                       }
+                   });
 
-        }
+               }
 
 
                private bool _pollStarted;
index 30b6f8d..8bb6d1b 100644 (file)
 
 <system.diagnostics >
     <sources >
+<!--
       <source name="System.Net"  switchValue="Information" tracemode="protocolonly" maxdatasize="65536" >
         <listeners>
-          <add name="ms" type="Pithos.Client.WPF.Diagnostics.Log4NetForwarder,PithosPlus"/>
-        </listeners>
+          <add name="ms" type="Pithos.Client.WPF.Diagnostics.Log4NetForwarder,PithosPlus" />          
+        </listeners>        
       </source>
+-->
     </sources>
   </system.diagnostics>
   <userSettings>
       <setting name="UpdateForceCheck" serializeAs="String">
         <value>True</value>
       </setting>
+      <setting name="Servers" serializeAs="Xml">
+        <value>
+          <ArrayOfServerSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+            <ServerSettings>
+              <ServerUri>https://pithos.okeanos.grnet.gr</ServerUri>
+              <LoginUri>https://pithos.okeanos.grnet.gr/login</LoginUri>
+              <LogoutUri>https://accounts.okeanos.grnet.gr/im/logout</LogoutUri>
+            </ServerSettings>
+            <ServerSettings>
+              <ServerUri>https://pithos.dev.grnet.gr</ServerUri>
+              <LoginUri>https://pithos.dev.grnet.gr/login</LoginUri>
+              <LogoutUri>https://pithos.dev.grnet.gr/im/logout</LogoutUri>
+            </ServerSettings>
+          </ArrayOfServerSettings>
+        </value>
+      </setting>      
     </Pithos.Client.WPF.Properties.Settings>
   </applicationSettings>
   <log4net>
index d1974bf..747fb52 100644 (file)
@@ -666,8 +666,10 @@ namespace Pithos.Core.Agents
                     string account;\r
                     string container;\r
                     var segmentsCount = folderUri.Segments.Length;\r
+                    //Is this an account URL?\r
                     if (segmentsCount < 3)\r
                         continue;\r
+                    //Is this a container or  folder URL?\r
                     if (segmentsCount == 3)\r
                     {\r
                         account = folderUri.Segments[1].TrimEnd('/');\r
@@ -681,11 +683,13 @@ namespace Pithos.Core.Agents
                     IList<ObjectInfo> items;\r
                     if (segmentsCount > 3)\r
                     {\r
+                        //List folder\r
                         var folder = String.Join("", folderUri.Segments.Splice(4));\r
                         items = client.ListObjects(account, container, folder);\r
                     }\r
                     else\r
                     {\r
+                        //List container\r
                         items = client.ListObjects(account, container);\r
                     }\r
                     var actions = CreatesToActions(accountInfo, items);\r
index a0bf8fe..69bff8f 100644 (file)
@@ -78,6 +78,17 @@ namespace Pithos.Interfaces
         }
     }
 
+
+    public class ServerSettings
+    {
+        public string ServerUri { get; set; }
+        public string LoginUri { get; set; }
+        public string LogoutUri { get; set; }
+    }
+
+    public class ServersCollection:List<ServerSettings>
+    {}
+
     //[Serializable]
     public class AccountsCollection:List<AccountSettings>
     {}