Skip to content

Feature: Added detection for Nutstore cloud #10890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 35 additions & 1 deletion src/Files.App/Helpers/CloudDrivesDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace Files.App.Helpers
[SupportedOSPlatform("Windows10.0.10240")]
public class CloudDrivesDetector
{
private readonly static string programFilesFolder = Environment.GetEnvironmentVariable("ProgramFiles");

public static async Task<IEnumerable<ICloudProvider>> DetectCloudDrives()
{
var tasks = new Task<IEnumerable<ICloudProvider>>[]
Expand All @@ -23,6 +25,7 @@ public static async Task<IEnumerable<ICloudProvider>> DetectCloudDrives()
SafetyExtensions.IgnoreExceptions(DetectGenericCloudDrive, App.Logger),
SafetyExtensions.IgnoreExceptions(DetectYandexDisk, App.Logger),
SafetyExtensions.IgnoreExceptions(DetectpCloudDrive, App.Logger),
SafetyExtensions.IgnoreExceptions(DetectNutstoreDrive, App.Logger),
};

await Task.WhenAll(tasks);
Expand Down Expand Up @@ -222,7 +225,7 @@ private static Task<IEnumerable<ICloudProvider>> DetectpCloudDrive()
var syncedFolder = (string)pCloudDriveKey?.GetValue("SyncDrive");
if (syncedFolder is not null)
{
string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "pCloud Drive", "pCloud.exe");
string iconPath = Path.Combine(programFilesFolder, "pCloud Drive", "pCloud.exe");
var iconFile = Win32API.ExtractSelectedIconsFromDLL(iconPath, new List<int>() { 32512 }, 32).FirstOrDefault();

results.Add(new CloudProvider(CloudProviders.pCloud)
Expand All @@ -235,5 +238,36 @@ private static Task<IEnumerable<ICloudProvider>> DetectpCloudDrive()

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

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

if (NutstoreKey is not null)
{
string iconPath = Path.Combine(programFilesFolder, "Nutstore", "Nutstore.exe");
var iconFile = Win32API.ExtractSelectedIconsFromDLL(iconPath, new List<int>() { 101 }).FirstOrDefault();

// get every folder under the Nutstore folder in %userprofile%
var mainFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Nutstore");
var nutstoreFolders = Directory.GetDirectories(mainFolder, "Nutstore", SearchOption.AllDirectories);
foreach (var nutstoreFolder in nutstoreFolders)
{
var folderName = Path.GetFileName(nutstoreFolder);
if (folderName is not null && folderName.StartsWith("Nutstore", StringComparison.OrdinalIgnoreCase))
{
results.Add(new CloudProvider(CloudProviders.Nutstore)
{
Name = $"Nutstore",
SyncFolder = nutstoreFolder,
IconData = iconFile?.IconData
});
}
}
}

return Task.FromResult<IEnumerable<ICloudProvider>>(results);
}
}
}
3 changes: 2 additions & 1 deletion src/Files.Shared/Cloud/CloudProviders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public enum CloudProviders
Jottacloud,
SynologyDrive,
pCloud,
AdobeCreativeCloud
AdobeCreativeCloud,
Nutstore
}
}