Revision 7f5882da trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs | ||
---|---|---|
55 | 55 |
using Pithos.Client.WPF.Configuration; |
56 | 56 |
using Pithos.Client.WPF.FileProperties; |
57 | 57 |
using Pithos.Client.WPF.Preferences; |
58 |
using Pithos.Client.WPF.Properties; |
|
59 | 58 |
using Pithos.Client.WPF.SelectiveSynch; |
60 | 59 |
using Pithos.Client.WPF.Services; |
61 | 60 |
using Pithos.Client.WPF.Shell; |
... | ... | |
122 | 121 |
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger("Pithos"); |
123 | 122 |
|
124 | 123 |
//Lazily initialized File Version info. This is done once and lazily to avoid blocking the UI |
125 |
private Lazy<FileVersionInfo> _fileVersion; |
|
124 |
private readonly Lazy<FileVersionInfo> _fileVersion;
|
|
126 | 125 |
|
127 |
private PollAgent _pollAgent; |
|
126 |
private readonly PollAgent _pollAgent;
|
|
128 | 127 |
|
129 | 128 |
///<summary> |
130 | 129 |
/// The Shell depends on MEF to provide implementations for windowManager, events, the status checker service and the settings |
... | ... | |
408 | 407 |
|
409 | 408 |
public void GoToSite(AccountInfo account) |
410 | 409 |
{ |
411 |
/*var site = String.Format("{0}/ui/?token={1}&user={2}", |
|
412 |
account.SiteUri,account.Token, |
|
413 |
account.UserName);*/ |
|
414 | 410 |
Process.Start(account.SiteUri); |
415 | 411 |
} |
416 | 412 |
|
413 |
/// <summary> |
|
414 |
/// Open an explorer window to the target path's directory |
|
415 |
/// and select the file |
|
416 |
/// </summary> |
|
417 |
/// <param name="entry"></param> |
|
418 |
public void GoToFile(FileEntry entry) |
|
419 |
{ |
|
420 |
var fullPath = entry.FullPath; |
|
421 |
if (!File.Exists(fullPath) && !Directory.Exists(fullPath)) |
|
422 |
return; |
|
423 |
Process.Start("explorer.exe","/select, " + fullPath); |
|
424 |
} |
|
425 |
|
|
417 | 426 |
public void ShowFileProperties() |
418 | 427 |
{ |
419 | 428 |
var account = Settings.Accounts.First(acc => acc.IsActive); |
... | ... | |
623 | 632 |
Execute.OnUIThread(() => |
624 | 633 |
{ |
625 | 634 |
var proxyAccount = IoC.Get<ProxyAccountViewModel>(); |
626 |
proxyAccount.Settings = this.Settings;
|
|
635 |
proxyAccount.Settings = Settings; |
|
627 | 636 |
if (true != _windowManager.ShowDialog(proxyAccount)) |
628 | 637 |
return; |
629 | 638 |
StartMonitor(monitor, retries); |
... | ... | |
645 | 654 |
} |
646 | 655 |
|
647 | 656 |
|
648 |
|
|
649 |
private static bool IsUnauthorized(WebException exc) |
|
650 |
{ |
|
651 |
if (exc==null) |
|
652 |
throw new ArgumentNullException("exc"); |
|
653 |
Contract.EndContractBlock(); |
|
654 |
|
|
655 |
var response = exc.Response as HttpWebResponse; |
|
656 |
if (response == null) |
|
657 |
return false; |
|
658 |
return (response.StatusCode == HttpStatusCode.Unauthorized); |
|
659 |
} |
|
660 |
|
|
661 |
private void TryLater(PithosMonitor monitor, Exception exc,int retries) |
|
657 |
private void TryLater(PithosMonitor monitor, Exception exc,int retries) |
|
662 | 658 |
{ |
663 | 659 |
var message = String.Format("An exception occured. Can't start monitoring\nWill retry in 10 seconds"); |
664 | 660 |
Task.Factory.StartNewDelayed(10000, () => StartMonitor(monitor,retries+1)); |
... | ... | |
677 | 673 |
|
678 | 674 |
public void NotifyChangedFile(string filePath) |
679 | 675 |
{ |
680 |
var entry = new FileEntry {FullPath=filePath}; |
|
676 |
if (RecentFiles.Any(e => e.FullPath == filePath)) |
|
677 |
return; |
|
678 |
|
|
681 | 679 |
IProducerConsumerCollection<FileEntry> files=RecentFiles; |
682 | 680 |
FileEntry popped; |
683 | 681 |
while (files.Count > 5) |
684 | 682 |
files.TryTake(out popped); |
683 |
var entry = new FileEntry { FullPath = filePath }; |
|
685 | 684 |
files.TryAdd(entry); |
686 | 685 |
} |
687 | 686 |
|
... | ... | |
703 | 702 |
{ |
704 | 703 |
if (conflictFiles == null) |
705 | 704 |
return; |
706 |
if (!conflictFiles.Any()) |
|
705 |
//Convert to list to avoid multiple iterations |
|
706 |
var files = conflictFiles.ToList(); |
|
707 |
if (files.Count==0) |
|
707 | 708 |
return; |
708 | 709 |
|
709 | 710 |
UpdateStatus(); |
710 | 711 |
//TODO: Create a more specific message. For now, just show a warning |
711 |
NotifyForFiles(conflictFiles,message,TraceLevel.Warning);
|
|
712 |
NotifyForFiles(files,message,TraceLevel.Warning);
|
|
712 | 713 |
|
713 | 714 |
} |
714 | 715 |
|
... | ... | |
743 | 744 |
if (Monitors.TryRemove(accountName, out monitor)) |
744 | 745 |
{ |
745 | 746 |
monitor.Stop(); |
747 |
//TODO: Also remove any pending actions for this account |
|
748 |
//from the network queue |
|
746 | 749 |
} |
747 | 750 |
} |
748 | 751 |
|
... | ... | |
790 | 793 |
} |
791 | 794 |
|
792 | 795 |
|
793 |
private bool _pollStarted = false;
|
|
796 |
private bool _pollStarted; |
|
794 | 797 |
|
795 | 798 |
//SMELL: Doing so much work for notifications in the shell is wrong |
796 | 799 |
//The notifications should be moved to their own view/viewmodel pair |
Also available in: Unified diff