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;
{
//var instanceMutex=new Mutex()
-
InitializeLogging();
///Register Application in the Restartmanager service
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;
</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" />
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"}; }
using System.IO;
using System.Reflection;
using Pithos.Client.WPF.Preferences;
+using Pithos.Client.WPF.Properties;
using Pithos.Network;
using log4net;
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);
public List<string> Servers
{
- get { return _servers; }
+ get { return Settings.Default.Servers.Select(server => server.ServerUri).ToList(); }
}
private bool _isValidServer;
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>
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;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Caliburn.Micro;
+using Pithos.Client.WPF.Properties;
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
}
}
- 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);
}
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")
{
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;
+ }
}
}
}
}
}
+ /* 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 });
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"]));
+ }
+ }
}
}
<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
#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;
<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>
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
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
}
}
+
+ 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>
{}