Skip to content

Commit

Permalink
Feature: Add pCloud to the cloud drive section (#10801)
Browse files Browse the repository at this point in the history
  • Loading branch information
gave92 authored Dec 22, 2022
1 parent 3b5ab67 commit 3d7169e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Files.App/Helpers/CloudDrivesDetector.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Files.App.Shell;
using Files.Shared.Cloud;
using Files.Shared.Extensions;
using Microsoft.Win32;
Expand All @@ -21,6 +22,7 @@ public static async Task<IEnumerable<ICloudProvider>> DetectCloudDrives()
SafetyExtensions.IgnoreExceptions(DetectSharepoint, App.Logger),
SafetyExtensions.IgnoreExceptions(DetectGenericCloudDrive, App.Logger),
SafetyExtensions.IgnoreExceptions(DetectYandexDisk, App.Logger),
SafetyExtensions.IgnoreExceptions(DetectpCloudDrive, App.Logger),
};

await Task.WhenAll(tasks);
Expand Down Expand Up @@ -199,5 +201,27 @@ private static Task<IEnumerable<ICloudProvider>> DetectSharepoint()

return Task.FromResult<IEnumerable<ICloudProvider>>(sharepointAccounts);
}

private static Task<IEnumerable<ICloudProvider>> DetectpCloudDrive()
{
var results = new List<ICloudProvider>();
using var pCloudDriveKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\pCloud");

var syncedFolder = (string)pCloudDriveKey?.GetValue("SyncDrive");
if (syncedFolder is not null)
{
string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "pCloud Drive", "pCloud.exe");
var iconFile = Win32API.ExtractSelectedIconsFromDLL(iconPath, new List<int>() { 32512 }, 32).FirstOrDefault();

results.Add(new CloudProvider(CloudProviders.pCloud)
{
Name = $"pCloud Drive",
SyncFolder = syncedFolder,
IconData = iconFile?.IconData
});
}

return Task.FromResult<IEnumerable<ICloudProvider>>(results);
}
}
}
1 change: 1 addition & 0 deletions src/Files.Shared/Cloud/CloudProviders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public enum CloudProviders
Box,
Jottacloud,
SynologyDrive,
pCloud
}
}

0 comments on commit 3d7169e

Please sign in to comment.