Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Files.Launcher/Files.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
Expand All @@ -126,9 +123,6 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Windows">
<HintPath>$(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\10.0.18362.0\Windows.winmd</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DeviceWatcher.cs" />
Expand Down
22 changes: 13 additions & 9 deletions Files.Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,13 @@ private static async Task ParseArgumentsAsync(AppServiceRequestReceivedEventArgs
await ParseRecycleBinActionAsync(args, binAction);
break;

case "StartupTasks":
case "DetectQuickLook":
// Check QuickLook Availability
QuickLook.CheckQuickLookAvailability(localSettings);
var available = QuickLook.CheckQuickLookAvailability();
await args.Request.SendResponseAsync(new ValueSet()
{
{ "IsAvailable", available }
});
break;

case "ToggleQuickLook":
Expand Down Expand Up @@ -326,8 +330,10 @@ await args.Request.SendResponseAsync(new ValueSet()
break;

case "GetOneDriveAccounts":
using (var oneDriveAccountsKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\OneDrive\Accounts", false))
try
{
var oneDriveAccountsKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\OneDrive\Accounts", false);

if (oneDriveAccountsKey == null)
{
await args.Request.SendResponseAsync(new ValueSet());
Expand All @@ -348,6 +354,10 @@ await args.Request.SendResponseAsync(new ValueSet()
}
await args.Request.SendResponseAsync(oneDriveAccounts);
}
catch
{
await args.Request.SendResponseAsync(new ValueSet());
}
break;

default:
Expand Down Expand Up @@ -798,12 +808,6 @@ private static bool HandleCommandLineArgs()

return true;
}
else if (arguments == "StartupTasks")
{
// Check QuickLook Availability
QuickLook.CheckQuickLookAvailability(localSettings);
return true;
}
}
return false;
}
Expand Down
10 changes: 4 additions & 6 deletions Files.Launcher/QuickLook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO;
using System.IO.Pipes;
using System.Security.Principal;
using Windows.Storage;

namespace FilesFullTrust
{
Expand All @@ -30,7 +29,7 @@ public static void ToggleQuickLook(string path)
}
}

public static void CheckQuickLookAvailability(ApplicationDataContainer localSettings)
public static bool CheckQuickLookAvailability()
{
static int QuickLookServerAvailable()
{
Expand All @@ -51,7 +50,7 @@ static int QuickLookServerAvailable()

return serverInstances;
}
catch (TimeoutException e)
catch (TimeoutException)
{
client.Close();
return 0;
Expand All @@ -61,14 +60,13 @@ static int QuickLookServerAvailable()
try
{
var result = QuickLookServerAvailable();

Logger.Info($"QuickLook detected: {result != 0}");
localSettings.Values["quicklook_enabled"] = result != 0;
return result != 0;
}
catch (Exception ex)
{
Logger.Info(ex, ex.Message);
localSettings.Values["quicklook_enabled"] = 0;
return false;
}
}
}
Expand Down
51 changes: 15 additions & 36 deletions Files/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ sealed partial class App : Application

public static IBundlesSettings BundlesSettings = new BundlesSettingsViewModel();

public static SettingsViewModel AppSettings { get; set; }
public static InteractionViewModel InteractionViewModel { get; set; }
public static SettingsViewModel AppSettings { get; private set; }
public static InteractionViewModel InteractionViewModel { get; private set; }
public static JumpListManager JumpList { get; } = new JumpListManager();
public static SidebarPinnedController SidebarPinnedController { get; set; }
public static CloudDrivesManager CloudDrivesManager { get; set; }
public static DrivesManager DrivesManager { get; set; }
public static SidebarPinnedController SidebarPinnedController { get; private set; }
public static CloudDrivesManager CloudDrivesManager { get; private set; }
public static DrivesManager DrivesManager { get; private set; }

private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

Expand Down Expand Up @@ -79,7 +79,7 @@ public App()
StartAppCenter();
}

internal static async Task EnsureSettingsAndConfigurationAreBootstrapped()
private static async Task EnsureSettingsAndConfigurationAreBootstrapped()
{
if (AppSettings == null)
{
Expand All @@ -91,38 +91,17 @@ internal static async Task EnsureSettingsAndConfigurationAreBootstrapped()
}
}

if (CloudDrivesManager == null)
{
//Enumerate cloud drives on in the background. It will update the UI itself when finished
_ = Files.Filesystem.CloudDrivesManager.Instance.ContinueWith(o =>
{
CloudDrivesManager = o.Result;
});
}
InteractionViewModel ??= new InteractionViewModel();
SidebarPinnedController ??= await SidebarPinnedController.CreateInstance();
DrivesManager ??= new DrivesManager();
CloudDrivesManager ??= new CloudDrivesManager();

//Start off a list of tasks we need to run before we can continue startup
var tasksToRun = new List<Task>();

if (SidebarPinnedController == null)
// Start off a list of tasks we need to run before we can continue startup
_ = Task.Factory.StartNew(async () =>
{
tasksToRun.Add(Files.Controllers.SidebarPinnedController.CreateInstance().ContinueWith(o => SidebarPinnedController = o.Result));
}

if (DrivesManager == null)
{
tasksToRun.Add(Files.Filesystem.DrivesManager.Instance.ContinueWith(o => DrivesManager = o.Result));
}

if (InteractionViewModel == null)
{
InteractionViewModel = new InteractionViewModel();
}

if (tasksToRun.Any())
{
//Only proceed when all tasks are completed
await Task.WhenAll(tasksToRun);
}
await DrivesManager.EnumerateDrivesAsync();
await CloudDrivesManager.EnumerateDrivesAsync();
});
}

private async void StartAppCenter()
Expand Down
2 changes: 1 addition & 1 deletion Files/Controllers/SidebarPinnedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private async Task LoadAsync()
Model.Save();
}

Model.AddAllItemsToSidebar();
await Model.AddAllItemsToSidebar();
}

public void SaveModel()
Expand Down
22 changes: 17 additions & 5 deletions Files/DataModels/SidebarPinnedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
using Files.ViewModels;
using Files.Views;
using Newtonsoft.Json;
using NLog;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.Xaml.Media;

namespace Files.DataModels
Expand Down Expand Up @@ -148,7 +151,7 @@ ex is ArgumentException // Pinned item was invalid
Debug.WriteLine($"An error occured while swapping pinned items in the navigation sidebar. {ex.Message}");
this.Items = sidebarItemsBackup;
this.RemoveStaleSidebarItems();
this.AddAllItemsToSidebar();
_ = this.AddAllItemsToSidebar();
}
}

Expand Down Expand Up @@ -215,12 +218,21 @@ public async Task AddItemToSidebarAsync(string path)
/// <summary>
/// Adds all items to the navigation sidebar
/// </summary>
public async void AddAllItemsToSidebar()
public async Task AddAllItemsToSidebar()
{
for (int i = 0; i < Items.Count(); i++)
await MainPage.SideBarItemsSemaphore.WaitAsync();
try
{
for (int i = 0; i < Items.Count(); i++)
{
string path = Items[i];
await AddItemToSidebarAsync(path);
}
MainPage.SideBarItems.EndBulkOperation();
}
finally
{
string path = Items[i];
await AddItemToSidebarAsync(path);
MainPage.SideBarItemsSemaphore.Release();
}
}

Expand Down
1 change: 1 addition & 0 deletions Files/Files.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<DependentUpon>RestartDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\BitmapHelper.cs" />
<Compile Include="Helpers\CollectionDebugView.cs" />
<Compile Include="Helpers\DynamicDialogFactory.cs" />
<Compile Include="Helpers\Extension.cs" />
<Compile Include="Helpers\FileListCache\CacheEntry.cs" />
Expand Down
16 changes: 4 additions & 12 deletions Files/Filesystem/Cloud/CloudProviderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,18 @@ namespace Files.Filesystem.Cloud
{
public class CloudProviderController
{
private List<CloudProvider> cloudProviders = new List<CloudProvider>();

public List<ICloudProviderDetector> CloudProviderDetectors => new List<ICloudProviderDetector>
private List<ICloudProviderDetector> CloudProviderDetectors => new List<ICloudProviderDetector>
{
new GoogleDriveCloudProvider(),
new DropBoxCloudProvider(),
new OneDriveCloudProvider(),
new MegaCloudProvider(),
new BoxCloudProvider(),
new AppleCloudProvider(),
new AmazonDriveProvider()
new AmazonDriveProvider(),
};

public List<CloudProvider> CloudProviders
{
get => cloudProviders.Where(x => !string.IsNullOrEmpty(x.SyncFolder)).ToList();
set => cloudProviders = value;
}

public async Task DetectInstalledCloudProvidersAsync()
public async Task<List<CloudProvider>> DetectInstalledCloudProvidersAsync()
{
var tasks = new List<Task<IList<CloudProvider>>>();
var results = new List<CloudProvider>();
Expand All @@ -38,7 +30,7 @@ public async Task DetectInstalledCloudProvidersAsync()

await Task.WhenAll(tasks);

cloudProviders = tasks.SelectMany(o => o.Result).ToList();
return tasks.SelectMany(o => o.Result).Distinct().ToList();
}
}
}
2 changes: 1 addition & 1 deletion Files/Filesystem/Cloud/Providers/OneDriveCloudProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public async Task<IList<CloudProvider>> DetectAsync()
{
try
{
using var connection = await AppServiceConnectionHelper.BuildConnection();
var connection = await AppServiceConnectionHelper.Instance;
if (connection != null)
{
var (status, response) = await connection.SendMessageWithRetryAsync(new ValueSet()
Expand Down
Loading