mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-01 18:35:13 +00:00
Support .rpm
This commit is contained in:
@@ -23,38 +23,42 @@
|
||||
<ColumnDefinition Width="150" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="image"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Width="120"
|
||||
Height="120"
|
||||
Margin="8"
|
||||
VerticalAlignment="Top"
|
||||
Opacity="0"
|
||||
RenderOptions.BitmapScalingMode="HighQuality"
|
||||
SnapsToDevicePixels="True"
|
||||
Stretch="Fill"
|
||||
UseLayoutRounding="True">
|
||||
<Image.Style>
|
||||
<Style TargetType="{x:Type Image}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Source, ElementName=image}" Value="{x:Null}">
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation BeginTime="0:0:0"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
From="0"
|
||||
To="1"
|
||||
Duration="0:0:0.05" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Image.Style>
|
||||
</Image>
|
||||
<Border x:Name="imageBk"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Width="124"
|
||||
Height="124"
|
||||
VerticalAlignment="Top"
|
||||
CornerRadius="8">
|
||||
<Image x:Name="image"
|
||||
Width="120"
|
||||
Height="120"
|
||||
Opacity="0"
|
||||
RenderOptions.BitmapScalingMode="HighQuality"
|
||||
SnapsToDevicePixels="True"
|
||||
Stretch="Fill"
|
||||
UseLayoutRounding="True">
|
||||
<Image.Style>
|
||||
<Style TargetType="{x:Type Image}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Source, ElementName=image}" Value="{x:Null}">
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation BeginTime="0:0:0"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
From="0"
|
||||
To="1"
|
||||
Duration="0:0:0.05" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Image.Style>
|
||||
</Image>
|
||||
</Border>
|
||||
<Grid Grid.Row="1" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="5" />
|
||||
@@ -73,6 +77,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="1"
|
||||
@@ -143,47 +148,67 @@
|
||||
Text="Searching..."
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="Wrap" />
|
||||
<!-- Vendor -->
|
||||
<TextBlock x:Name="vendorTitle"
|
||||
Grid.Row="6"
|
||||
Grid.Column="1"
|
||||
Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||
Text="Vendor" />
|
||||
<TextBlock x:Name="vendor"
|
||||
Grid.Row="6"
|
||||
Grid.Column="2"
|
||||
Margin="8,0,0,0"
|
||||
Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||
Text="Searching..."
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="Wrap" />
|
||||
<!-- Type -->
|
||||
<TextBlock x:Name="typeTitle"
|
||||
Grid.Row="6"
|
||||
Grid.Row="7"
|
||||
Grid.Column="1"
|
||||
Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||
Text="Type" />
|
||||
Text="Type"
|
||||
Visibility="Collapsed" />
|
||||
<TextBlock x:Name="type"
|
||||
Grid.Row="6"
|
||||
Grid.Row="7"
|
||||
Grid.Column="2"
|
||||
Margin="8,0,0,0"
|
||||
Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||
Text="Searching..."
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="Wrap" />
|
||||
TextWrapping="Wrap"
|
||||
Visibility="Collapsed" />
|
||||
<!-- Terminal -->
|
||||
<TextBlock x:Name="terminalTitle"
|
||||
Grid.Row="7"
|
||||
Grid.Row="8"
|
||||
Grid.Column="1"
|
||||
Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||
Text="Terminal" />
|
||||
Text="Terminal"
|
||||
Visibility="Collapsed" />
|
||||
<TextBlock x:Name="terminal"
|
||||
Grid.Row="7"
|
||||
Grid.Row="8"
|
||||
Grid.Column="2"
|
||||
Margin="8,0,0,0"
|
||||
Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||
Text="Searching..."
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="Wrap" />
|
||||
TextWrapping="Wrap"
|
||||
Visibility="Collapsed" />
|
||||
<!-- Total Size -->
|
||||
<TextBlock x:Name="totalSizeTitle"
|
||||
Grid.Row="8"
|
||||
Grid.Row="9"
|
||||
Grid.Column="1"
|
||||
Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||
Text="Total Size" />
|
||||
<TextBlock x:Name="totalSize"
|
||||
Grid.Row="8"
|
||||
Grid.Row="9"
|
||||
Grid.Column="2"
|
||||
Margin="8,0,0,0"
|
||||
Padding="3"
|
||||
@@ -191,13 +216,13 @@
|
||||
Text="Calculating size..." />
|
||||
<!-- Last Modified -->
|
||||
<TextBlock x:Name="modDateTitle"
|
||||
Grid.Row="9"
|
||||
Grid.Row="10"
|
||||
Grid.Column="1"
|
||||
Padding="3"
|
||||
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||
Text="Last Modified" />
|
||||
<TextBlock x:Name="modDate"
|
||||
Grid.Row="9"
|
||||
Grid.Row="10"
|
||||
Grid.Column="2"
|
||||
Margin="8,0,0,0"
|
||||
Padding="3"
|
||||
@@ -206,7 +231,7 @@
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
<!-- Environment -->
|
||||
<GroupBox x:Name="environmentGroupBox"
|
||||
Grid.Row="10"
|
||||
Grid.Row="11"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="3,3,16,16"
|
||||
|
@@ -18,7 +18,6 @@
|
||||
using QuickLook.Common.ExtensionMethods;
|
||||
using QuickLook.Common.Helpers;
|
||||
using QuickLook.Common.Plugin;
|
||||
using QuickLook.Plugin.AppViewer.PackageParsers.AppImage;
|
||||
using QuickLook.Plugin.AppViewer.PackageParsers.Rpm;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
@@ -26,6 +25,7 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace QuickLook.Plugin.AppViewer.InfoPanels;
|
||||
@@ -45,6 +45,7 @@ public partial class RpmInfoPanel : UserControl, IAppInfoPanel
|
||||
applicationNameTitle.Text = TranslationHelper.Get("APP_NAME", translationFile);
|
||||
versionTitle.Text = TranslationHelper.Get("APP_VERSION", translationFile);
|
||||
architectureTitle.Text = TranslationHelper.Get("ARCHITECTURE", translationFile);
|
||||
vendorTitle.Text = TranslationHelper.Get("VENDOR", translationFile);
|
||||
typeTitle.Text = TranslationHelper.Get("TYPE", translationFile);
|
||||
terminalTitle.Text = TranslationHelper.Get("TERMINAL", translationFile);
|
||||
totalSizeTitle.Text = TranslationHelper.Get("TOTAL_SIZE", translationFile);
|
||||
@@ -69,19 +70,21 @@ public partial class RpmInfoPanel : UserControl, IAppInfoPanel
|
||||
{
|
||||
applicationName.Text = rpmInfo.Name;
|
||||
version.Text = rpmInfo.Version;
|
||||
architectureName.Text = rpmInfo.Arch;
|
||||
type.Text = rpmInfo.Type;
|
||||
terminal.Text = rpmInfo.Terminal;
|
||||
architectureName.Text = rpmInfo.Arch; // Not impl
|
||||
vendor.Text = rpmInfo.Vendor;
|
||||
type.Text = rpmInfo.Type; // Not impl
|
||||
terminal.Text = rpmInfo.Terminal; // Not impl
|
||||
totalSize.Text = size.ToPrettySize(2);
|
||||
modDate.Text = last.ToString(CultureInfo.CurrentCulture);
|
||||
permissions.ItemsSource = rpmInfo.Env;
|
||||
permissions.ItemsSource = rpmInfo.Env; // Not impl
|
||||
|
||||
if (rpmInfo.HasIcon)
|
||||
if (rpmInfo.HasIcon) // Not impl
|
||||
{
|
||||
image.Source = rpmInfo.Logo.ToBitmapSource();
|
||||
}
|
||||
else
|
||||
{
|
||||
imageBk.Background = new SolidColorBrush(OSThemeHelper.AppsUseDarkTheme() ? Colors.LightGray : Colors.White);
|
||||
image.Source = new BitmapImage(new Uri("pack://application:,,,/QuickLook.Plugin.AppViewer;component/Resources/rpm.png"));
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,8 @@ public class RpmInfo
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Vendor { get; set; }
|
||||
|
||||
public string Exec { get; set; }
|
||||
|
||||
public string Icon { get; set; }
|
||||
|
@@ -15,7 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using QuickLook.Plugin.AppViewer.PackageParsers.AppImage;
|
||||
using RpmReaderNet;
|
||||
|
||||
namespace QuickLook.Plugin.AppViewer.PackageParsers.Rpm;
|
||||
|
||||
@@ -23,19 +23,24 @@ public class RpmParser
|
||||
{
|
||||
public static RpmInfo Parse(string path)
|
||||
{
|
||||
var reader = new RpmReader(path);
|
||||
using var reader = new RpmReader(path);
|
||||
|
||||
#if DEBUG
|
||||
try { _ = reader.ToString(); } catch { }
|
||||
#endif
|
||||
|
||||
return new RpmInfo()
|
||||
{
|
||||
Arch = reader.Arch,
|
||||
Version = reader.Version,
|
||||
Name = reader.Name,
|
||||
Exec = reader.Exec,
|
||||
Icon = reader.Icon,
|
||||
Logo = reader.Logo,
|
||||
Type = reader.Type,
|
||||
Terminal = reader.Terminal,
|
||||
Env = reader.Env,
|
||||
Vendor = reader.Vendor,
|
||||
//Exec = reader.Exec,
|
||||
//Icon = reader.Icon,
|
||||
//Logo = reader.Logo,
|
||||
//Type = reader.Type,
|
||||
//Terminal = reader.Terminal,
|
||||
//Env = reader.Env,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,117 +0,0 @@
|
||||
// Copyright © 2017-2025 QL-Win Contributors
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using PureSharpCompress.Common;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace QuickLook.Plugin.AppViewer.PackageParsers.Rpm;
|
||||
|
||||
public class RpmReader
|
||||
{
|
||||
public string Arch { get; set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Exec { get; set; }
|
||||
|
||||
public string Icon { get; set; }
|
||||
|
||||
public Bitmap Logo { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
|
||||
public string Terminal { get; set; }
|
||||
|
||||
public string[] Env { get; set; }
|
||||
|
||||
public RpmReader(Stream stream)
|
||||
{
|
||||
Open(stream);
|
||||
}
|
||||
|
||||
public RpmReader(string path)
|
||||
{
|
||||
using FileStream fs = File.OpenRead(path);
|
||||
Open(fs);
|
||||
}
|
||||
|
||||
private void Open(Stream stream)
|
||||
{
|
||||
using var br = new BinaryReader(stream);
|
||||
|
||||
// Step 1: Read the lead (96 bytes)
|
||||
byte[] lead = br.ReadBytes(96);
|
||||
Debug.WriteLine($"[lead] 96 bytes read, magic: {BitConverter.ToString(lead, 0, 4)}");
|
||||
|
||||
// Step 2: Read signature header
|
||||
RpmHeader sigHeader = ReadHeader(br);
|
||||
Debug.WriteLine($"[signature header] IndexCount: {sigHeader.IndexCount}, DataSize: {sigHeader.DataSize}");
|
||||
|
||||
// Step 3: Read main header
|
||||
RpmHeader mainHeader = ReadHeader(br);
|
||||
Debug.WriteLine($"[main header] IndexCount: {mainHeader.IndexCount}, DataSize: {mainHeader.DataSize}");
|
||||
|
||||
// Step 4: Remaining is the payload (cpio archive + compression)
|
||||
long payloadSize = stream.Length - stream.Position;
|
||||
Debug.WriteLine($"[payload] Size: {payloadSize} bytes at offset: {stream.Position}");
|
||||
|
||||
// (Optional) Detect compression (e.g. gzip, xz, zstd)
|
||||
byte[] magic = br.ReadBytes(6);
|
||||
string type = magic[0] switch
|
||||
{
|
||||
0x1F when magic[1] == 0x8B => "gzip",
|
||||
0xFD when magic[1] == 0x37 => "xz",
|
||||
0x28 when magic[1] == 0xB5 => "zstd",
|
||||
_ => "unknown"
|
||||
};
|
||||
Debug.WriteLine($"Detected payload compression: {type}");
|
||||
}
|
||||
|
||||
private static RpmHeader ReadHeader(BinaryReader br)
|
||||
{
|
||||
// ed ab ee db 03
|
||||
byte[] magic = br.ReadBytes(3);
|
||||
//if (Encoding.ASCII.GetString(magic) != "\x8e\xad\xe8")
|
||||
//throw new InvalidDataException("Invalid RPM header magic");
|
||||
|
||||
byte version = br.ReadByte(); // Usually 1
|
||||
byte[] reserved = br.ReadBytes(4);
|
||||
int indexCount = ReadBigEndianInt32(br);
|
||||
int dataSize = ReadBigEndianInt32(br);
|
||||
return new RpmHeader { IndexCount = indexCount, DataSize = dataSize };
|
||||
}
|
||||
|
||||
private static int ReadBigEndianInt32(BinaryReader br)
|
||||
{
|
||||
byte[] b = br.ReadBytes(4);
|
||||
if (b.Length < 4) throw new EndOfStreamException();
|
||||
return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
|
||||
}
|
||||
|
||||
private class RpmHeader
|
||||
{
|
||||
public int IndexCount { get; set; }
|
||||
|
||||
public int DataSize { get; set; }
|
||||
}
|
||||
}
|
@@ -51,7 +51,7 @@ public class Plugin : IViewer
|
||||
// Ubuntu
|
||||
".deb", // Debian Package
|
||||
".appimage", // AppImage Format
|
||||
// ".rpm", // Red Hat Package Manager
|
||||
".rpm", // Red Hat Package Manager
|
||||
|
||||
// Others
|
||||
".wgt", ".wgtu", // UniApp Widget
|
||||
@@ -83,7 +83,7 @@ public class Plugin : IViewer
|
||||
".deb" => new Size { Width = 600, Height = 345 },
|
||||
".dmg" => new Size { Width = 560, Height = 510 },
|
||||
".appimage" => new Size { Width = 600, Height = 300 },
|
||||
".rpm" => new Size { Width = 600, Height = 300 },
|
||||
".rpm" => new Size { Width = 600, Height = 260 },
|
||||
".wgt" or ".wgtu" => new Size { Width = 600, Height = 345 },
|
||||
_ => throw new NotSupportedException("Extension is not supported."),
|
||||
};
|
||||
|
@@ -78,6 +78,7 @@
|
||||
<PackageReference Include="ApkReader" Version="2.0.1.1" />
|
||||
<PackageReference Include="PureSharpCompress" Version="0.39.0" />
|
||||
<PackageReference Include="QuickLook.DiscUtils" Version="1.0.0" />
|
||||
<PackageReference Include="QuickLook.RpmReader" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 4.6 KiB |
@@ -31,6 +31,7 @@
|
||||
<ENVIRONMENT>Environment</ENVIRONMENT>
|
||||
<TYPE>Type</TYPE>
|
||||
<TERMINAL>Terminal</TERMINAL>
|
||||
<VENDOR>Vendor</VENDOR>
|
||||
</en>
|
||||
<pt-BR>
|
||||
<PRODUCT_VERSION>Versão do produto</PRODUCT_VERSION>
|
||||
@@ -62,6 +63,7 @@
|
||||
<ENVIRONMENT>Ambiente</ENVIRONMENT>
|
||||
<TYPE>Tipo</TYPE>
|
||||
<TERMINAL>Terminal</TERMINAL>
|
||||
<VENDOR>Fornecedor</VENDOR>
|
||||
</pt-BR>
|
||||
<zh-CN>
|
||||
<PRODUCT_VERSION>产品版本</PRODUCT_VERSION>
|
||||
@@ -93,6 +95,7 @@
|
||||
<ENVIRONMENT>运行环境</ENVIRONMENT>
|
||||
<TYPE>类型</TYPE>
|
||||
<TERMINAL>终端</TERMINAL>
|
||||
<VENDOR>供应商</VENDOR>
|
||||
</zh-CN>
|
||||
<zh-TW>
|
||||
<PRODUCT_VERSION>產品版本</PRODUCT_VERSION>
|
||||
@@ -124,6 +127,7 @@
|
||||
<ENVIRONMENT>執行環境</ENVIRONMENT>
|
||||
<TYPE>類型</TYPE>
|
||||
<TERMINAL>終端機</TERMINAL>
|
||||
<VENDOR>供應商</VENDOR>
|
||||
</zh-TW>
|
||||
<ja>
|
||||
<PRODUCT_VERSION>製品バージョン</PRODUCT_VERSION>
|
||||
@@ -155,6 +159,7 @@
|
||||
<ENVIRONMENT>実行環境</ENVIRONMENT>
|
||||
<TYPE>種類</TYPE>
|
||||
<TERMINAL>ターミナル</TERMINAL>
|
||||
<VENDOR>ベンダー</VENDOR>
|
||||
</ja>
|
||||
<de>
|
||||
<PRODUCT_VERSION>Produktversion</PRODUCT_VERSION>
|
||||
@@ -186,5 +191,6 @@
|
||||
<ENVIRONMENT>Umgebung</ENVIRONMENT>
|
||||
<TYPE>Typ</TYPE>
|
||||
<TERMINAL>Terminal</TERMINAL>
|
||||
<VENDOR>Anbieter</VENDOR>
|
||||
</de>
|
||||
</Translations>
|
||||
|
Reference in New Issue
Block a user