This commit is contained in:
PatrickSt1991
2025-09-26 19:57:16 +02:00
parent 1ae3db4f02
commit 62f40b608d
20 changed files with 309 additions and 30 deletions

View File

@@ -11,5 +11,8 @@
<Application.Styles>
<FluentTheme />
<Style Selector="Window">
<Setter Property="Icon" Value="avares://Jellyfin2SamsungCrossOS/Assets/jelly2sams.ico" />
</Style>
</Application.Styles>
</Application>

View File

@@ -11,6 +11,7 @@ using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
namespace Jellyfin2SamsungCrossOS
{
@@ -26,7 +27,7 @@ namespace Jellyfin2SamsungCrossOS
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
public async override void OnFrameworkInitializationCompleted()
{
ConfigureServices();
@@ -34,12 +35,86 @@ namespace Jellyfin2SamsungCrossOS
{
DisableAvaloniaDataAnnotationValidation();
var mainWindow = _serviceProvider.GetRequiredService<MainWindow>();
var viewModel = _serviceProvider.GetRequiredService<MainWindowViewModel>();
desktop.MainWindow = mainWindow;
if (!OperatingSystem.IsWindows())
await RequestInitialPrivilegesWithUI();
await viewModel.InitializeAsync();
}
base.OnFrameworkInitializationCompleted();
}
private async Task RequestInitialPrivilegesWithUI()
{
try
{
var dialogService = _serviceProvider.GetRequiredService<IDialogService>();
await dialogService.ShowMessageAsync(
"Administrator Privileges Required",
"This application needs administrator privileges to install software on your system. " +
"You will be prompted for your password once at the beginning.");
// Request privileges
var processHelper = _serviceProvider.GetRequiredService<ProcessHelper>();
var success = await RequestInitialPrivileges(processHelper);
if (success)
{
await dialogService.ShowMessageAsync(
"Authentication Successful",
"Administrator privileges have been granted. You can now install software without additional password prompts.");
}
else
{
await dialogService.ShowMessageAsync(
"Authentication Failed",
"Could not obtain administrator privileges. You may be prompted for passwords during installation.");
}
}
catch (Exception ex)
{
// Handle any errors silently or log them
Console.WriteLine($"Privilege request failed: {ex.Message}");
}
}
private async Task<bool> RequestInitialPrivileges(ProcessHelper processHelper)
{
try
{
if (OperatingSystem.IsLinux())
{
// Use pkexec to authenticate, then extend sudo timeout
var result1 = await processHelper.RunCommandAsync("pkexec", "sudo -v");
if (result1.ExitCode == 0)
{
// Extend the sudo timeout to maximum (usually 15 minutes)
var result2 = await processHelper.RunCommandAsync("sudo", "-v");
return result2.ExitCode == 0;
}
return false;
}
else if (OperatingSystem.IsMacOS())
{
// Test macOS authentication
var result = await processHelper.RunCommandAsync("osascript",
"-e \"do shell script \\\"true\\\" with administrator privileges\"");
return result.ExitCode == 0;
}
}
catch (Exception ex)
{
Console.WriteLine($"Authentication error: {ex.Message}");
return false;
}
return false;
}
private void ConfigureServices()
{
var services = new ServiceCollection();

View File

@@ -71,6 +71,7 @@
"DownloadingSetupFile": "Downloader installer...",
"InstallingSetupFile": "Installerer Tizen Studio CLI...",
"InstallingCertificateManager": "Installerer Certificate Manager...",
"ReInstallingCertificateManager": "Installation af Certifikathåndtering-tilføjelsen mislykkedes. Vil du prøve igen?",
"InstallingCertificateAddOn": "Installerer Certificate Manager add-on...",
"CheckingPackageManagerList": "Checker Tizen Package manager",
"PermissionDenied": "Adgang nægtet",
@@ -138,5 +139,6 @@
"minimalCliTitle": "Tizen CLI og certifikatadministrator kræves",
"minimalCliMessage": "Tizen CLI og certifikatadministrator er nødvendige for at fortsætte.\n\nVi downloader og installerer nu Tizen CLI efterfulgt af certifikatadministrator.\nDette kan tage et par minutter. Vær tålmodig under installationsprocessen.",
"minimalCliStop": "Brugeren afviste at installere Tizen CLI",
"packageAndSign": "Emballering og signering..."
"packageAndSign": "Emballering og signering...",
"certRetryFailed": "Gentagelse mislykkedes, opret venligst en fejl"
}

View File

@@ -71,6 +71,7 @@
"DownloadingSetupFile": "Downloading installer...",
"InstallingSetupFile": "Installing Tizen Studio CLI...",
"InstallingCertificateManager": "Installing Certificate Manager...",
"ReInstallingCertificateManager": "Installing Certificate Manager add-on failed, want to try again?",
"InstallingCertificateAddOn": "Installing Certificate Manager add-on...",
"CheckingPackageManagerList": "Checking Tizen Package manager",
"PermissionDenied": "Permission Denied",
@@ -138,5 +139,6 @@
"minimalCliTitle": "Tizen CLI & Certificate manager required",
"minimalCliMessage": "Tizen CLI & Certificate manager are required to continue.\n\nWe will now download and install Tizen CLI followed by Certificate manager.\nThis may take a few minutes. Please be patient during the installation process.",
"minimalCliStop": "User declined to install Tizen CLI",
"packageAndSign": "Packaging and signing..."
"packageAndSign": "Packaging and signing...",
"certRetryFailed": "Retry failed, please create an issue"
}

View File

@@ -71,6 +71,7 @@
"DownloadingSetupFile": "Installer downloaden...",
"InstallingSetupFile": "Tizen Studio CLI installeren...",
"InstallingCertificateManager": "Certificate Manager installeren...",
"ReInstallingCertificateManager": "Het installeren van de Certificate Manager-invoegtoepassing is mislukt. Wilt u het opnieuw proberen?",
"InstallingCertificateAddOn": "Certificate Manager add-on installeren...",
"CheckingPackageManagerList": "Tizen Package manager controleren",
"PermissionDenied": "Toestemming geweigerd",
@@ -138,5 +139,6 @@
"minimalCliTitle": "Tizen CLI & Certificaatbeheerder vereist",
"minimalCliMessage": "Tizen CLI en Certificaatbeheer zijn vereist om door te gaan.\n\nWe gaan nu Tizen CLI downloaden en installeren, gevolgd door Certificaatbeheer.\nDit kan enkele minuten duren. Wees geduldig tijdens het installatieproces.",
"minimalCliStop": "Gebruiker weigerde Tizen CLI te installeren",
"packageAndSign": "Inpakken en ondertekenen..."
"packageAndSign": "Inpakken en ondertekenen...",
"certRetryFailed": "Opnieuw proberen mislukt, maak een probleem aan"
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -51,7 +51,7 @@ namespace Jellyfin2SamsungCrossOS.Helpers
// ----- Application-scoped settings (readonly at runtime) -----
public string ReleasesUrl { get; set; } = "https://api.github.com/repos/jeppevinkel/jellyfin-tizen-builds/releases";
public string AuthorEndpoint { get; set; } = "https://dev.tizen.samsung.com/apis/v2/authors";
public string AppVersion { get; set; } = "v2.0.0";
public string AppVersion { get; set; } = "v1.8.0-beta";
public string TizenCliWindows { get; set; } = "https://download.tizen.org/sdk/Installer/tizen-studio_6.1/web-cli_Tizen_Studio_6.1_windows-64.exe";
public string TizenCliLinux { get; set; } = "https://download.tizen.org/sdk/Installer/tizen-studio_6.1/web-cli_Tizen_Studio_6.1_ubuntu-64.bin";
public string TizenCliMac { get; set; } = "https://download.tizen.org/sdk/Installer/tizen-studio_6.1/web-cli_Tizen_Studio_6.1_macos-64.bin";

View File

@@ -3,6 +3,7 @@ using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -152,5 +153,85 @@ namespace Jellyfin2SamsungCrossOS.Helpers
return null;
}
}
public async Task<ProcessResult> RunPrivilegedCommandAsync(string programPath, string[] arguments, string? workingDirectory = null)
{
if (OperatingSystem.IsWindows())
{
throw new PlatformNotSupportedException("RunPrivilegedCommandAsync only supports Linux/macOS currently.");
}
string fileName;
string args;
if (OperatingSystem.IsMacOS())
{
// Use osascript for macOS GUI privilege escalation
fileName = "osascript";
var command = $"{programPath} {string.Join(" ", arguments.Select(EscapeShellArgument))}";
args = $"-e \"do shell script \\\"{EscapeAppleScriptString(command)}\\\" with administrator privileges\"";
}
else if (OperatingSystem.IsLinux())
{
// Try pkexec first (GUI prompt), fallback to gksu/kdesu
var escalationTool = await GetLinuxPrivilegeEscalationTool();
fileName = escalationTool;
if (escalationTool == "pkexec")
{
args = $"{programPath} {string.Join(" ", arguments.Select(EscapeShellArgument))}";
}
else if (escalationTool == "gksu" || escalationTool == "kdesu")
{
var command = $"{programPath} {string.Join(" ", arguments.Select(EscapeShellArgument))}";
args = $"\"{command}\"";
}
else
{
throw new InvalidOperationException("No GUI privilege escalation tool found. Please install pkexec, gksu, or kdesu.");
}
}
else
{
throw new PlatformNotSupportedException("Unsupported OS.");
}
return await RunCommandAsync(fileName, args, workingDirectory);
}
private static string EscapeShellArgument(string arg)
{
if (string.IsNullOrEmpty(arg))
return "\"\"";
// Escape single quotes and wrap in single quotes for shell safety
return $"'{arg.Replace("'", "'\"'\"'")}'";
}
private static string EscapeAppleScriptString(string str)
{
// Escape quotes and backslashes for AppleScript
return str.Replace("\\", "\\\\").Replace("\"", "\\\"");
}
private async Task<string> GetLinuxPrivilegeEscalationTool()
{
// Check which GUI privilege escalation tools are available
var tools = new[] { "pkexec", "gksu", "kdesu" };
foreach (var tool in tools)
{
try
{
var result = await RunCommandAsync("which", tool);
if (result.ExitCode == 0)
return tool;
}
catch
{
// Continue to next tool
}
}
return "pkexec"; // Default fallback
}
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Jellyfin2SamsungCrossOS</string>
<key>CFBundleDisplayName</key>
<string>Jellyfin2Samsung</string>
<key>CFBundleIdentifier</key>
<string>com.madebypatrick.jellyfin2samsung</string>
<key>CFBundleVersion</key>
<string>1.8.0-beta</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleExecutable</key>
<string>Jellyfin2SamsungCrossOS</string>
<key>CFBundleIconFile</key>
<string>jelly2sams.icns</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict>
</plist>

View File

@@ -7,7 +7,22 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<AssemblyName>Jellyfin2SamsungCrossOS</AssemblyName>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<!-- Windows icon -->
<ApplicationIcon>Assets\jelly2sams.ico</ApplicationIcon>
<!-- macOS bundle info -->
<CFBundleName>Jellyfin2SamsungCrossOS</CFBundleName>
<CFBundleDisplayName>Jellyfin to Samsung TV</CFBundleDisplayName>
<CFBundleIdentifier>com.yourcompany.jellyfin2samsung</CFBundleIdentifier>
<CFBundleVersion>1.0.0</CFBundleVersion>
<CFBundlePackageType>APPL</CFBundlePackageType>
<CFBundleSignature>????</CFBundleSignature>
<CFBundleExecutable>Jellyfin2SamsungCrossOS</CFBundleExecutable>
<CFBundleIconFile>jelly2sams.icns</CFBundleIconFile>
<!-- Linux desktop entry info -->
<LinuxDesktopFile>true</LinuxDesktopFile>
<LinuxDesktopFileName>jellyfin2samsung.desktop</LinuxDesktopFileName>
</PropertyGroup>
<ItemGroup>
@@ -33,6 +48,18 @@
</ItemGroup>
<ItemGroup>
<None Include="Assets\jelly2sams.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Assets\jelly2sams.icns" Condition="Exists('Assets\jelly2sams.icns')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Assets\jelly2sams.png" Condition="Exists('Assets\jelly2sams.png')">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.3.6" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.6" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.6" />

View File

@@ -4,6 +4,7 @@
{
public int ExitCode { get; set; }
public string Output { get; set; } = string.Empty;
public string Error { get; set; } = string.Empty;
}
}

View File

@@ -100,10 +100,10 @@ namespace Jellyfin2SamsungCrossOS.Services
return dialog;
}
public async Task ShowMessageAsync(string message)
public async Task ShowMessageAsync(string title, string message)
{
var window = GetMainWindow();
var dialog = CreateStyledDialog("Message", new TextBlock
var dialog = CreateStyledDialog(title, new TextBlock
{
Text = message,
TextWrapping = TextWrapping.Wrap,

View File

@@ -4,7 +4,7 @@ namespace Jellyfin2SamsungCrossOS.Services
{
public interface IDialogService
{
Task ShowMessageAsync(string message);
Task ShowMessageAsync(string title, string message);
Task ShowErrorAsync(string message);
Task<bool> ShowConfirmationAsync(string title, string message, string yes, string no);
Task<string?> PromptForIpAsync();

View File

@@ -175,7 +175,7 @@ namespace Jellyfin2SamsungCrossOS.Services
if (defaultPath.Length > MaxSafePathLength)
{
_dialogService.ShowMessageAsync("Path length exceeded the safe limit. Using fallback path.").Wait();
_dialogService.ShowMessageAsync("Path length exceeded", "Path length exceeded the safe limit. Using fallback path.").Wait();
_installPath = fallbackPath;
}
else
@@ -552,7 +552,6 @@ namespace Jellyfin2SamsungCrossOS.Services
}
else
{
// Linux / macOS
await _processHelper.RunCommandAsync("chmod", $"+x \"{installerPath}\"");
var result = await _processHelper.RunCommandAsync("bash", $"\"{installerPath}\" --accept-license \"{installPath}\"");
cliInstalled = result.ExitCode == 0;
@@ -566,18 +565,15 @@ namespace Jellyfin2SamsungCrossOS.Services
if (!cliInstalled)
return "Tizen CLI installation failed.";
// 6⃣ Install Certificate tooling
installingWindow.ViewModel.StatusText = "Installing Tizen Certificate tooling...";
bool certInstalled = await InstallSamsungCertificateExtensionAsync(installPath, installingWindow);
Debug.WriteLine($"certInstalled: {certInstalled}");
// 7⃣ Retry logic if certificate failed
if (!certInstalled)
{
bool retry = await _dialogService.ShowConfirmationAsync(
"retryCertTitle".Localized(),
"retryCertMessage".Localized(),
"InstallationFailed".Localized(),
"ReInstallingCertificateManager".Localized(),
"keyYes".Localized(),
"keyNo".Localized());
@@ -616,7 +612,7 @@ namespace Jellyfin2SamsungCrossOS.Services
public async Task<bool> InstallSamsungCertificateExtensionAsync(string installPath, InstallingWindow installingWindow)
{
string certManagerExe = OperatingSystem.IsWindows() ? "certificate-manager.exe" : "certificate-manager";
string certManagerExe = OperatingSystem.IsWindows() ? "certificate-manager.exe" : "certificate-manager.bin";
string[] possiblePaths = {
Path.Combine(installPath, "tools", "certificate-manager", certManagerExe),
Path.Combine(installPath, "certificate-manager", certManagerExe)
@@ -626,7 +622,7 @@ namespace Jellyfin2SamsungCrossOS.Services
if (possiblePaths.Any(File.Exists))
return true;
string packageManagerExe = OperatingSystem.IsWindows() ? "package-manager-cli.exe" : "package-manager-cli";
string packageManagerExe = OperatingSystem.IsWindows() ? "package-manager-cli.exe" : "package-manager-cli.bin";
string packageManagerPath = Path.Combine(installPath, "package-manager", packageManagerExe);
if (!File.Exists(packageManagerPath))
@@ -679,10 +675,11 @@ namespace Jellyfin2SamsungCrossOS.Services
{
// Linux/macOS CLI-based installation
installingWindow.ViewModel.SetStatusText("Installing Certificate Manager...");
await _processHelper.RunCommandAsync(packageManagerPath, "install 'Certificate-Manager' --accept-license", installPath);
await _processHelper.RunCommandAsync(packageManagerPath, "install Certificate-Manager --accept-license");
installingWindow.ViewModel.SetStatusText("Installing Certificate Add-On...");
await _processHelper.RunCommandAsync(packageManagerPath, "install 'cert-add-on' --accept-license", installPath);
//await _processHelper.RunCommandAsyncEx("pkexec",new[] { packageManagerPath, "install", "cert-add-on", "--accept-license" });
await _processHelper.RunPrivilegedCommandAsync(packageManagerPath,new[] { "install", "cert-add-on", "--accept-license" });
}
// Verify installation

View File

@@ -89,8 +89,6 @@ namespace Jellyfin2SamsungCrossOS.ViewModels
_localizationService = localizationService;
_localizationService.LanguageChanged += OnLanguageChanged;
InitializeAsync();
}
private void OnLanguageChanged(object? sender, EventArgs e)
@@ -326,9 +324,7 @@ namespace Jellyfin2SamsungCrossOS.ViewModels
var avResponse = await _httpClient.GetStringAsync(AppSettings.Default.JellyfinAvRelease);
var avRelease = JsonConvert.DeserializeObject<GitHubRelease>(avResponse, settings);
if (avRelease != null)
{
Releases.Add(avRelease);
}
}
catch (Exception ex)
{

View File

@@ -8,13 +8,6 @@ namespace Jellyfin2SamsungCrossOS.Views
public MainWindow()
{
InitializeComponent();
this.Opened += async (_, __) =>
{
if (DataContext is MainWindowViewModel vm)
{
await vm.InitializeAsync();
}
};
}
}
}

View File

@@ -0,0 +1,43 @@
# Build script for cross-platform publishing
param(
[string]$Configuration = "Release"
)
$ProjectName = "Jellyfin2SamsungCrossOS"
$OutputDir = "./publish"
# Clean previous builds
if (Test-Path $OutputDir) {
Remove-Item $OutputDir -Recurse -Force
}
Write-Host "Publishing for Windows..." -ForegroundColor Green
dotnet publish -c $Configuration -r win-x64 --self-contained -o "$OutputDir/win-x64"
Write-Host "Publishing for macOS..." -ForegroundColor Green
dotnet publish -c $Configuration -r osx-x64 --self-contained -o "$OutputDir/osx-x64"
Write-Host "Publishing for Linux..." -ForegroundColor Green
dotnet publish -c $Configuration -r linux-x64 --self-contained -o "$OutputDir/linux-x64"
# Create macOS app bundle
Write-Host "Creating macOS app bundle..." -ForegroundColor Green
$MacOSAppPath = "$OutputDir/osx-x64/$ProjectName.app"
New-Item -ItemType Directory -Path "$MacOSAppPath/Contents/MacOS" -Force
New-Item -ItemType Directory -Path "$MacOSAppPath/Contents/Resources" -Force
Move-Item "$OutputDir/osx-x64/$ProjectName" "$MacOSAppPath/Contents/MacOS/"
Copy-Item "Info.plist" "$MacOSAppPath/Contents/"
if (Test-Path "Assets/jelly2sams.icns") {
Copy-Item "Assets/jelly2sams.icns" "$MacOSAppPath/Contents/Resources/"
}
# Copy Linux desktop file and icon
Write-Host "Setting up Linux package..." -ForegroundColor Green
Copy-Item "jellyfin2samsung.desktop" "$OutputDir/linux-x64/"
Copy-Item "start-jellyfin2samsung.sh" "$OutputDir/linux-x64/"
if (Test-Path "Assets/jelly2sams.png") {
Copy-Item "Assets/jelly2sams.png" "$OutputDir/linux-x64/"
}
Write-Host "Build complete! Check the $OutputDir folder." -ForegroundColor Yellow

View File

@@ -0,0 +1,11 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Jellyfin2Samsung
Comment=Install Jellyfin on Samsung Smart TVs
Icon=jelly2sams
Terminal=false
Categories=Utility;Network;
StartupNotify=true
MimeType=application/x-jellyfin2samsung;
Exec=start-jellyfin2samsung.sh

View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Get the directory of this script, works even if cwd is different
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Binary is in the same folder
APP_BIN="$SCRIPT_DIR/Jellyfin2SamsungCrossOS"
# Check root
if [ "$(id -u)" -ne 0 ]; then
if command -v pkexec >/dev/null 2>&1; then
exec pkexec "$APP_BIN" "$@"
else
exec sudo "$APP_BIN" "$@"
fi
else
exec "$APP_BIN" "$@"
fi