Compare commits
No commits in common. "main" and "1.0.3.1" have entirely different histories.
64 changed files with 630 additions and 1222 deletions
|
@ -1,5 +1,3 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
|
@ -9,16 +7,24 @@ indent_style = space
|
|||
indent_size = 4 # A property with the same name was updated with a value 2 in a section [{*.yaml,*.yml}]
|
||||
|
||||
[{*.yaml,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2 # A property with the same name was updated with a value 4 in a section [*]; with a value 4 in a section [*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
|
||||
dotnet_diagnostic.CA1047.severity = error
|
||||
|
||||
[*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
|
||||
indent_style = space
|
||||
indent_size = 4 # A property with the same name was updated with a value 2 in a section [{*.yaml,*.yml}]
|
||||
tab_width = 4
|
||||
|
||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
|
||||
dotnet_style_prefer_auto_properties = true:warning
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||
|
@ -29,8 +35,13 @@ dotnet_style_namespace_match_folder = true:suggestion
|
|||
dotnet_style_readonly_field = true:warning
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
|
||||
dotnet_style_predefined_type_for_member_access = true:warning
|
||||
dotnet_style_require_accessibility_modifiers = always:error
|
||||
dotnet_style_allow_multiple_blank_lines_experimental = false:silent
|
||||
dotnet_style_allow_statement_immediately_after_block_experimental = false:silent
|
||||
dotnet_code_quality_unused_parameters = all:warning
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||
dotnet_style_qualification_for_field = false:silent
|
||||
dotnet_style_qualification_for_property = false:silent
|
||||
|
@ -66,8 +77,6 @@ dotnet_diagnostic.CA1852.severity = suggestion
|
|||
dotnet_diagnostic.CA2012.severity = warning
|
||||
dotnet_diagnostic.CA2019.severity = warning
|
||||
dotnet_diagnostic.CA2211.severity = warning
|
||||
dotnet_diagnostic.CA1822.severity = suggestion
|
||||
dotnet_diagnostic.CA1725.severity = suggestion
|
||||
|
||||
[*.cs]
|
||||
|
||||
|
@ -703,16 +712,14 @@ resharper_blank_lines_inside_region = 1
|
|||
resharper_blank_lines_inside_type = 0
|
||||
resharper_blank_line_after_pi = true
|
||||
resharper_braces_for_dowhile = required
|
||||
resharper_braces_for_fixed = required_for_multiline
|
||||
resharper_braces_for_fixed = required
|
||||
resharper_braces_for_for = required_for_multiline
|
||||
resharper_braces_for_foreach = required_for_multiline
|
||||
resharper_braces_for_ifelse = required_for_multiline
|
||||
resharper_braces_for_lock = required_for_multiline
|
||||
resharper_braces_for_using = required_for_multiline
|
||||
resharper_braces_for_lock = required
|
||||
resharper_braces_for_using = required
|
||||
resharper_braces_for_while = required_for_multiline
|
||||
resharper_braces_redundant = true
|
||||
resharper_builtin_type_apply_to_native_integer = true
|
||||
resharper_csharp_empty_block_style = together_same_line
|
||||
resharper_break_template_declaration = line_break
|
||||
resharper_can_use_global_alias = false
|
||||
resharper_configure_await_analysis_mode = disabled
|
||||
|
@ -810,7 +817,7 @@ resharper_indent_typearg_angles = inside
|
|||
resharper_indent_typeparam_angles = inside
|
||||
resharper_indent_type_constraints = true
|
||||
resharper_indent_wrapped_function_names = false
|
||||
resharper_instance_members_qualify_declared_in =
|
||||
resharper_instance_members_qualify_declared_in = base_class
|
||||
resharper_int_align_assignments = false
|
||||
resharper_int_align_binary_expressions = false
|
||||
resharper_int_align_declaration_names = false
|
||||
|
@ -911,7 +918,7 @@ resharper_place_simple_switch_expression_on_single_line = false
|
|||
resharper_place_type_attribute_on_same_line = false
|
||||
resharper_place_type_constraints_on_same_line = true
|
||||
resharper_prefer_explicit_discard_declaration = false
|
||||
resharper_prefer_separate_deconstructed_variables_declaration = false
|
||||
resharper_prefer_separate_deconstructed_variables_declaration = true
|
||||
resharper_preserve_spaces_inside_tags = pre,textarea
|
||||
resharper_qualified_using_at_nested_scope = false
|
||||
resharper_quote_style = doublequoted
|
||||
|
@ -1062,7 +1069,6 @@ resharper_space_within_typeof_parentheses = false
|
|||
resharper_space_within_type_argument_angles = false
|
||||
resharper_space_within_type_parameter_angles = false
|
||||
resharper_space_within_type_parameter_parentheses = false
|
||||
resharper_csharp_allow_alias = false
|
||||
resharper_special_else_if_treatment = true
|
||||
resharper_static_members_qualify_members = none
|
||||
resharper_static_members_qualify_with = declared_type
|
||||
|
@ -1168,7 +1174,7 @@ resharper_arrange_default_value_when_type_evident_highlighting = suggestion
|
|||
resharper_arrange_default_value_when_type_not_evident_highlighting = suggestion
|
||||
resharper_arrange_local_function_body_highlighting = error
|
||||
resharper_arrange_method_or_operator_body_highlighting = error
|
||||
resharper_arrange_missing_parentheses_highlighting = none
|
||||
resharper_arrange_missing_parentheses_highlighting = hint
|
||||
resharper_arrange_namespace_body_highlighting = error
|
||||
resharper_arrange_object_creation_when_type_evident_highlighting = suggestion
|
||||
resharper_arrange_object_creation_when_type_not_evident_highlighting = suggestion
|
||||
|
@ -1283,7 +1289,7 @@ resharper_convert_to_using_declaration_highlighting = suggestion
|
|||
resharper_convert_to_vb_auto_property_highlighting = suggestion
|
||||
resharper_convert_to_vb_auto_property_when_possible_highlighting = hint
|
||||
resharper_convert_to_vb_auto_property_with_private_setter_highlighting = hint
|
||||
resharper_convert_type_check_pattern_to_null_check_highlighting = none
|
||||
resharper_convert_type_check_pattern_to_null_check_highlighting = warning
|
||||
resharper_convert_type_check_to_null_check_highlighting = warning
|
||||
resharper_co_variant_array_conversion_highlighting = warning
|
||||
resharper_c_declaration_with_implicit_int_type_highlighting = warning
|
||||
|
@ -1402,8 +1408,8 @@ resharper_meaningless_default_parameter_value_highlighting = warning
|
|||
resharper_member_can_be_internal_highlighting = none
|
||||
resharper_member_can_be_made_static_global_highlighting = hint
|
||||
resharper_member_can_be_made_static_local_highlighting = hint
|
||||
resharper_member_can_be_private_global_highlighting = hint
|
||||
resharper_member_can_be_private_local_highlighting = hint
|
||||
resharper_member_can_be_private_global_highlighting = suggestion
|
||||
resharper_member_can_be_private_local_highlighting = suggestion
|
||||
resharper_member_can_be_protected_global_highlighting = suggestion
|
||||
resharper_member_can_be_protected_local_highlighting = suggestion
|
||||
resharper_member_hides_interface_member_with_default_implementation_highlighting = warning
|
||||
|
@ -1531,7 +1537,7 @@ resharper_redundant_assignment_highlighting = warning
|
|||
resharper_redundant_attribute_parentheses_highlighting = hint
|
||||
resharper_redundant_attribute_usage_property_highlighting = suggestion
|
||||
resharper_redundant_base_constructor_call_highlighting = warning
|
||||
resharper_redundant_base_qualifier_highlighting = none
|
||||
resharper_redundant_base_qualifier_highlighting = warning
|
||||
resharper_redundant_blank_lines_highlighting = none
|
||||
resharper_redundant_bool_compare_highlighting = warning
|
||||
resharper_redundant_case_label_highlighting = warning
|
||||
|
@ -1541,7 +1547,7 @@ resharper_redundant_check_before_assignment_highlighting = warning
|
|||
resharper_redundant_collection_initializer_element_braces_highlighting = hint
|
||||
resharper_redundant_configure_await_highlighting = suggestion
|
||||
resharper_redundant_declaration_semicolon_highlighting = hint
|
||||
resharper_redundant_default_member_initializer_highlighting = hint
|
||||
resharper_redundant_default_member_initializer_highlighting = warning
|
||||
resharper_redundant_delegate_creation_highlighting = warning
|
||||
resharper_redundant_disable_warning_comment_highlighting = warning
|
||||
resharper_redundant_discard_designation_highlighting = suggestion
|
||||
|
@ -1867,17 +1873,3 @@ resharper_void_method_with_must_use_return_value_attribute_highlighting = warnin
|
|||
resharper_with_expression_instead_of_initializer_highlighting = suggestion
|
||||
resharper_wrong_indent_size_highlighting = none
|
||||
resharper_xunit_xunit_test_with_console_output_highlighting = warning
|
||||
resharper_arrange_constructor_or_destructor_body_highlighting = hint
|
||||
resharper_arrange_local_function_body_highlighting = hint
|
||||
resharper_arrange_method_or_operator_body_highlighting = hint
|
||||
resharper_arrange_null_checking_pattern_highlighting = suggestion
|
||||
resharper_enforce_do_while_statement_braces_highlighting = warning
|
||||
resharper_enforce_fixed_statement_braces_highlighting = warning
|
||||
resharper_enforce_foreach_statement_braces_highlighting = none
|
||||
resharper_enforce_for_statement_braces_highlighting = none
|
||||
resharper_enforce_if_statement_braces_highlighting = none
|
||||
resharper_enforce_lock_statement_braces_highlighting = warning
|
||||
resharper_enforce_while_statement_braces_highlighting = none
|
||||
resharper_remove_redundant_braces_highlighting = hint
|
||||
resharper_suggest_discard_declaration_var_style_highlighting = warning
|
||||
resharper_prefer_concrete_value_over_default_highlighting = hint
|
|
@ -1,56 +0,0 @@
|
|||
name: Bug Report
|
||||
description: File a bug report.
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Which version of EllieHub are you using?
|
||||
multiple: false
|
||||
options:
|
||||
- "Windows x64"
|
||||
- "Windows arm64"
|
||||
- "Linux x64"
|
||||
- "Linux arm64"
|
||||
- "MacOS x64"
|
||||
- "MacOS arm64"
|
||||
- "I compiled from source"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Description"
|
||||
description: "Give a concise description of the problem"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Reproduction Steps"
|
||||
description: "Enumerate the steps needed to reproduce the behavior"
|
||||
value: "1. Go to '...'\n2. Click on '....'\n3. Scroll down to '....'\n4. See error"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Expected Behavior"
|
||||
description: "Describe what you expected to happen"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Actual Behavior"
|
||||
description: "Describe what actually happened"
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Screenshots"
|
||||
description: "If applicable, add screenshots to help explain your problem"
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Notes"
|
||||
description: "Add any other context about the problem here"
|
||||
placeholder: "eg. OS version, etc"
|
||||
validations:
|
||||
required: false
|
|
@ -1,30 +0,0 @@
|
|||
name: "Feature Request"
|
||||
description: Suggest an idea for this project.
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: "textarea"
|
||||
attributes:
|
||||
label: "Is your feature request related to a problem?"
|
||||
description: "If so, describe what the problem is"
|
||||
placeholder: "eg. I'm always frustrated when [...]"
|
||||
validations:
|
||||
required: false
|
||||
- type: "textarea"
|
||||
attributes:
|
||||
label: "Describe the feature you'd like"
|
||||
description: "Describe what you want to happen"
|
||||
placeholder: "eg. The application should do [...] then [...]"
|
||||
validations:
|
||||
required: true
|
||||
- type: "textarea"
|
||||
attributes:
|
||||
label: "What alternatives have you considered?"
|
||||
description: "Feel free to mention similar applications if you feel this will get your point across better"
|
||||
validations:
|
||||
required: false
|
||||
- type: "textarea"
|
||||
attributes:
|
||||
label: "Additional context"
|
||||
description: "Add any other context or screenshots about the feature request here"
|
||||
validations:
|
||||
required: false
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -481,6 +481,3 @@ $RECYCLE.BIN/
|
|||
# Built files
|
||||
build/*
|
||||
zips/*
|
||||
|
||||
# Scripts
|
||||
release.ps1
|
|
@ -5,11 +5,6 @@ VisualStudioVersion = 17.6.33829.357
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EllieHub", "EllieHub\EllieHub.csproj", "{6E399AD5-2130-4F97-A08F-397EFCE5872A}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2A553F1B-5A2C-43D6-A145-F219530326D3}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
release.ps1 = release.ps1
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
|
@ -20,7 +20,7 @@ public partial class App : Application
|
|||
/// </summary>
|
||||
public IServiceProvider Services { get; } = new ServiceCollection()
|
||||
.RegisterViewsAndViewModels(Assembly.GetExecutingAssembly())
|
||||
.RegisterAppServices()
|
||||
.RegisterServices()
|
||||
.BuildServiceProvider(true);
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -6,7 +6,7 @@ using EllieHub.Features.AppWindow.Views.Windows;
|
|||
using EllieHub.Features.BotConfig.Services.Abstractions;
|
||||
using EllieHub.Features.BotConfig.Services.Mocks;
|
||||
using EllieHub.Features.BotConfig.ViewModels;
|
||||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
namespace EllieHub.Avalonia.DesignData.Controls;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ using EllieHub.Features.AppConfig.Services.Abstractions;
|
|||
using EllieHub.Features.AppConfig.Services.Mocks;
|
||||
using EllieHub.Features.AppConfig.ViewModels;
|
||||
using EllieHub.Features.AppWindow.Views.Windows;
|
||||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
namespace EllieHub.Avalonia.DesignData.Controls;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using EllieHub.Avalonia.DesignData.Common;
|
||||
using EllieHub.Features.AppWindow.Views.Windows;
|
||||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
namespace EllieHub.Avalonia.DesignData.Controls;
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@ public sealed class DesignFakeConsoleViewModel : FakeConsoleViewModel
|
|||
/// <summary>
|
||||
/// Creates a mock <see cref="FakeConsoleViewModel"/> to be used at design-time.
|
||||
/// </summary>
|
||||
public DesignFakeConsoleViewModel()
|
||||
public DesignFakeConsoleViewModel() : base()
|
||||
=> Watermark = "Sample watermark.";
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using Avalonia.Platform.Storage;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using EllieHub.Avalonia.DesignData.Common;
|
||||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
namespace EllieHub.Avalonia.DesignData.Controls;
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
<SolidColorBrush x:Key='LightBackground'>#FAF5F8</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='MediumBackground'>#FCFAFC</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='HeavyBackground'>#FFFAFD</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='BotSelectionColor'>#3498DB</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='BotSelectionColor'>#FF0067</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='HyperlinkColor'>Blue</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key='Dark'>
|
||||
<SolidColorBrush x:Key='LightBackground'>#252525</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='MediumBackground'>#202020</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='HeavyBackground'>#181818</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='BotSelectionColor'>#206694</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='BotSelectionColor'>#D90058</SolidColorBrush>
|
||||
<SolidColorBrush x:Key='HyperlinkColor'>#5090BB</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<FontFamily x:Key="NotoSansFont">avares://EllieHub/Assets/Fonts/NotoSans-Regular.ttf</FontFamily>
|
||||
<FontFamily x:Key="NotoSansBoldFont">avares://EllieHub/Assets/Fonts/NotoSans-Bold.ttf</FontFamily>
|
||||
|
||||
<!--Preview-->
|
||||
<Design.PreviewWith>
|
||||
<Border Padding="20">
|
||||
|
@ -17,4 +13,7 @@
|
|||
</StackPanel>
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
|
||||
<FontFamily x:Key="NotoSansFont">avares://EllieHub/Assets/Fonts/NotoSans-Regular.ttf</FontFamily>
|
||||
<FontFamily x:Key="NotoSansBoldFont">avares://EllieHub/Assets/Fonts/NotoSans-Bold.ttf</FontFamily>
|
||||
</ResourceDictionary>
|
|
@ -50,7 +50,7 @@
|
|||
<Bitmap x:Key="UrlIcon">avares://EllieHub/Assets/Light/icon-link.png</Bitmap>
|
||||
<Bitmap x:Key="SuggestionIcon">avares://EllieHub/Assets/Light/icon-suggest.png</Bitmap>
|
||||
<Bitmap x:Key="DiscordIcon">avares://EllieHub/Assets/Light/icon-support.png</Bitmap>
|
||||
<WindowIcon x:Key="EllieHubIcon"><![CDATA[avares://EllieHub/Assets/Light/ellieupdatericon.ico]]></WindowIcon>
|
||||
<WindowIcon x:Key="EllieHubIcon">avares://EllieHub/Assets/Light/ellieupdatericon.ico</WindowIcon>
|
||||
<Bitmap x:Key="EllieHubImage">avares://EllieHub/Assets/Light/ellieupdatericon.ico</Bitmap>
|
||||
<Bitmap x:Key="TerminalIcon">avares://EllieHub/Assets/Light/terminal.png</Bitmap>
|
||||
</ResourceDictionary>
|
||||
|
@ -65,7 +65,7 @@
|
|||
<Bitmap x:Key="UrlIcon">avares://EllieHub/Assets/Dark/icon-link.png</Bitmap>
|
||||
<Bitmap x:Key="SuggestionIcon">avares://EllieHub/Assets/Dark/icon-suggest.png</Bitmap>
|
||||
<Bitmap x:Key="DiscordIcon">avares://EllieHub/Assets/Dark/icon-support.png</Bitmap>
|
||||
<WindowIcon x:Key="EllieHubIcon"><![CDATA[avares://EllieHub/Assets/Dark/ellieupdatericon.ico]]></WindowIcon>
|
||||
<WindowIcon x:Key="EllieHubIcon">avares://EllieHub/Assets/Dark/ellieupdatericon.ico</WindowIcon>
|
||||
<Bitmap x:Key="EllieHubImage">avares://EllieHub/Assets/Dark/ellieupdatericon.ico</Bitmap>
|
||||
<Bitmap x:Key="TerminalIcon">avares://EllieHub/Assets/Dark/terminal.png</Bitmap>
|
||||
</ResourceDictionary>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<Border Classes="circular">
|
||||
<Button Classes="accent" Content="+" />
|
||||
</Border>
|
||||
<Button Classes="link-11" Content="HyperlinkButton" />
|
||||
<TextBlock Text="Text Block" />
|
||||
<TextBox Classes="console" Watermark="Fake Console" />
|
||||
<TextBox Watermark="Regular Text Box" Text="Sample Text" />
|
||||
|
@ -85,6 +86,31 @@
|
|||
</Style>
|
||||
</Style>
|
||||
|
||||
<!--Button styled like a hyperlink text-->
|
||||
<Style Selector="Button.link-11">
|
||||
<Setter Property="Foreground" Value="{DynamicResource HyperlinkColor}" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<ContentPresenter Content="{TemplateBinding Content}">
|
||||
<ContentPresenter.Styles>
|
||||
<Style Selector="TextBlock">
|
||||
<Setter Property="Foreground" Value="{TemplateBinding Foreground}"/>
|
||||
<!--This should be binding to the template's FontSize, but since I'm overriding-->
|
||||
<!--the main TextBlock class, this doesn't seem to work properly, so I have to set-->
|
||||
<!--the value manually-->
|
||||
<Setter Property="FontSize" Value="11"/>
|
||||
<Setter Property="TextDecorations" Value="Underline"/>
|
||||
</Style>
|
||||
</ContentPresenter.Styles>
|
||||
</ContentPresenter>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--Circular Border-->
|
||||
<Style Selector="Border.circular">
|
||||
<Setter Property="ClipToBounds" Value="True" />
|
||||
|
|
|
@ -15,35 +15,35 @@ public static partial class AppStatics
|
|||
/// Defines the default location where the updater configuration and bot instances are stored.
|
||||
/// </summary>
|
||||
#if DEBUG
|
||||
public static string AppDefaultConfigDirectoryUri { get; } = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "EllieHubDebug");
|
||||
public static string AppDefaultConfigDirectoryUri { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "EllieHubDebug");
|
||||
#else
|
||||
public static string AppDefaultConfigDirectoryUri { get; } = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EllieHub");
|
||||
public static string AppDefaultConfigDirectoryUri { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EllieHub");
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Defines the default location where the bot instances are stored.
|
||||
/// </summary>
|
||||
public static string AppDefaultBotDirectoryUri { get; } = Path.Join(AppDefaultConfigDirectoryUri, "Bots");
|
||||
public static string AppDefaultBotDirectoryUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "Bots");
|
||||
|
||||
/// <summary>
|
||||
/// Defines the default location where the backups of bot instances are stored.
|
||||
/// </summary>
|
||||
public static string AppDefaultBotBackupDirectoryUri { get; } = Path.Join(AppDefaultConfigDirectoryUri, "Backups");
|
||||
public static string AppDefaultBotBackupDirectoryUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "Backups");
|
||||
|
||||
/// <summary>
|
||||
/// Defines the default location where the logs of bot instances are stored.
|
||||
/// </summary>
|
||||
public static string AppDefaultLogDirectoryUri { get; } = Path.Join(AppDefaultConfigDirectoryUri, "Logs");
|
||||
public static string AppDefaultLogDirectoryUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "Logs");
|
||||
|
||||
/// <summary>
|
||||
/// Defines the location of the application's configuration file.
|
||||
/// </summary>
|
||||
public static string AppConfigUri { get; } = Path.Join(AppDefaultConfigDirectoryUri, "config.json");
|
||||
public static string AppConfigUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "config.json");
|
||||
|
||||
/// <summary>
|
||||
/// Defines the location of the application's dependencies.
|
||||
/// </summary>
|
||||
public static string AppDepsUri { get; } = Path.Join(AppDefaultConfigDirectoryUri, "Dependencies");
|
||||
public static string AppDepsUri { get; } = Path.Combine(AppDefaultConfigDirectoryUri, "Dependencies");
|
||||
|
||||
/// <summary>
|
||||
/// Defines a transparent color brush.
|
||||
|
@ -56,11 +56,11 @@ public static partial class AppStatics
|
|||
public static FilePickerOpenOptions ImageFilePickerOptions { get; } = new()
|
||||
{
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter =
|
||||
[
|
||||
new("Image") { Patterns = ["*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp"]},
|
||||
new("All") { Patterns = ["*.*"]}
|
||||
]
|
||||
FileTypeFilter = new FilePickerFileType[]
|
||||
{
|
||||
new("Image") { Patterns = new[] { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" } },
|
||||
new("All") { Patterns = new[] { "*.*" } }
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
using Avalonia.Platform;
|
||||
using SkiaSharp;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace EllieHub.Common;
|
||||
|
||||
|
@ -8,30 +11,205 @@ namespace EllieHub.Common;
|
|||
/// </summary>
|
||||
internal static class Utilities
|
||||
{
|
||||
private static readonly string _programVerifier = (Environment.OSVersion.Platform is PlatformID.Win32NT) ? "where" : "which";
|
||||
private static readonly string _envPathSeparator = (Environment.OSVersion.Platform is PlatformID.Win32NT) ? ";" : ":";
|
||||
private static readonly EnvironmentVariableTarget _envTarget = (Environment.OSVersion.Platform is PlatformID.Win32NT)
|
||||
? EnvironmentVariableTarget.User
|
||||
: EnvironmentVariableTarget.Process;
|
||||
|
||||
/// <summary>
|
||||
/// Loads an image embedded with this application.
|
||||
/// Loads an image embeded with this application.
|
||||
/// </summary>
|
||||
/// <param name="uri">An uri that starts with "avares://"</param>
|
||||
/// <remarks>Valid uris must start with "avares://".</remarks>
|
||||
/// <returns>The embedded image or the default bot avatar placeholder.</returns>
|
||||
/// <exception cref="FileNotFoundException">Occurs when the embedded resource does not exist.</exception>
|
||||
public static SKBitmap LoadEmbeddedImage(string? uri = default)
|
||||
/// <returns>The embeded image or the default bot avatar placeholder.</returns>
|
||||
/// <exception cref="FileNotFoundException">Occurs when the embeded resource does not exist.</exception>
|
||||
public static SKBitmap LoadEmbededImage(string? uri = default)
|
||||
{
|
||||
return (string.IsNullOrWhiteSpace(uri) || !uri.StartsWith("avares://", StringComparison.Ordinal))
|
||||
? SKBitmap.Decode(AssetLoader.Open(new(AppConstants.BotAvatarUri)))
|
||||
: SKBitmap.Decode(AssetLoader.Open(new(uri)));
|
||||
? SKBitmap.Decode(AssetLoader.Open(new Uri(AppConstants.BotAvatarUri)))
|
||||
: SKBitmap.Decode(AssetLoader.Open(new Uri(uri)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the image at the specified location or the bot avatar placeholder if it was not found.
|
||||
/// </summary>
|
||||
/// <param name="imagePath">The absolute path to the image file or <see langword="null"/> to get the avatar placeholder.</param>
|
||||
/// <remarks>This fallsback to <see cref="LoadEmbeddedImage(string?)"/> if <paramref name="imagePath"/> doesn't point to a valid image file.</remarks>
|
||||
/// <param name="uri">The absolute path to the image file or <see langword="null"/> to get the avatar placeholder.</param>
|
||||
/// <remarks>This fallsback to <see cref="LoadEmbededImage(string?)"/> if <paramref name="uri"/> doesn't point to a valid image file.</remarks>
|
||||
/// <returns>The requested image or the default bot avatar placeholder.</returns>
|
||||
public static SKBitmap LoadLocalImage(string? imagePath)
|
||||
public static SKBitmap LoadLocalImage(string? uri = default)
|
||||
{
|
||||
return (File.Exists(imagePath))
|
||||
? SKBitmap.Decode(imagePath)
|
||||
: LoadEmbeddedImage(imagePath);
|
||||
return (File.Exists(uri))
|
||||
? SKBitmap.Decode(uri)
|
||||
: LoadEmbededImage(uri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Safely casts an <see cref="object"/> to a <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to cast to.</typeparam>
|
||||
/// <param name="obj">The object to be cast.</param>
|
||||
/// <param name="castObject">The cast object, or <see langword="null"/> is casting failed.</param>
|
||||
/// <returns><see langword="true"/> if the object was successfully cast, <see langword="false"/> otherwise.</returns>
|
||||
public static bool TryCastTo<T>(object? obj, [MaybeNullWhen(false)] out T castObject)
|
||||
{
|
||||
if (obj is T result)
|
||||
{
|
||||
castObject = result;
|
||||
return true;
|
||||
}
|
||||
|
||||
castObject = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the specified program in the background.
|
||||
/// </summary>
|
||||
/// <param name="program">
|
||||
/// The name of the program in the PATH environment variable,
|
||||
/// or the absolute path to its executable.
|
||||
/// </param>
|
||||
/// <param name="arguments">The arguments to the program.</param>
|
||||
/// <returns>The process of the specified program.</returns>
|
||||
/// <exception cref="ArgumentException" />
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
/// <exception cref="Win32Exception">Occurs when <paramref name="program"/> does not exist.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when the process fails to execute.</exception>
|
||||
public static Process StartProcess(string program, string arguments = "")
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(program, nameof(program));
|
||||
ArgumentNullException.ThrowIfNull(arguments, nameof(arguments));
|
||||
|
||||
return Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
FileName = program,
|
||||
Arguments = arguments,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardOutput = true,
|
||||
}) ?? throw new InvalidOperationException($"Failed spawing process for: {program} {arguments}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a program exists.
|
||||
/// </summary>
|
||||
/// <param name="programName">The name of the program.</param>
|
||||
/// <param name="cToken">The cancellation token.</param>
|
||||
/// <returns><see langword="true"/> if the program exists, <see langword="false"/> otherwise.</returns>
|
||||
/// <exception cref="ArgumentException" />
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
public static async ValueTask<bool> ProgramExistsAsync(string programName, CancellationToken cToken = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(programName, nameof(programName));
|
||||
|
||||
using var process = StartProcess(_programVerifier, programName);
|
||||
return !string.IsNullOrWhiteSpace(await process.StandardOutput.ReadToEndAsync(cToken));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Safely deletes a file.
|
||||
/// </summary>
|
||||
/// <param name="fileUri">The absolute path to the file.</param>
|
||||
/// <returns><see langword="true"/> if the file was deleted, <see langword="false"/> otherwise.</returns>
|
||||
/// <exception cref="ArgumentException" />
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
/// <exception cref="IOException" />
|
||||
/// <exception cref="NotSupportedException" />
|
||||
/// <exception cref="PathTooLongException" />
|
||||
/// <exception cref="UnauthorizedAccessException" />
|
||||
public static bool TryDeleteFile(string fileUri)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(fileUri, nameof(fileUri));
|
||||
|
||||
if (!File.Exists(fileUri))
|
||||
return false;
|
||||
|
||||
File.Delete(fileUri);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Safely deletes a directory.
|
||||
/// </summary>
|
||||
/// <param name="directoryUri">The absolute path to the directory.</param>
|
||||
/// <returns><see langword="true"/> if the directory was deleted, <see langword="false"/> otherwise.</returns>
|
||||
/// <exception cref="ArgumentException" />
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
/// <exception cref="IOException" />
|
||||
/// <exception cref="DirectoryNotFoundException" />
|
||||
/// <exception cref="PathTooLongException" />
|
||||
/// <exception cref="UnauthorizedAccessException" />
|
||||
public static bool TryDeleteDirectory(string directoryUri)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(directoryUri, nameof(directoryUri));
|
||||
|
||||
if (!Directory.Exists(directoryUri))
|
||||
return false;
|
||||
|
||||
Directory.Delete(directoryUri, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if this application can write to <paramref name="directoryUri"/>.
|
||||
/// </summary>
|
||||
/// <param name="directoryUri">The absolute path to a directory.</param>
|
||||
/// <returns><see langword="true"/> if writing is allowed, <see langword="false"/> otherwise.</returns>
|
||||
/// <exception cref="PathTooLongException" />
|
||||
/// <exception cref="DirectoryNotFoundException" />
|
||||
public static bool CanWriteTo(string directoryUri)
|
||||
{
|
||||
var tempFileUri = Path.Combine(directoryUri, $"{Guid.NewGuid()}.tmp");
|
||||
|
||||
try
|
||||
{
|
||||
using var fileStream = File.Create(tempFileUri);
|
||||
return true;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
TryDeleteFile(tempFileUri);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a directory path to the PATH environment variable.
|
||||
/// </summary>
|
||||
/// <param name="directoryUri">The absolute path to a directory.</param>
|
||||
/// <remarks>
|
||||
/// On Windows, this needs to be called once and the dependencies will be available for the user forever. <br />
|
||||
/// On Unix systems, we can only add to the PATH on a process basis, so this needs to be called at least once everytime the application is opened.
|
||||
/// </remarks>
|
||||
/// <returns><see langword="true"/> if <paramref name="directoryUri"/> got successfully added to the PATH envar, <see langword="false"/> otherwise.</returns>
|
||||
/// <exception cref="ArgumentException" />
|
||||
/// <exception cref="ArgumentNullException" />
|
||||
public static bool AddPathToPATHEnvar(string directoryUri)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(directoryUri, nameof(directoryUri));
|
||||
|
||||
if (File.Exists(directoryUri))
|
||||
throw new ArgumentException("Parameter must point to a directory, not a file.", nameof(directoryUri));
|
||||
|
||||
var envPathValue = Environment.GetEnvironmentVariable("PATH", _envTarget) ?? string.Empty;
|
||||
|
||||
// If directoryPath is already in the PATH envar, don't add it again.
|
||||
if (envPathValue.Contains(directoryUri, StringComparison.Ordinal))
|
||||
return false;
|
||||
|
||||
var newPathEnvValue = envPathValue + _envPathSeparator + directoryUri;
|
||||
|
||||
// Add path to Windows' user envar, so it persists across reboots.
|
||||
if (Environment.OSVersion.Platform is PlatformID.Win32NT)
|
||||
Environment.SetEnvironmentVariable("PATH", newPathEnvValue, EnvironmentVariableTarget.User);
|
||||
|
||||
// Add path to the current process' envar, so the updater can see the dependencies.
|
||||
Environment.SetEnvironmentVariable("PATH", newPathEnvValue, EnvironmentVariableTarget.Process);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<!--Project Settings-->
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AnalysisLevel>latest</AnalysisLevel>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
@ -20,7 +20,7 @@
|
|||
<DebugType>embedded</DebugType>
|
||||
|
||||
<!--Version-->
|
||||
<VersionPrefix>1.0.4.0</VersionPrefix>
|
||||
<VersionPrefix>1.0.3.1</VersionPrefix>
|
||||
|
||||
<!--Avalonia Settings-->
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
|
@ -46,23 +46,21 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.1.5" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.1.5" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.5" />
|
||||
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.1.5" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.5" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.5" />
|
||||
<PackageReference Include="Toastie.DependencyInjection" Version="3.0.0" />
|
||||
<PackageReference Include="Toastie.Events" Version="3.0.0" />
|
||||
<PackageReference Include="Avalonia" Version="11.0.10" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10" />
|
||||
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.10" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
|
||||
<PackageReference Include="Toastie.Events" Version="2.2.1" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.1.5.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
<PackageReference Include="SingleFileExtractor.Core" Version="2.2.0" />
|
||||
<PackageReference Include="SkiaImageView.Avalonia11" Version="1.5.0" />
|
||||
<PackageReference Include="Toastie.Utilities" Version="3.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -10,6 +10,7 @@ using EllieHub.Features.BotConfig.Services.Abstractions;
|
|||
using EllieHub.Features.BotConfig.Services.Mocks;
|
||||
using EllieHub.Features.Home.Services;
|
||||
using EllieHub.Features.Home.Services.Abstractions;
|
||||
using EllieHub.Services;
|
||||
using ReactiveUI;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
@ -47,7 +48,7 @@ public static class IServiceCollectionExt
|
|||
/// </summary>
|
||||
/// <param name="serviceCollection">This service collection.</param>
|
||||
/// <returns>This service collection with the services added.</returns>
|
||||
public static IServiceCollection RegisterAppServices(this IServiceCollection serviceCollection)
|
||||
public static IServiceCollection RegisterServices(this IServiceCollection serviceCollection)
|
||||
{
|
||||
// Design-time
|
||||
if (Design.IsDesignMode)
|
||||
|
@ -65,18 +66,18 @@ public static class IServiceCollectionExt
|
|||
|
||||
// Web requests
|
||||
serviceCollection.AddHttpClient();
|
||||
serviceCollection.AddHttpClient(AppConstants.NoRedirectClient) // Client that doesn't allow automatic redirections
|
||||
serviceCollection.AddHttpClient(AppConstants.NoRedirectClient) // Client that doesn't allow automatic reditections
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler() { AllowAutoRedirect = false });
|
||||
serviceCollection.AddHttpClient(AppConstants.ToastielabClient)
|
||||
.ConfigureHttpClient(x =>
|
||||
{
|
||||
x.DefaultRequestHeaders.Add("Accept", "application/vnd.toastielab+json");
|
||||
x.DefaultRequestHeaders.Add("X-Toastielab-Api-Version", "2022-11-28");
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
x.DefaultRequestHeaders.UserAgent.TryParseAdd($"EllieHub v{AppStatics.AppVersion}-Debug");
|
||||
#else
|
||||
#else
|
||||
x.DefaultRequestHeaders.UserAgent.TryParseAdd($"EllieHub v{AppStatics.AppVersion}");
|
||||
#endif
|
||||
#endif
|
||||
});
|
||||
|
||||
// App settings
|
||||
|
|
31
EllieHub/Extensions/IServiceProviderExt.cs
Normal file
31
EllieHub/Extensions/IServiceProviderExt.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace EllieHub.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Defines extension methods for <see cref="IServiceProvider"/>.
|
||||
/// </summary>
|
||||
public static class IServiceProviderExt
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets service of type <typeparamref name="T"/> from the <see cref="IServiceProvider"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of service object to get.</typeparam>
|
||||
/// <param name="serviceProvider">The <see cref="IServiceProvider"/> to retrieve the service object from.</param>
|
||||
/// <param name="arguments"></param>
|
||||
/// <remarks>Do not use abstract types in the type argument!</remarks>
|
||||
/// <returns>A service object of type <typeparamref name="T"/>.</returns>
|
||||
/// <exception cref="ArgumentNullException">Occurs when <paramref name="serviceProvider"/> or <paramref name="arguments"/> are <see langword="null"/>.</exception>
|
||||
/// <exception cref="InvalidOperationException">Occurs when there is no concrete service of type <typeparamref name="T"/> or when the arguments are wrong.</exception>
|
||||
public static T GetParameterizedService<T>(this IServiceProvider serviceProvider, params object[] arguments)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(serviceProvider, nameof(serviceProvider));
|
||||
ArgumentNullException.ThrowIfNull(arguments, nameof(arguments));
|
||||
|
||||
var result = ActivatorUtilities.CreateInstance<T>(serviceProvider, arguments);
|
||||
|
||||
return (result is null)
|
||||
? throw new InvalidOperationException($"There is no service of type {nameof(T)} or the arguments were incorrect.")
|
||||
: result;
|
||||
}
|
||||
}
|
|
@ -85,6 +85,6 @@ public static class WindowExt
|
|||
? throw new InvalidOperationException($"Resource '{resourceName}' was not found.")
|
||||
: (resource is T castResource)
|
||||
? castResource
|
||||
: throw new InvalidCastException($"Could not convert resource of type '{resource?.GetType().FullName}' to '{nameof(T)}'.");
|
||||
: throw new InvalidCastException($"Could not convert resource of type '{resource?.GetType()?.FullName}' to '{nameof(T)}'.");
|
||||
}
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
using Toastie.Utilities;
|
||||
|
||||
namespace EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
|
@ -24,7 +22,7 @@ public abstract class FfmpegResolver : IFfmpegResolver
|
|||
public virtual async ValueTask<bool?> CanUpdateAsync(CancellationToken cToken = default)
|
||||
{
|
||||
// Check where ffmpeg is referenced.
|
||||
using var whereProcess = ToastieUtilities.StartProcess(_programVerifier, FfmpegProcessName, true);
|
||||
using var whereProcess = Utilities.StartProcess(_programVerifier, FfmpegProcessName);
|
||||
var installationPath = await whereProcess.StandardOutput.ReadToEndAsync(cToken);
|
||||
|
||||
// If ffmpeg is present but not managed by us, just report it is installed.
|
||||
|
@ -34,7 +32,7 @@ public abstract class FfmpegResolver : IFfmpegResolver
|
|||
var currentVer = await GetCurrentVersionAsync(cToken);
|
||||
|
||||
// If ffmpeg or ffprobe are absent, a reinstall needs to be performed.
|
||||
if (currentVer is null || !ToastieUtilities.ProgramExists("ffprobe"))
|
||||
if (currentVer is null || !await Utilities.ProgramExistsAsync("ffprobe", cToken))
|
||||
return null;
|
||||
|
||||
var latestVer = await GetLatestVersionAsync(cToken);
|
||||
|
@ -46,20 +44,20 @@ public abstract class FfmpegResolver : IFfmpegResolver
|
|||
public virtual async ValueTask<string?> GetCurrentVersionAsync(CancellationToken cToken = default)
|
||||
{
|
||||
// If ffmpeg is not accessible from the shell...
|
||||
if (!ToastieUtilities.ProgramExists(FfmpegProcessName))
|
||||
if (!await Utilities.ProgramExistsAsync(FfmpegProcessName, cToken))
|
||||
{
|
||||
// And doesn't exist in the dependencies folder,
|
||||
// report that ffmpeg is not installed.
|
||||
if (!File.Exists(Path.Join(AppStatics.AppDepsUri, FileName)))
|
||||
if (!File.Exists(Path.Combine(AppStatics.AppDepsUri, FileName)))
|
||||
return null;
|
||||
|
||||
// Else, add the dependencies directory to the PATH envar,
|
||||
// then try again.
|
||||
ToastieUtilities.AddPathToPATHEnvar(AppStatics.AppDepsUri);
|
||||
Utilities.AddPathToPATHEnvar(AppStatics.AppDepsUri);
|
||||
return await GetCurrentVersionAsync(cToken);
|
||||
}
|
||||
|
||||
using var ffmpeg = ToastieUtilities.StartProcess(FfmpegProcessName, "-version", true);
|
||||
using var ffmpeg = Utilities.StartProcess(FfmpegProcessName, "-version");
|
||||
var match = AppStatics.FfmpegVersionRegex.Match(await ffmpeg.StandardOutput.ReadLineAsync(cToken) ?? string.Empty);
|
||||
|
||||
return match.Groups[1].Value;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using EllieHub.Features.Common.Services.Abstractions;
|
||||
using EllieHub.Features.Shared.Services.Abstractions;
|
||||
|
||||
namespace EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using EllieHub.Features.Common.Services.Abstractions;
|
||||
using EllieHub.Features.Shared.Services.Abstractions;
|
||||
|
||||
namespace EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using Toastie.Utilities;
|
||||
using EllieHub.Features.AppConfig.Models;
|
||||
using EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
using EllieHub.Features.AppWindow.Models;
|
||||
|
@ -34,7 +33,7 @@ public sealed class AppConfigManager : IAppConfigManager
|
|||
var newId = CreateNewId();
|
||||
var newPosition = _appConfig.BotEntries.Count is 0 ? 0 : _appConfig.BotEntries.Values.Max(x => x.Position) + 1;
|
||||
var newBotName = "NewBot_" + newPosition;
|
||||
var newEntry = new BotInstanceInfo(newBotName, Path.Join(_appConfig.BotsDirectoryUri, newBotName), newPosition);
|
||||
var newEntry = new BotInstanceInfo(newBotName, Path.Combine(_appConfig.BotsDirectoryUri, newBotName), newPosition);
|
||||
|
||||
if (!_appConfig.BotEntries.TryAdd(newId, newEntry))
|
||||
throw new InvalidOperationException($"Could not create a new bot entry with Id {newId}.");
|
||||
|
@ -50,7 +49,7 @@ public sealed class AppConfigManager : IAppConfigManager
|
|||
if (!_appConfig.BotEntries.TryRemove(id, out var removedEntry))
|
||||
return null;
|
||||
|
||||
ToastieUtilities.TryDeleteDirectory(removedEntry.InstanceDirectoryUri);
|
||||
Utilities.TryDeleteDirectory(removedEntry.InstanceDirectoryUri);
|
||||
|
||||
await SaveAsync(cToken);
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using Toastie.Utilities;
|
||||
using EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace EllieHub.Features.AppConfig.Services;
|
||||
namespace EllieHub.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service that checks, downloads, installs, and updates ffmpeg on Linux.
|
||||
|
@ -15,7 +14,7 @@ public sealed partial class FfmpegLinuxResolver : FfmpegResolver
|
|||
{
|
||||
private readonly Regex _ffmpegLatestVersionRegex = FfmpegLatestVersionRegexGenerator();
|
||||
private readonly string _tempDirectory = Path.GetTempPath();
|
||||
private bool _isUpdating;
|
||||
private bool _isUpdating = false;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -49,7 +48,7 @@ public sealed partial class FfmpegLinuxResolver : FfmpegResolver
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async ValueTask<(string? OldVersion, string? NewVersion)> InstallOrUpdateAsync(string installationUri, CancellationToken cToken = default)
|
||||
public override async ValueTask<(string? OldVersion, string? NewVersion)> InstallOrUpdateAsync(string dependenciesUri, CancellationToken cToken = default)
|
||||
{
|
||||
if (_isUpdating)
|
||||
return (null, null);
|
||||
|
@ -65,42 +64,42 @@ public sealed partial class FfmpegLinuxResolver : FfmpegResolver
|
|||
if (currentVersion == newVersion)
|
||||
return (currentVersion, null);
|
||||
|
||||
ToastieUtilities.TryDeleteFile(Path.Join(installationUri, FileName));
|
||||
ToastieUtilities.TryDeleteFile(Path.Join(installationUri, "ffprobe"));
|
||||
Utilities.TryDeleteFile(Path.Combine(dependenciesUri, FileName));
|
||||
Utilities.TryDeleteFile(Path.Combine(dependenciesUri, "ffprobe"));
|
||||
}
|
||||
|
||||
// Install
|
||||
Directory.CreateDirectory(installationUri);
|
||||
Directory.CreateDirectory(dependenciesUri);
|
||||
|
||||
var architecture = (RuntimeInformation.OSArchitecture is Architecture.X64) ? "amd" : "arm";
|
||||
var tarFileName = $"ffmpeg-release-{architecture}64-static.tar.xz";
|
||||
var http = _httpClientFactory.CreateClient();
|
||||
await using var downloadStream = await http.GetStreamAsync($"https://johnvansickle.com/ffmpeg/releases/{tarFileName}", cToken);
|
||||
using var downloadStream = await http.GetStreamAsync($"https://johnvansickle.com/ffmpeg/releases/{tarFileName}", cToken);
|
||||
|
||||
// Save tar file to the temporary directory.
|
||||
var tarFilePath = Path.Join(_tempDirectory, tarFileName);
|
||||
var tarExtractDir = Path.Join(_tempDirectory, $"ffmpeg-{newVersion}-{architecture}64-static");
|
||||
await using (var fileStream = new FileStream(tarFilePath, FileMode.Create))
|
||||
var tarFilePath = Path.Combine(_tempDirectory, tarFileName);
|
||||
var tarExtractDir = Path.Combine(_tempDirectory, $"ffmpeg-{newVersion}-{architecture}64-static");
|
||||
using (var fileStream = new FileStream(tarFilePath, FileMode.Create))
|
||||
await downloadStream.CopyToAsync(fileStream, cToken);
|
||||
|
||||
// Extract the tar file.
|
||||
using var extractProcess = ToastieUtilities.StartProcess("tar", ["xf", tarFilePath, $"--directory=\"{_tempDirectory}\""]);
|
||||
using var extractProcess = Utilities.StartProcess("tar", $"xf \"{tarFilePath}\" --directory=\"{_tempDirectory}\"");
|
||||
await extractProcess.WaitForExitAsync(cToken);
|
||||
|
||||
// Move ffmpeg to the dependencies directory.
|
||||
ToastieUtilities.TryMoveFile(Path.Join(tarExtractDir, FileName), Path.Join(installationUri, FileName), true);
|
||||
ToastieUtilities.TryMoveFile(Path.Join(tarExtractDir, "ffprobe"), Path.Join(installationUri, "ffprobe"), true);
|
||||
File.Move(Path.Combine(tarExtractDir, FileName), Path.Combine(dependenciesUri, FileName), true);
|
||||
File.Move(Path.Combine(tarExtractDir, "ffprobe"), Path.Combine(dependenciesUri, "ffprobe"), true);
|
||||
|
||||
// Mark the files as executable.
|
||||
using var chmod = ToastieUtilities.StartProcess("chmod", ["+x", Path.Join(installationUri, FileName), Path.Join(installationUri, "ffprobe")]);
|
||||
using var chmod = Utilities.StartProcess("chmod", $"+x \"{Path.Combine(dependenciesUri, FileName)}\" \"{Path.Combine(dependenciesUri, "ffprobe")}\"");
|
||||
await chmod.WaitForExitAsync(cToken);
|
||||
|
||||
// Cleanup
|
||||
ToastieUtilities.TryDeleteFile(tarFilePath);
|
||||
ToastieUtilities.TryDeleteDirectory(tarExtractDir, true);
|
||||
File.Delete(tarFilePath);
|
||||
Directory.Delete(tarExtractDir, true);
|
||||
|
||||
// Update environment variable
|
||||
ToastieUtilities.AddPathToPATHEnvar(installationUri);
|
||||
Utilities.AddPathToPATHEnvar(dependenciesUri);
|
||||
|
||||
_isUpdating = false;
|
||||
return (currentVersion, newVersion);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using Toastie.Utilities;
|
||||
using EllieHub.Features.AppConfig.Models.Api.Evermeet;
|
||||
using EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
using System.IO.Compression;
|
||||
|
@ -16,7 +15,7 @@ public sealed class FfmpegMacResolver : FfmpegResolver
|
|||
private const string _apiFfmpegInfoEndpoint = "https://evermeet.cx/ffmpeg/info/ffmpeg/release";
|
||||
private const string _apiFfprobeInfoEndpoint = "https://evermeet.cx/ffmpeg/info/ffprobe/release";
|
||||
private readonly string _tempDirectory = Path.GetTempPath();
|
||||
private bool _isUpdating;
|
||||
private bool _isUpdating = false;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -39,7 +38,7 @@ public sealed class FfmpegMacResolver : FfmpegResolver
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async ValueTask<(string? OldVersion, string? NewVersion)> InstallOrUpdateAsync(string installationUri, CancellationToken cToken = default)
|
||||
public override async ValueTask<(string? OldVersion, string? NewVersion)> InstallOrUpdateAsync(string dependenciesUri, CancellationToken cToken = default)
|
||||
{
|
||||
if (_isUpdating)
|
||||
return (null, null);
|
||||
|
@ -58,24 +57,24 @@ public sealed class FfmpegMacResolver : FfmpegResolver
|
|||
return (currentVersion, null);
|
||||
}
|
||||
|
||||
ToastieUtilities.TryDeleteFile(Path.Join(installationUri, FileName));
|
||||
ToastieUtilities.TryDeleteFile(Path.Join(installationUri, "ffprobe"));
|
||||
Utilities.TryDeleteFile(Path.Combine(dependenciesUri, FileName));
|
||||
Utilities.TryDeleteFile(Path.Combine(dependenciesUri, "ffprobe"));
|
||||
}
|
||||
|
||||
// Install
|
||||
Directory.CreateDirectory(installationUri);
|
||||
Directory.CreateDirectory(dependenciesUri);
|
||||
|
||||
var http = _httpClientFactory.CreateClient();
|
||||
var ffmpegResponse = await http.CallApiAsync<EvermeetInfo>(_apiFfmpegInfoEndpoint, cToken);
|
||||
var ffprobeResponse = await http.CallApiAsync<EvermeetInfo>(_apiFfprobeInfoEndpoint, cToken);
|
||||
|
||||
await Task.WhenAll(
|
||||
InstallDependencyAsync(ffmpegResponse, installationUri, cToken),
|
||||
InstallDependencyAsync(ffprobeResponse, installationUri, cToken)
|
||||
InstallDependencyAsync(ffmpegResponse, dependenciesUri, cToken),
|
||||
InstallDependencyAsync(ffprobeResponse, dependenciesUri, cToken)
|
||||
);
|
||||
|
||||
// Update environment variable
|
||||
ToastieUtilities.AddPathToPATHEnvar(installationUri);
|
||||
Utilities.AddPathToPATHEnvar(dependenciesUri);
|
||||
|
||||
_isUpdating = false;
|
||||
return (currentVersion, newVersion);
|
||||
|
@ -92,26 +91,26 @@ public sealed class FfmpegMacResolver : FfmpegResolver
|
|||
var http = _httpClientFactory.CreateClient();
|
||||
var downloadUrl = downloadInfo.Download["zip"].Url;
|
||||
var zipFileName = downloadUrl[(downloadUrl.LastIndexOf('/') + 1)..];
|
||||
var zipFilePath = Path.Join(_tempDirectory, zipFileName);
|
||||
var zipFilePath = Path.Combine(_tempDirectory, zipFileName);
|
||||
|
||||
// Download the zip file and save it to the temporary directory.
|
||||
await using var zipStream = await http.GetStreamAsync(downloadUrl, cToken);
|
||||
using var zipStream = await http.GetStreamAsync(downloadUrl, cToken);
|
||||
|
||||
await using (var fileStream = new FileStream(zipFilePath, FileMode.Create))
|
||||
using (var fileStream = new FileStream(zipFilePath, FileMode.Create))
|
||||
await zipStream.CopyToAsync(fileStream, cToken);
|
||||
|
||||
// Extract the zip file.
|
||||
ZipFile.ExtractToDirectory(zipFileName, _tempDirectory);
|
||||
|
||||
// Move the dependency binary.
|
||||
var finalFileUri = Path.Join(dependenciesUri, downloadInfo.Name);
|
||||
ToastieUtilities.TryMoveFile(Path.Join(_tempDirectory, downloadInfo.Name), finalFileUri, true);
|
||||
var finalFileUri = Path.Combine(dependenciesUri, downloadInfo.Name);
|
||||
File.Move(Path.Combine(_tempDirectory, downloadInfo.Name), finalFileUri, true);
|
||||
|
||||
// Mark binary as executable.
|
||||
using var chmod = ToastieUtilities.StartProcess("chmod", $"+x \"{finalFileUri}\"");
|
||||
using var chmod = Utilities.StartProcess("chmod", $"+x \"{finalFileUri}\"");
|
||||
await chmod.WaitForExitAsync(cToken);
|
||||
|
||||
// Cleanup.
|
||||
ToastieUtilities.TryDeleteFile(zipFilePath);
|
||||
File.Delete(zipFilePath);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
using Toastie.Utilities;
|
||||
using EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -14,7 +13,7 @@ namespace EllieHub.Features.AppConfig.Services;
|
|||
public sealed class FfmpegWindowsResolver : FfmpegResolver
|
||||
{
|
||||
private readonly string _tempDirectory = Path.GetTempPath();
|
||||
private bool _isUpdating;
|
||||
private bool _isUpdating = false;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -50,7 +49,7 @@ public sealed class FfmpegWindowsResolver : FfmpegResolver
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async ValueTask<(string? OldVersion, string? NewVersion)> InstallOrUpdateAsync(string installationUri, CancellationToken cToken = default)
|
||||
public override async ValueTask<(string? OldVersion, string? NewVersion)> InstallOrUpdateAsync(string dependenciesUri, CancellationToken cToken = default)
|
||||
{
|
||||
if (_isUpdating)
|
||||
return (null, null);
|
||||
|
@ -69,22 +68,22 @@ public sealed class FfmpegWindowsResolver : FfmpegResolver
|
|||
return (currentVersion, null);
|
||||
}
|
||||
|
||||
ToastieUtilities.TryDeleteFile(Path.Join(installationUri, FileName));
|
||||
ToastieUtilities.TryDeleteFile(Path.Join(installationUri, "ffprobe.exe"));
|
||||
//ToastieUtilities.TryDeleteFile(Path.Join(dependenciesUri, "ffplay.exe"));
|
||||
Utilities.TryDeleteFile(Path.Combine(dependenciesUri, FileName));
|
||||
Utilities.TryDeleteFile(Path.Combine(dependenciesUri, "ffprobe.exe"));
|
||||
//Utilities.TryDeleteFile(Path.Combine(dependenciesUri, "ffplay.exe"));
|
||||
}
|
||||
|
||||
// Install
|
||||
Directory.CreateDirectory(installationUri);
|
||||
Directory.CreateDirectory(dependenciesUri);
|
||||
|
||||
var zipFileName = $"ffmpeg-{newVersion}-full_build.zip";
|
||||
var http = _httpClientFactory.CreateClient();
|
||||
await using var downloadStream = await http.GetStreamAsync($"https://github.com/GyanD/codexffmpeg/releases/download/{newVersion}/{zipFileName}", cToken);
|
||||
using var downloadStream = await http.GetStreamAsync($"https://github.com/GyanD/codexffmpeg/releases/download/{newVersion}/{zipFileName}", cToken);
|
||||
|
||||
// Save zip file to the temporary directory.
|
||||
var zipFilePath = Path.Join(_tempDirectory, zipFileName);
|
||||
var zipExtractDir = Path.Join(_tempDirectory, zipFileName[..^4]);
|
||||
await using (var fileStream = new FileStream(zipFilePath, FileMode.Create))
|
||||
var zipFilePath = Path.Combine(_tempDirectory, zipFileName);
|
||||
var zipExtractDir = Path.Combine(_tempDirectory, zipFileName[..^4]);
|
||||
using (var fileStream = new FileStream(zipFilePath, FileMode.Create))
|
||||
await downloadStream.CopyToAsync(fileStream, cToken);
|
||||
|
||||
// Schedule installation to the thread-pool because ffmpeg is pretty
|
||||
|
@ -95,17 +94,17 @@ public sealed class FfmpegWindowsResolver : FfmpegResolver
|
|||
ZipFile.ExtractToDirectory(zipFilePath, _tempDirectory);
|
||||
|
||||
// Move ffmpeg to the dependencies directory.
|
||||
ToastieUtilities.TryMoveFile(Path.Join(zipExtractDir, "bin", FileName), Path.Join(installationUri, FileName), true);
|
||||
ToastieUtilities.TryMoveFile(Path.Join(zipExtractDir, "bin", "ffprobe.exe"), Path.Join(installationUri, "ffprobe.exe"), true);
|
||||
//ToastieUtilities.TryMoveFile(Path.Join(zipExtractDir, "bin", "ffplay.exe"), Path.Join(dependenciesUri, "ffplay.exe"));
|
||||
File.Move(Path.Combine(zipExtractDir, "bin", FileName), Path.Combine(dependenciesUri, FileName), true);
|
||||
File.Move(Path.Combine(zipExtractDir, "bin", "ffprobe.exe"), Path.Combine(dependenciesUri, "ffprobe.exe"), true);
|
||||
//File.Move(Path.Combine(zipExtractDir, "bin", "ffplay.exe"), Path.Combine(dependenciesUri, "ffplay.exe"));
|
||||
|
||||
// Cleanup
|
||||
ToastieUtilities.TryDeleteFile(zipFilePath);
|
||||
ToastieUtilities.TryDeleteDirectory(zipExtractDir);
|
||||
File.Delete(zipFilePath);
|
||||
Directory.Delete(zipExtractDir, true);
|
||||
}, cToken);
|
||||
|
||||
// Update environment variable
|
||||
ToastieUtilities.AddPathToPATHEnvar(installationUri);
|
||||
Utilities.AddPathToPATHEnvar(dependenciesUri);
|
||||
|
||||
_isUpdating = false;
|
||||
return (currentVersion, newVersion);
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace EllieHub.Features.AppConfig.Services.Mocks;
|
|||
internal sealed class MockAppConfigManager : IAppConfigManager
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public ReadOnlyAppSettings AppConfig { get; } = new(new() { BotEntries = new() { [Guid.Empty] = new("MockBot", Path.Join(AppStatics.AppDefaultBotDirectoryUri, "MockBot"), 0) } });
|
||||
public ReadOnlyAppSettings AppConfig { get; } = new(new() { BotEntries = new() { [Guid.Empty] = new("MockBot", Path.Combine(AppStatics.AppDefaultBotDirectoryUri, "MockBot"), 0) } });
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ValueTask<BotEntry> CreateBotEntryAsync(CancellationToken cToken = default)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using Toastie.Utilities;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -14,7 +13,7 @@ public sealed class YtdlpResolver : IYtdlpResolver
|
|||
private const string _cachedCurrentVersionKey = "currentVersion:yt-dlp";
|
||||
private const string _ytdlpProcessName = "yt-dlp";
|
||||
private static readonly string _downloadedFileName = GetDownloadFileName();
|
||||
private bool _isUpdating;
|
||||
private bool _isUpdating = false;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
|
@ -57,16 +56,16 @@ public sealed class YtdlpResolver : IYtdlpResolver
|
|||
public async ValueTask<string?> GetCurrentVersionAsync(CancellationToken cToken = default)
|
||||
{
|
||||
// If yt-dlp is not accessible from the shell...
|
||||
if (!ToastieUtilities.ProgramExists(_ytdlpProcessName))
|
||||
if (!await Utilities.ProgramExistsAsync(_ytdlpProcessName, cToken))
|
||||
{
|
||||
// And doesn't exist in the dependencies folder,
|
||||
// report that yt-dlp is not installed.
|
||||
if (!File.Exists(Path.Join(AppStatics.AppDepsUri, FileName)))
|
||||
if (!File.Exists(Path.Combine(AppStatics.AppDepsUri, FileName)))
|
||||
return null;
|
||||
|
||||
// Else, add the dependencies directory to the PATH envar,
|
||||
// then try again.
|
||||
ToastieUtilities.AddPathToPATHEnvar(AppStatics.AppDepsUri);
|
||||
Utilities.AddPathToPATHEnvar(AppStatics.AppDepsUri);
|
||||
return await GetCurrentVersionAsync(cToken);
|
||||
}
|
||||
|
||||
|
@ -74,7 +73,7 @@ public sealed class YtdlpResolver : IYtdlpResolver
|
|||
if (_memoryCache.TryGetValue<string>(_cachedCurrentVersionKey, out var currentVersion) && currentVersion is not null)
|
||||
return currentVersion;
|
||||
|
||||
using var ytdlp = ToastieUtilities.StartProcess(_ytdlpProcessName, "--version", true);
|
||||
using var ytdlp = Utilities.StartProcess(_ytdlpProcessName, "--version");
|
||||
|
||||
var currentProcessVersion = (await ytdlp.StandardOutput.ReadToEndAsync(cToken)).Trim();
|
||||
_memoryCache.Set(_cachedCurrentVersionKey, currentProcessVersion, TimeSpan.FromMinutes(1.5));
|
||||
|
@ -96,7 +95,7 @@ public sealed class YtdlpResolver : IYtdlpResolver
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async ValueTask<(string? OldVersion, string? NewVersion)> InstallOrUpdateAsync(string installationUri, CancellationToken cToken = default)
|
||||
public async ValueTask<(string? OldVersion, string? NewVersion)> InstallOrUpdateAsync(string dependenciesUri, CancellationToken cToken = default)
|
||||
{
|
||||
if (_isUpdating)
|
||||
return (null, null);
|
||||
|
@ -117,7 +116,7 @@ public sealed class YtdlpResolver : IYtdlpResolver
|
|||
return (currentVersion, null);
|
||||
}
|
||||
|
||||
using var ytdlp = ToastieUtilities.StartProcess(_ytdlpProcessName, "-U");
|
||||
using var ytdlp = Utilities.StartProcess(_ytdlpProcessName, "-U");
|
||||
await ytdlp.WaitForExitAsync(cToken);
|
||||
|
||||
_isUpdating = false;
|
||||
|
@ -125,21 +124,21 @@ public sealed class YtdlpResolver : IYtdlpResolver
|
|||
}
|
||||
|
||||
// Install
|
||||
Directory.CreateDirectory(installationUri);
|
||||
Directory.CreateDirectory(dependenciesUri);
|
||||
|
||||
var finalFilePath = Path.Join(installationUri, FileName);
|
||||
var finalFilePath = Path.Combine(dependenciesUri, FileName);
|
||||
var http = _httpClientFactory.CreateClient();
|
||||
await using var downloadStream = await http.GetStreamAsync($"https://github.com/yt-dlp/yt-dlp/releases/download/{newVersion}/{_downloadedFileName}", cToken);
|
||||
await using (var fileStream = new FileStream(finalFilePath, FileMode.Create))
|
||||
using var downloadStream = await http.GetStreamAsync($"https://github.com/yt-dlp/yt-dlp/releases/download/{newVersion}/{_downloadedFileName}", cToken);
|
||||
using (var fileStream = new FileStream(finalFilePath, FileMode.Create))
|
||||
await downloadStream.CopyToAsync(fileStream, cToken);
|
||||
|
||||
// Update environment variable
|
||||
ToastieUtilities.AddPathToPATHEnvar(installationUri);
|
||||
Utilities.AddPathToPATHEnvar(dependenciesUri);
|
||||
|
||||
// On Linux and MacOS, we need to mark the file as executable.
|
||||
if (Environment.OSVersion.Platform is PlatformID.Unix)
|
||||
{
|
||||
using var chmod = ToastieUtilities.StartProcess("chmod", ["+x", finalFilePath]);
|
||||
using var chmod = Utilities.StartProcess("chmod", $"+x \"{finalFilePath}\"");
|
||||
await chmod.WaitForExitAsync(cToken);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ using EllieHub.Features.AppConfig.Views.Controls;
|
|||
using EllieHub.Features.AppConfig.Views.Windows;
|
||||
using EllieHub.Features.AppWindow.ViewModels;
|
||||
using EllieHub.Features.AppWindow.Views.Windows;
|
||||
using EllieHub.Features.Common.Services.Abstractions;
|
||||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.Services.Abstractions;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
using ReactiveUI;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:EllieHub.Features.AppConfig.ViewModels"
|
||||
xmlns:views="using:EllieHub.Features.Common.Views.Controls"
|
||||
xmlns:views="using:EllieHub.Features.Shared.Views.Controls"
|
||||
xmlns:const="using:EllieHub.Common"
|
||||
xmlns:dd="using:EllieHub.Avalonia.DesignData.Controls"
|
||||
mc:Ignorable="d"
|
||||
|
@ -23,6 +23,7 @@
|
|||
Fill="{DynamicResource HeavyBackground}" />
|
||||
|
||||
<Rectangle Grid.Row="1"
|
||||
Grid.RowSpan="2"
|
||||
Fill="{DynamicResource MediumBackground}"/>
|
||||
|
||||
<!--Settings Title-->
|
||||
|
@ -86,10 +87,9 @@
|
|||
|
||||
<!--Backup Directory Bar-->
|
||||
<TextBlock Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Margin="0 8 0 0"
|
||||
Text="Backup Directory:"
|
||||
ToolTip.Tip="Defines the directory the updater is going to store the backups of the bot instances."/>
|
||||
ToolTip.Tip="Defines the directory the updater is going to store the backup of the bot instances."/>
|
||||
|
||||
<TextBox Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
|
@ -113,7 +113,6 @@
|
|||
|
||||
<!--Logs directory Bar-->
|
||||
<TextBlock Grid.Row="4"
|
||||
Grid.Column="0"
|
||||
Margin="0 8 0 0"
|
||||
Text="Logs Directory:"
|
||||
ToolTip.Tip="Defines the directory the updater is going to store the logs of the bot instances."/>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:EllieHub.Features.AppConfig.ViewModels"
|
||||
xmlns:const="using:EllieHub.Common"
|
||||
xmlns:dd="using:EllieHub.Avalonia.DesignData.Windows"
|
||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="305"
|
||||
Width="400" Height="305"
|
||||
|
@ -22,7 +23,7 @@
|
|||
Margin="0 0 0 10"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button CommandParameter="https://paypal.me/toastiet0ast"
|
||||
<Button CommandParameter="https://www.paypal.com/paypalme/toastiet0ast"
|
||||
Command="{Binding OpenUrl}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Paypal " />
|
||||
|
@ -54,13 +55,11 @@
|
|||
<Separator Margin="20"
|
||||
HorizontalAlignment="Stretch" />
|
||||
|
||||
<TextBlock Text="This tool was made by Toastie. If it has been useful to you, consider showing your support."
|
||||
<TextBlock Text="This tool was made by Toastie. If it has been useful to you, consider showing your support on Ko-fi."
|
||||
TextAlignment="Center"
|
||||
Margin="0 0 0 10" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Margin="0 0 5 0"
|
||||
HorizontalAlignment="Center"
|
||||
<Button HorizontalAlignment="Center"
|
||||
CommandParameter="https://ko-fi.com/toastie_t0ast"
|
||||
Command="{Binding OpenUrl}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
@ -69,26 +68,21 @@
|
|||
Source="{DynamicResource UrlIcon}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Margin="5 0 0 0"
|
||||
HorizontalAlignment="Center"
|
||||
CommandParameter="https://toastielab.dev/EllieBotDevs/EllieHub/issues/new"
|
||||
Command="{Binding OpenUrl}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Report a bug " />
|
||||
<Image Classes="icon-url"
|
||||
Source="{DynamicResource UrlIcon}" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Text="© 2025 Toastie_t0ast"
|
||||
<TextBlock Text="© 2024 Toastie"
|
||||
FontSize="11"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0 30 0 0"/>
|
||||
<HyperlinkButton FontSize="11"
|
||||
HorizontalAlignment="Center"
|
||||
Content="GNU General Public License Version 3"
|
||||
CommandParameter="https://toastielab.dev/EllieBotDevs/EllieHub/src/branch/main/LICENSE"
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center">
|
||||
<TextBlock Text="License: "
|
||||
FontSize="11" />
|
||||
<Button Classes="link-11"
|
||||
FontSize="11"
|
||||
Content="Apache License Version 2"
|
||||
CommandParameter="https://toastielab.dev/ToastieSharp/EllieHub/src/branch/main/LICENSE"
|
||||
Command="{Binding OpenUrl}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
xmlns:siv="https://github.com/kekyo/SkiaImageView"
|
||||
xmlns:vm="using:EllieHub.Features.AppWindow.ViewModels"
|
||||
xmlns:dd="using:EllieHub.Avalonia.DesignData.Controls"
|
||||
xmlns:const="using:EllieHub.Common"
|
||||
mc:Ignorable="d" d:DesignWidth="70" d:DesignHeight="450"
|
||||
x:Class="EllieHub.Features.AppWindow.Views.Controls.LateralBarView"
|
||||
x:DataType="vm:LateralBarViewModel">
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace EllieHub.Features.AppWindow.Views.Controls;
|
|||
/// </summary>
|
||||
public partial class LateralBarView : ReactiveUserControl<LateralBarViewModel>
|
||||
{
|
||||
private static readonly Cursor _pointingHandCursor = new(StandardCursorType.Hand);
|
||||
private static readonly Cursor _arrow = new(StandardCursorType.Arrow);
|
||||
private readonly ReadOnlyAppSettings _appConfig;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Styling;
|
||||
using Toastie.DependencyInjection.Extensions;
|
||||
using Toastie.Utilities;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using EllieHub.Avalonia.DesignData.Common;
|
||||
using EllieHub.Enums;
|
||||
|
@ -17,7 +15,7 @@ using EllieHub.Features.BotConfig.ViewModels;
|
|||
using EllieHub.Features.Home.Services.Abstractions;
|
||||
using EllieHub.Features.Home.ViewModels;
|
||||
using EllieHub.Features.Home.Views.Windows;
|
||||
using EllieHub.Features.BotConfig.Services;
|
||||
using EllieHub.Services;
|
||||
using ReactiveUI;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Versioning;
|
||||
|
@ -119,13 +117,13 @@ public partial class AppView : ReactiveWindow<AppViewModel>
|
|||
{
|
||||
// Ensure that bots on Unix system have access to the dependencies.
|
||||
if (Environment.OSVersion.Platform is PlatformID.Unix)
|
||||
ToastieUtilities.AddPathToPATHEnvar(AppStatics.AppDepsUri);
|
||||
Utilities.AddPathToPATHEnvar(AppStatics.AppDepsUri);
|
||||
|
||||
// Set the window size from the last session
|
||||
base.Height = _appConfigManager.AppConfig.WindowSize.Height;
|
||||
base.Width = _appConfigManager.AppConfig.WindowSize.Width;
|
||||
|
||||
// Set the user preferred theme
|
||||
// Set the user prefered theme
|
||||
base.RequestedThemeVariant = _appConfigManager.AppConfig.Theme switch
|
||||
{
|
||||
ThemeType.Auto => ThemeVariant.Default,
|
||||
|
@ -159,22 +157,13 @@ public partial class AppView : ReactiveWindow<AppViewModel>
|
|||
|
||||
/// <inheritdoc/>
|
||||
protected override async void OnClosed(EventArgs eventArgs)
|
||||
{
|
||||
try
|
||||
{
|
||||
// When the updater is closed, kill all bots and write their logs.
|
||||
_botOrchestrator.StopAllBots();
|
||||
_botOrchestrator.StopAll();
|
||||
await _logWriter.FlushAllAsync(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
base.OnClosed(eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the size of this window to the application settings after the specified <paramref name="waitTime"/> elapses.
|
||||
|
@ -265,15 +254,8 @@ public partial class AppView : ReactiveWindow<AppViewModel>
|
|||
|
||||
_ = new UpdateView().ShowDialog(this);
|
||||
|
||||
try
|
||||
{
|
||||
await _appResolver.InstallOrUpdateAsync(AppContext.BaseDirectory);
|
||||
_appResolver.LaunchNewVersion();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
|
||||
base.Close();
|
||||
}
|
||||
|
@ -284,13 +266,13 @@ public partial class AppView : ReactiveWindow<AppViewModel>
|
|||
[SupportedOSPlatform("windows")]
|
||||
private async Task MigrateOldBotsAsync()
|
||||
{
|
||||
var configFileUri = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "EllieBotUpdater", "bots.json");
|
||||
var configFileUri = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "EllieBotUpdater", "bots.json");
|
||||
|
||||
if (File.Exists(AppStatics.AppConfigUri) || !File.Exists(configFileUri))
|
||||
return;
|
||||
|
||||
var bots = (JsonSerializer.Deserialize<OldUpdaterBotEntry[]>(await File.ReadAllTextAsync(configFileUri)) ?? [])
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x.PathUri) && File.Exists(Path.Join(x.PathUri, "EllieBot.exe")))
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x.PathUri) && File.Exists(Path.Combine(x.PathUri, "EllieBot.exe")))
|
||||
.Select((x, y) => new BotEntry(x.Guid, new(x.Name, x.PathUri!, (uint)y, x.Version, x.IconUri)));
|
||||
|
||||
foreach (var botEntry in bots)
|
||||
|
@ -311,7 +293,7 @@ public partial class AppView : ReactiveWindow<AppViewModel>
|
|||
private static BotConfigViewModel GetBotConfigViewModel(Button button, IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
using var scope = scopeFactory.CreateScope();
|
||||
var botId = button.Content ?? throw new InvalidOperationException("Bot button has no valid Id.");
|
||||
var botId = (button.Content ?? throw new InvalidOperationException("Bot button has no valid Id."));
|
||||
var botResolver = scope.ServiceProvider.GetParameterizedService<EllieResolver>(botId);
|
||||
|
||||
return scope.ServiceProvider.GetParameterizedService<BotConfigViewModel>(botResolver);
|
||||
|
|
|
@ -15,21 +15,14 @@ public sealed class BotExitEventArgs : EventArgs
|
|||
/// </summary>
|
||||
public int ExitCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The exit message.
|
||||
/// </summary>
|
||||
public string Message { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates the event arguments when a bot process exits.
|
||||
/// </summary>
|
||||
/// <param name="botId">The bot's Id.</param>
|
||||
/// <param name="exitCode">The exit code.</param>
|
||||
/// <param name="message">The message for the bot process that just exited.</param>
|
||||
public BotExitEventArgs(Guid botId, int exitCode, string message)
|
||||
public BotExitEventArgs(Guid botId, int exitCode)
|
||||
{
|
||||
Id = botId;
|
||||
ExitCode = exitCode;
|
||||
Message = message;
|
||||
}
|
||||
}
|
|
@ -34,18 +34,18 @@ public interface IBotOrchestrator
|
|||
/// </summary>
|
||||
/// <param name="botId">The bot's Id.</param>
|
||||
/// <returns><see langword="true"/> if the bot successfully started, <see langword="false"/> otherwise.</returns>
|
||||
bool StartBot(Guid botId);
|
||||
bool Start(Guid botId);
|
||||
|
||||
/// <summary>
|
||||
/// Stops the bot with the specified <paramref name="botId"/>.
|
||||
/// </summary>
|
||||
/// <param name="botId">The bot's Id.</param>
|
||||
/// <returns><see langword="true"/> if the bot successfully stopped, <see langword="false"/> otherwise.</returns>
|
||||
bool StopBot(Guid botId);
|
||||
bool Stop(Guid botId);
|
||||
|
||||
/// <summary>
|
||||
/// Stops all bot instances.
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if at least one bot instance was stopped, <see langword="false"/> otherwise.</returns>
|
||||
bool StopAllBots();
|
||||
bool StopAll();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using EllieHub.Features.Common.Services.Abstractions;
|
||||
using EllieHub.Features.Shared.Services.Abstractions;
|
||||
|
||||
namespace EllieHub.Features.BotConfig.Services.Abstractions;
|
||||
|
||||
|
|
|
@ -10,9 +10,8 @@ namespace EllieHub.Features.BotConfig.Services;
|
|||
/// </summary>
|
||||
public sealed class EllieOrchestrator : IBotOrchestrator
|
||||
{
|
||||
private readonly ReadOnlyAppSettings _appConfig;
|
||||
private readonly ILogWriter _logWriter;
|
||||
private readonly Dictionary<Guid, Process> _runningBots = new();
|
||||
private readonly ReadOnlyAppSettings _appConfig;
|
||||
private readonly string _fileName = OperatingSystem.IsWindows() ? "EllieBot.exe" : "EllieBot";
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -28,28 +27,24 @@ public sealed class EllieOrchestrator : IBotOrchestrator
|
|||
/// Creates an object that coordinates multiple running processes of EllieBot.
|
||||
/// </summary>
|
||||
/// <param name="appConfig">The application settings.</param>
|
||||
/// <param name="logWriter">The service that writes bot logs to disk.</param>
|
||||
public EllieOrchestrator(ReadOnlyAppSettings appConfig, ILogWriter logWriter)
|
||||
{
|
||||
_appConfig = appConfig;
|
||||
_logWriter = logWriter;
|
||||
}
|
||||
public EllieOrchestrator(ReadOnlyAppSettings appConfig)
|
||||
=> _appConfig = appConfig;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool IsBotRunning(Guid botId)
|
||||
=> _runningBots.ContainsKey(botId);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool StartBot(Guid botId)
|
||||
public bool Start(Guid botId)
|
||||
{
|
||||
if (_runningBots.ContainsKey(botId)
|
||||
|| !_appConfig.BotEntries.TryGetValue(botId, out var botEntry)
|
||||
|| !File.Exists(Path.Join(botEntry.InstanceDirectoryUri, _fileName)))
|
||||
|| !File.Exists(Path.Combine(botEntry.InstanceDirectoryUri, _fileName)))
|
||||
return false;
|
||||
|
||||
var botProcess = Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
FileName = Path.Join(botEntry.InstanceDirectoryUri, _fileName),
|
||||
FileName = Path.Combine(botEntry.InstanceDirectoryUri, _fileName),
|
||||
WorkingDirectory = botEntry.InstanceDirectoryUri,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
|
@ -71,7 +66,7 @@ public sealed class EllieOrchestrator : IBotOrchestrator
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool StopBot(Guid botId)
|
||||
public bool Stop(Guid botId)
|
||||
{
|
||||
if (!_runningBots.TryGetValue(botId, out var botProcess))
|
||||
return false;
|
||||
|
@ -81,11 +76,10 @@ public sealed class EllieOrchestrator : IBotOrchestrator
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool StopAllBots()
|
||||
public bool StopAll()
|
||||
{
|
||||
var amount = _runningBots.Count;
|
||||
|
||||
// ReSharper disable once EmptyGeneralCatchClause
|
||||
foreach (var process in _runningBots.Values)
|
||||
try { process.Kill(true); } catch { }
|
||||
|
||||
|
@ -101,12 +95,7 @@ public sealed class EllieOrchestrator : IBotOrchestrator
|
|||
private void OnExit(object? sender, EventArgs eventArgs)
|
||||
{
|
||||
var (id, process) = _runningBots.First(x => x.Value.Equals(sender));
|
||||
var message = Environment.NewLine
|
||||
+ $"{_appConfig.BotEntries[id].Name} stopped. Status code: {process.ExitCode}"
|
||||
+ Environment.NewLine;
|
||||
|
||||
_logWriter.TryAdd(id, message);
|
||||
OnBotExit?.Invoke(this, new(id, process.ExitCode, message));
|
||||
OnBotExit?.Invoke(this, new(id, process.ExitCode));
|
||||
|
||||
_runningBots.Remove(id);
|
||||
process.CancelOutputRead();
|
||||
|
@ -127,7 +116,6 @@ public sealed class EllieOrchestrator : IBotOrchestrator
|
|||
var (id, _) = _runningBots.First(x => x.Value.Equals(sender));
|
||||
var newEventArgs = new ProcessStdWriteEventArgs(id, eventArgs.Data);
|
||||
|
||||
_logWriter.TryAdd(id, eventArgs.Data);
|
||||
OnStdout?.Invoke(this, newEventArgs);
|
||||
}
|
||||
|
||||
|
@ -144,7 +132,6 @@ public sealed class EllieOrchestrator : IBotOrchestrator
|
|||
var (id, _) = _runningBots.First(x => x.Value.Equals(sender));
|
||||
var newEventArgs = new ProcessStdWriteEventArgs(id, eventArgs.Data);
|
||||
|
||||
_logWriter.TryAdd(id, eventArgs.Data);
|
||||
OnStderr?.Invoke(this, newEventArgs);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
using Toastie.Utilities;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
using EllieHub.Features.BotConfig.Models.Api.Toastielab;
|
||||
|
@ -11,20 +10,20 @@ using System.Runtime.InteropServices;
|
|||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace EllieHub.Features.BotConfig.Services;
|
||||
namespace EllieHub.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service that checks, downloads, installs, and updates a EllieBot instance.
|
||||
/// </summary>
|
||||
/// <remarks>Source: https://toastielab.dev/EllieBotDevs/elliebot/releases/latest</remarks>
|
||||
/// <remarks>Source: https://toastielab.dev/Emotions-stuff/elliebot/releases/latest</remarks>
|
||||
public sealed partial class EllieResolver : IBotResolver
|
||||
{
|
||||
private const string _cachedCurrentVersionKey = "currentVersion:EllieBot";
|
||||
private const string _toastielabReleasesEndpointUrl = "https://toastielab.dev/api/v1/repos/EllieBotDevs/elliebot/releases/latest";
|
||||
private const string _toastielabReleasesRepoUrl = "https://toastielab.dev/EllieBotDevs/elliebot/releases/latest";
|
||||
private const string _toastielabReleasesEndpointUrl = "https://toastielab.dev/api/v1/repos/Emotions-stuff/elliebot/releases/latest";
|
||||
private const string _toastielabReleasesRepoUrl = "https://toastielab.dev/Emotions-stuff/elliebot/releases/latest";
|
||||
private static readonly HashSet<Guid> _updateIdOngoing = [];
|
||||
private static readonly string _tempDirectory = Path.GetTempPath();
|
||||
private static readonly Regex _unzippedDirRegex = GenerateUnzipedDirRegex();
|
||||
private static readonly Regex _unzipedDirRegex = GenerateUnzipedDirRegex();
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private readonly IAppConfigManager _appConfigManager;
|
||||
|
@ -95,7 +94,7 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
var now = DateTimeOffset.Now;
|
||||
var date = new DateOnly(now.Year, now.Month, now.Day).ToShortDateString().Replace('/', '-');
|
||||
var backupZipName = $"{botInstance.Name}_v{botInstance.Version}_{date}-{now.ToUnixTimeMilliseconds()}.zip";
|
||||
var destinationUri = Path.Join(_appConfigManager.AppConfig.BotsBackupDirectoryUri, backupZipName);
|
||||
var destinationUri = Path.Combine(_appConfigManager.AppConfig.BotsBackupDirectoryUri, backupZipName);
|
||||
|
||||
// ZipFile does not provide asynchronous implementations, so we have to schedule its
|
||||
// execution to be run in the thread-pool due to how long it takes to finish execution.
|
||||
|
@ -108,7 +107,7 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
public async ValueTask<string?> GetCurrentVersionAsync(CancellationToken cToken = default)
|
||||
{
|
||||
var botEntry = _appConfigManager.AppConfig.BotEntries[Id];
|
||||
var executableUri = Path.Join(botEntry.InstanceDirectoryUri, FileName);
|
||||
var executableUri = Path.Combine(botEntry.InstanceDirectoryUri, FileName);
|
||||
|
||||
if (!File.Exists(executableUri))
|
||||
{
|
||||
|
@ -162,8 +161,8 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
|
||||
var http = _httpClientFactory.CreateClient();
|
||||
var downloadFileName = GetDownloadFileName(latestVersion);
|
||||
var botTempLocation = Path.Join(_tempDirectory, "elliebot-" + _unzippedDirRegex.Match(downloadFileName).Groups[1].Value);
|
||||
var zipTempLocation = Path.Join(_tempDirectory, downloadFileName);
|
||||
var botTempLocation = Path.Combine(_tempDirectory, "elliebot-" + _unzipedDirRegex.Match(downloadFileName).Groups[1].Value);
|
||||
var zipTempLocation = Path.Combine(_tempDirectory, downloadFileName);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -186,10 +185,10 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
await _appConfigManager.UpdateBotEntryAsync(Id, x => x with { Version = latestVersion }, cToken);
|
||||
|
||||
// Create creds.yml
|
||||
var credsUri = Path.Join(installationUri, "creds.yml");
|
||||
var credsUri = Path.Combine(installationUri, "creds.yml");
|
||||
|
||||
if (!File.Exists(credsUri))
|
||||
File.Copy(Path.Join(installationUri, "creds_example.yml"), credsUri);
|
||||
File.Copy(Path.Combine(installationUri, "creds_example.yml"), credsUri);
|
||||
|
||||
return (currentVersion, latestVersion);
|
||||
}
|
||||
|
@ -198,8 +197,8 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
_updateIdOngoing.Remove(Id);
|
||||
|
||||
// Cleanup
|
||||
ToastieUtilities.TryDeleteFile(zipTempLocation);
|
||||
ToastieUtilities.TryDeleteDirectory(botTempLocation);
|
||||
Utilities.TryDeleteFile(zipTempLocation);
|
||||
Utilities.TryDeleteDirectory(botTempLocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,10 +214,12 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
// Extract the tar ball
|
||||
await TarFile.ExtractToDirectoryAsync(downloadStream, _tempDirectory, true, cToken);
|
||||
|
||||
ToastieUtilities.TryMoveDirectory(botTempLocation, installationUri);
|
||||
// Move the bot root directory with "mv" to circumvent this issue on Unix systems: https://github.com/dotnet/runtime/issues/31149
|
||||
using var moveProcess = Utilities.StartProcess("mv", $"\"{botTempLocation}\" \"{installationUri}\"");
|
||||
await moveProcess.WaitForExitAsync(cToken);
|
||||
|
||||
// Set executable permission
|
||||
using var chmod = ToastieUtilities.StartProcess("chmod", ["+x", Path.Join(installationUri, FileName)]);
|
||||
using var chmod = Utilities.StartProcess("chmod", $"+x \"{Path.Combine(installationUri, FileName)}\"");
|
||||
await chmod.WaitForExitAsync(cToken);
|
||||
}
|
||||
|
||||
|
@ -230,10 +231,10 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
/// <param name="zipTempLocation">The absolute path to the zip file the bot is initially on.</param>
|
||||
/// <param name="botTempLocation">The absolute path to the temporary directory the bot is extracted to.</param>
|
||||
/// <param name="cToken">The cancellation token.</param>
|
||||
private static async ValueTask InstallToWindowsAsync(Stream downloadStream, string installationUri, string zipTempLocation, string botTempLocation, CancellationToken cToken = default)
|
||||
private async static ValueTask InstallToWindowsAsync(Stream downloadStream, string installationUri, string zipTempLocation, string botTempLocation, CancellationToken cToken = default)
|
||||
{
|
||||
// Save the zip file
|
||||
await using (var fileStream = new FileStream(zipTempLocation, FileMode.Create))
|
||||
using (var fileStream = new FileStream(zipTempLocation, FileMode.Create))
|
||||
await downloadStream.CopyToAsync(fileStream, cToken);
|
||||
|
||||
// Extract the zip file
|
||||
|
@ -249,7 +250,7 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
/// <param name="installationUri">The absolute path to the directory the bot got installed to.</param>
|
||||
/// <param name="backupFileUri">The absolute path to the backup zip file.</param>
|
||||
/// <param name="cToken">The cancellation token.</param>
|
||||
private static async ValueTask ReaplyBotSettingsAsync(string installationUri, string backupFileUri, CancellationToken cToken = default)
|
||||
private async static ValueTask ReaplyBotSettingsAsync(string installationUri, string backupFileUri, CancellationToken cToken = default)
|
||||
{
|
||||
using var zipFile = ZipFile.OpenRead(backupFileUri);
|
||||
var zippedFiles = zipFile.Entries
|
||||
|
@ -264,7 +265,7 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
.Prepend(Directory.GetParent(installationUri)?.FullName ?? string.Empty)
|
||||
.ToArray();
|
||||
|
||||
await RestoreFileAsync(zippedFile, Path.Join(fileDestinationPath), cToken);
|
||||
await RestoreFileAsync(zippedFile, Path.Combine(fileDestinationPath), cToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,10 +275,10 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
/// <param name="zippedFile">The file to be extracted.</param>
|
||||
/// <param name="destinationPath">The final location of the extracted file.</param>
|
||||
/// <param name="cToken">The cancellation token.</param>
|
||||
private static async ValueTask RestoreFileAsync(ZipArchiveEntry zippedFile, string destinationPath, CancellationToken cToken = default)
|
||||
private async static ValueTask RestoreFileAsync(ZipArchiveEntry zippedFile, string destinationPath, CancellationToken cToken = default)
|
||||
{
|
||||
await using var zipStream = zippedFile.Open();
|
||||
await using var fileStream = new FileStream(destinationPath, FileMode.Create);
|
||||
using var zipStream = zippedFile.Open();
|
||||
using var fileStream = new FileStream(destinationPath, FileMode.Create);
|
||||
|
||||
await zipStream.CopyToAsync(fileStream, cToken);
|
||||
}
|
||||
|
@ -326,7 +327,7 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return $"https://toastielab.dev/EllieBotDevs/elliebot/releases/download/{latestVersion}/{downloadFileName}";
|
||||
return $"https://toastielab.dev/Emotions-stuff/elliebot/releases/download/{latestVersion}/{downloadFileName}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,7 +414,7 @@ public sealed partial class EllieResolver : IBotResolver
|
|||
finally
|
||||
{
|
||||
if (isSingleFile)
|
||||
ToastieUtilities.TryDeleteDirectory(directoryUri);
|
||||
Utilities.TryDeleteDirectory(directoryUri);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using EllieHub.Features.AppConfig.Models;
|
||||
using EllieHub.Features.BotConfig.Models;
|
||||
using EllieHub.Features.BotConfig.Services.Abstractions;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
|
@ -12,7 +11,7 @@ namespace EllieHub.Features.BotConfig.Services;
|
|||
/// </summary>
|
||||
public sealed class LogWriter : ILogWriter
|
||||
{
|
||||
private readonly ConcurrentDictionary<Guid, StringBuilder> _botLogs = [];
|
||||
private readonly Dictionary<Guid, StringBuilder> _botLogs = new();
|
||||
private readonly ReadOnlyAppSettings _appConfig;
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -28,11 +27,7 @@ public sealed class LogWriter : ILogWriter
|
|||
/// <inheritdoc/>
|
||||
public async Task<bool> FlushAllAsync(bool removeFromMemory = false, CancellationToken cToken = default)
|
||||
{
|
||||
var result = await Task.WhenAll(_botLogs.Keys.Select(x => FlushAsync(x, false, cToken)));
|
||||
|
||||
if (removeFromMemory)
|
||||
_botLogs.Clear();
|
||||
|
||||
var result = await Task.WhenAll(_botLogs.Keys.Select(x => FlushAsync(x, removeFromMemory, cToken)));
|
||||
return result.Any(x => x);
|
||||
}
|
||||
|
||||
|
@ -43,7 +38,7 @@ public sealed class LogWriter : ILogWriter
|
|||
return false;
|
||||
|
||||
if (removeFromMemory)
|
||||
_botLogs.Remove(botId, out _);
|
||||
_botLogs.Remove(botId);
|
||||
|
||||
if (logStringBuilder.Length is 0)
|
||||
return false;
|
||||
|
@ -53,7 +48,7 @@ public sealed class LogWriter : ILogWriter
|
|||
var botEntry = _appConfig.BotEntries[botId];
|
||||
var now = DateTimeOffset.Now;
|
||||
var date = new DateOnly(now.Year, now.Month, now.Day).ToShortDateString().Replace('/', '-');
|
||||
var fileUri = Path.Join(_appConfig.LogsDirectoryUri, $"{botEntry.Name}_v{botEntry.Version}_{date}-{now.ToUnixTimeSeconds()}.txt");
|
||||
var fileUri = Path.Combine(_appConfig.LogsDirectoryUri, $"{botEntry.Name}_v{botEntry.Version}_{date}-{now.ToUnixTimeSeconds()}.txt");
|
||||
|
||||
await File.WriteAllTextAsync(fileUri, logStringBuilder.ToString(), cToken);
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
using Avalonia.Controls;
|
||||
using Toastie.Utilities;
|
||||
using MsBox.Avalonia.Enums;
|
||||
using EllieHub.Enums;
|
||||
using EllieHub.Features.Abstractions;
|
||||
using EllieHub.Features.AppConfig.Services.Abstractions;
|
||||
using EllieHub.Features.AppWindow.ViewModels;
|
||||
using EllieHub.Features.AppWindow.Views.Controls;
|
||||
using EllieHub.Features.AppWindow.Views.Windows;
|
||||
using EllieHub.Features.BotConfig.Models;
|
||||
using EllieHub.Features.BotConfig.Services.Abstractions;
|
||||
using EllieHub.Features.BotConfig.Views.Controls;
|
||||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
using ReactiveUI;
|
||||
using SkiaSharp;
|
||||
using System.Diagnostics;
|
||||
|
@ -103,7 +103,7 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
{
|
||||
var sanitizedValue = value.ReplaceLineEndings(string.Empty);
|
||||
|
||||
DirectoryHint = $"Select the absolute path to the bot directory. For example: {Path.Join(_appConfigManager.AppConfig.BotsDirectoryUri, sanitizedValue)}";
|
||||
DirectoryHint = $"Select the absolute path to the bot directory. For example: {Path.Combine(_appConfigManager.AppConfig.BotsDirectoryUri, sanitizedValue)}";
|
||||
this.RaiseAndSetIfChanged(ref _botName, sanitizedValue);
|
||||
}
|
||||
}
|
||||
|
@ -180,10 +180,10 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
if (IsBotRunning)
|
||||
EnableButtons(true, false);
|
||||
else
|
||||
EnableButtons(!File.Exists(Path.Join(botEntry.InstanceDirectoryUri, Resolver.FileName)), true);
|
||||
EnableButtons(!File.Exists(Path.Combine(botEntry.InstanceDirectoryUri, Resolver.FileName)), true);
|
||||
|
||||
// Dispose when the view is deactivated
|
||||
this.WhenActivated(disposables => Disposable.Create(Dispose).DisposeWith(disposables));
|
||||
this.WhenActivated(disposables => Disposable.Create(() => Dispose()).DisposeWith(disposables));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -216,12 +216,14 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
Directory.Delete(BotDirectoryUriBar.CurrentUri);
|
||||
}
|
||||
|
||||
if (!ToastieUtilities.TryMoveDirectory(oldUri, BotDirectoryUriBar.CurrentUri))
|
||||
throw new InvalidOperationException(
|
||||
$"Could not move \"{oldUri}\" to \"{BotDirectoryUriBar.CurrentUri}\"." +
|
||||
Environment.NewLine + Environment.NewLine +
|
||||
"Make sure you have permission to write to the target directory."
|
||||
);
|
||||
if (Environment.OSVersion.Platform is not PlatformID.Unix)
|
||||
Directory.Move(oldUri, BotDirectoryUriBar.CurrentUri);
|
||||
else
|
||||
{
|
||||
// Move the bot root directory with "mv" to circumvent this issue on Unix systems: https://github.com/dotnet/runtime/issues/31149
|
||||
using var moveProcess = Utilities.StartProcess("mv", $"\"{oldUri}\" \"{BotDirectoryUriBar.CurrentUri}\"");
|
||||
await moveProcess.WaitForExitAsync();
|
||||
}
|
||||
|
||||
BotDirectoryUriBar.RecheckCurrentUri();
|
||||
}
|
||||
|
@ -245,7 +247,7 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
{
|
||||
_ = LoadUpdateBarAsync(Resolver, UpdateBar);
|
||||
|
||||
if (!wereButtonsUnlocked && File.Exists(Path.Join(BotDirectoryUriBar.CurrentUri, Resolver.FileName)))
|
||||
if (!wereButtonsUnlocked && File.Exists(Path.Combine(BotDirectoryUriBar.CurrentUri, Resolver.FileName)))
|
||||
EnableButtons(false, true);
|
||||
else
|
||||
EnableButtons(!wereButtonsUnlocked, true);
|
||||
|
@ -341,7 +343,7 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
EnableButtons(true, false);
|
||||
|
||||
// Stop the bot instance
|
||||
_botOrchestrator.StopBot(Resolver.Id);
|
||||
_botOrchestrator.Stop(Resolver.Id);
|
||||
|
||||
// Cleanup
|
||||
FakeConsole.Content = string.Empty;
|
||||
|
@ -408,7 +410,7 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
/// </summary>
|
||||
public void StartBot()
|
||||
{
|
||||
IsBotRunning = _botOrchestrator.StartBot(Id);
|
||||
IsBotRunning = _botOrchestrator.Start(Id);
|
||||
|
||||
if (IsBotRunning)
|
||||
EnableButtons(true, false);
|
||||
|
@ -418,14 +420,14 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
/// Stops the bot instance associated with this view-model.
|
||||
/// </summary>
|
||||
public void StopBot()
|
||||
=> _botOrchestrator.StopBot(Id);
|
||||
=> _botOrchestrator.Stop(Id);
|
||||
|
||||
/// <summary>
|
||||
/// Loads the bot update bar.
|
||||
/// </summary>
|
||||
/// <param name="botResolver">The bot resolver.</param>
|
||||
/// <param name="updateBotBar">The update bar.</param>
|
||||
private static async Task LoadUpdateBarAsync(IBotResolver botResolver, DependencyButtonViewModel updateBotBar)
|
||||
private async static Task LoadUpdateBarAsync(IBotResolver botResolver, DependencyButtonViewModel updateBotBar)
|
||||
{
|
||||
updateBotBar.DependencyName = "Checking...";
|
||||
updateBotBar.Status = DependencyStatus.Checking;
|
||||
|
@ -466,6 +468,8 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
if (eventArgs.Id != Resolver.Id)
|
||||
return;
|
||||
|
||||
_logWriter.TryAdd(eventArgs.Id, eventArgs.Output);
|
||||
|
||||
FakeConsole.Content = FakeConsole.Content.Length > 100_000
|
||||
? FakeConsole.Content[FakeConsole.Content.IndexOf(Environment.NewLine, 60_000, StringComparison.Ordinal)..] + eventArgs.Output + Environment.NewLine
|
||||
: FakeConsole.Content + eventArgs.Output + Environment.NewLine;
|
||||
|
@ -481,11 +485,14 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
if (eventArgs.Id != Resolver.Id)
|
||||
return;
|
||||
|
||||
FakeConsole.Content += eventArgs.Message;
|
||||
var message = Environment.NewLine + ActualBotName + " stopped." + Environment.NewLine;
|
||||
|
||||
_logWriter.TryAdd(Resolver.Id, message);
|
||||
FakeConsole.Content += message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-enables the buttons when the bot instance associated with this view-model exits.
|
||||
/// Reenables the buttons when the bot instance associated with this view-model exits.
|
||||
/// </summary>
|
||||
/// <param name="botOrchestrator">The bot orchestrator.</param>
|
||||
/// <param name="eventArgs">The event arguments.</param>
|
||||
|
@ -501,13 +508,7 @@ public class BotConfigViewModel : ViewModelBase<BotConfigView>, IDisposable
|
|||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
UpdateBar.Click -= InstallOrUpdateAsync;
|
||||
_botOrchestrator.OnStdout -= WriteLog;
|
||||
_botOrchestrator.OnStderr -= WriteLog;
|
||||
_botOrchestrator.OnBotExit -= LogBotExit;
|
||||
_botOrchestrator.OnBotExit -= ReenableButtonsOnBotExit;
|
||||
|
||||
BotAvatar.Dispose();
|
||||
BotAvatar?.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using EllieHub.Features.Abstractions;
|
||||
using EllieHub.Features.BotConfig.Views.Controls;
|
||||
using EllieHub.Features.AppConfig.Views.Controls;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace EllieHub.Features.BotConfig.ViewModels;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
Fill="{DynamicResource HeavyBackground}"/>
|
||||
|
||||
<Rectangle Grid.Row="1"
|
||||
Grid.RowSpan="2"
|
||||
Grid.RowSpan="3"
|
||||
Fill="{DynamicResource MediumBackground}"/>
|
||||
|
||||
<!--Bot Settings Title-->
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
xmlns:vm="using:EllieHub.Features.BotConfig.ViewModels"
|
||||
xmlns:dd="using:EllieHub.Avalonia.DesignData.Controls"
|
||||
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="250"
|
||||
x:Class="EllieHub.Features.BotConfig.Views.Controls.FakeConsole"
|
||||
x:Class="EllieHub.Features.AppConfig.Views.Controls.FakeConsole"
|
||||
x:DataType="vm:FakeConsoleViewModel">
|
||||
<Design.DataContext>
|
||||
<dd:DesignFakeConsoleViewModel/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Avalonia.ReactiveUI;
|
||||
using EllieHub.Features.BotConfig.ViewModels;
|
||||
|
||||
namespace EllieHub.Features.BotConfig.Views.Controls;
|
||||
namespace EllieHub.Features.AppConfig.Views.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a control that mimics the appearance of a terminal emulator.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using EllieHub.Features.Common.Services.Abstractions;
|
||||
using EllieHub.Features.Shared.Services.Abstractions;
|
||||
|
||||
namespace EllieHub.Features.Home.Services.Abstractions;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using Toastie.Utilities;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using EllieHub.Features.Home.Models.Api.Toastielab;
|
||||
using EllieHub.Features.Home.Services.Abstractions;
|
||||
|
@ -14,8 +13,8 @@ namespace EllieHub.Features.Home.Services;
|
|||
public sealed class AppResolver : IAppResolver
|
||||
{
|
||||
private const string _cachedCurrentVersionKey = "currentVersion:EllieHub";
|
||||
private const string _toastielabReleasesEndpointUrl = "https://toastielab.dev/api/v1/repos/EllieBotDevs/EllieHub/releases/latest";
|
||||
private const string _toastielabReleasesRepoUrl = "https://toastielab.dev/EllieBotDevs/EllieHub/releases/latest";
|
||||
private const string _toastielabReleasesEndpointUrl = "https://toastielab.dev/api/v1/repos/Emotions-stuff/EllieHub/releases/latest";
|
||||
private const string _toastielabReleasesRepoUrl = "https://toastielab.dev/Emotions-stuff/EllieHub/releases/latest";
|
||||
private static readonly string _tempDirectory = Path.GetTempPath();
|
||||
private static readonly string _downloadedFileName = GetDownloadFileName();
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
|
@ -43,7 +42,7 @@ public sealed class AppResolver : IAppResolver
|
|||
_httpClientFactory = httpClientFactory;
|
||||
_memoryCache = memoryCache;
|
||||
FileName = OperatingSystem.IsWindows() ? "EllieHub.exe" : "EllieHub";
|
||||
BinaryUri = Path.Join(AppContext.BaseDirectory, FileName);
|
||||
BinaryUri = Path.Combine(AppContext.BaseDirectory, FileName);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -52,7 +51,7 @@ public sealed class AppResolver : IAppResolver
|
|||
|
||||
/// <inheritdoc/>
|
||||
public void LaunchNewVersion()
|
||||
=> ToastieUtilities.StartProcess(BinaryUri);
|
||||
=> Utilities.StartProcess(BinaryUri);
|
||||
|
||||
/// <returns>
|
||||
/// <see langword="true"/> if the updater can be updated,
|
||||
|
@ -62,7 +61,7 @@ public sealed class AppResolver : IAppResolver
|
|||
/// <inheritdoc/>
|
||||
public async ValueTask<bool?> CanUpdateAsync(CancellationToken cToken = default)
|
||||
{
|
||||
if (!ToastieUtilities.HasWritePermissionAt(AppContext.BaseDirectory))
|
||||
if (!Utilities.CanWriteTo(AppContext.BaseDirectory))
|
||||
return null;
|
||||
|
||||
var currentVersion = await GetCurrentVersionAsync(cToken);
|
||||
|
@ -89,7 +88,7 @@ public sealed class AppResolver : IAppResolver
|
|||
var result = false;
|
||||
|
||||
foreach (var file in Directory.GetFiles(AppContext.BaseDirectory).Where(x => x.EndsWith(OldFileSuffix, StringComparison.Ordinal)))
|
||||
result |= ToastieUtilities.TryDeleteFile(file);
|
||||
result |= Utilities.TryDeleteFile(file);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -117,18 +116,18 @@ public sealed class AppResolver : IAppResolver
|
|||
return (currentVersion, null);
|
||||
|
||||
var http = _httpClientFactory.CreateClient(); // Do not initialize a ToastielabClient here, it returns 302 with no data
|
||||
var appTempLocation = Path.Join(_tempDirectory, _downloadedFileName[.._downloadedFileName.LastIndexOf('.')]);
|
||||
var zipTempLocation = Path.Join(_tempDirectory, _downloadedFileName);
|
||||
var appTempLocation = Path.Combine(_tempDirectory, _downloadedFileName[.._downloadedFileName.LastIndexOf('.')]);
|
||||
var zipTempLocation = Path.Combine(_tempDirectory, _downloadedFileName);
|
||||
|
||||
try
|
||||
{
|
||||
await using var downloadStream = await http.GetStreamAsync(
|
||||
using var downloadStream = await http.GetStreamAsync(
|
||||
await GetDownloadUrlAsync(latestVersion, cToken),
|
||||
cToken
|
||||
);
|
||||
|
||||
// Save the zip file
|
||||
await using (var fileStream = new FileStream(zipTempLocation, FileMode.Create))
|
||||
using (var fileStream = new FileStream(zipTempLocation, FileMode.Create))
|
||||
await downloadStream.CopyToAsync(fileStream, cToken);
|
||||
|
||||
// Extract the zip file
|
||||
|
@ -139,30 +138,27 @@ public sealed class AppResolver : IAppResolver
|
|||
|
||||
foreach (var newFileUri in newFilesUris)
|
||||
{
|
||||
var destinationUri = Path.Join(AppContext.BaseDirectory, newFileUri[(newFileUri.LastIndexOf(Path.DirectorySeparatorChar) + 1)..]);
|
||||
var destinationUri = Path.Combine(AppContext.BaseDirectory, newFileUri[(newFileUri.LastIndexOf(Path.DirectorySeparatorChar) + 1)..]);
|
||||
|
||||
// Rename the original file from "file" to "file_old".
|
||||
if (File.Exists(destinationUri))
|
||||
File.Move(destinationUri, destinationUri + OldFileSuffix, true); // This executes fine
|
||||
File.Move(destinationUri, destinationUri + OldFileSuffix, true);
|
||||
|
||||
// Move the new file to the application's directory.
|
||||
// ...
|
||||
// This is a workaround for a really weird bug with Unix applications published as single-file.
|
||||
// The moving operation works, but invoking any process from the shell results in:
|
||||
// FileNotFoundException: Could not load file or assembly 'System.IO.Pipes, Version=9.0.0.0 [...]
|
||||
if (Environment.OSVersion.Platform is not PlatformID.Unix)
|
||||
File.Move(newFileUri, destinationUri, true);
|
||||
else
|
||||
{
|
||||
using var moveProcess = ToastieUtilities.StartProcess("mv", [newFileUri, destinationUri]);
|
||||
// Circumvent this issue on Unix systems: https://github.com/dotnet/runtime/issues/31149
|
||||
using var moveProcess = Utilities.StartProcess("mv", $"\"{newFileUri}\" \"{destinationUri}\"");
|
||||
await moveProcess.WaitForExitAsync(cToken);
|
||||
}
|
||||
}
|
||||
|
||||
// Mark the new binary file as executable.c
|
||||
// Mark the new binary file as executable.
|
||||
if (Environment.OSVersion.Platform is PlatformID.Unix)
|
||||
{
|
||||
using var chmod = ToastieUtilities.StartProcess("chmod", ["+x", BinaryUri]);
|
||||
using var chmod = Utilities.StartProcess("chmod", $"+x \"{BinaryUri}\"");
|
||||
await chmod.WaitForExitAsync(cToken);
|
||||
}
|
||||
|
||||
|
@ -171,8 +167,8 @@ public sealed class AppResolver : IAppResolver
|
|||
finally
|
||||
{
|
||||
// Cleanup
|
||||
ToastieUtilities.TryDeleteFile(zipTempLocation);
|
||||
ToastieUtilities.TryDeleteDirectory(appTempLocation);
|
||||
Utilities.TryDeleteFile(zipTempLocation);
|
||||
Utilities.TryDeleteDirectory(appTempLocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +213,7 @@ public sealed class AppResolver : IAppResolver
|
|||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return $"https://toastielab.dev/EllieBotDevs/EllieHub/releases/download/{latestVersion}/{_downloadedFileName}";
|
||||
return $"https://toastielab.dev/Emotions-stuff/EllieHub/releases/download/{latestVersion}/{_downloadedFileName}";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,15 +28,15 @@
|
|||
Grid.ColumnSpan="5"
|
||||
Fill="{DynamicResource HeavyBackground}"/>
|
||||
|
||||
<Rectangle Grid.Row="4"
|
||||
<Rectangle Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
Fill="#008DDA"/>
|
||||
|
||||
<Rectangle Grid.Row="4"
|
||||
<Rectangle Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Fill="#F86752"/>
|
||||
|
||||
<Rectangle Grid.Row="4"
|
||||
<Rectangle Grid.Row="5"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="3"
|
||||
Fill="#0e3f88"/>
|
||||
|
@ -78,7 +78,7 @@
|
|||
Classes="transparent"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
CommandParameter="https://app.feedbacky.net/b/ellie-feedback"
|
||||
CommandParameter="https://beta.elliebot.net/"
|
||||
Command="{Binding OpenUrl}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Classes="icon"
|
||||
|
@ -147,7 +147,7 @@
|
|||
VerticalAlignment="Top"/>
|
||||
|
||||
<!--Bottom Buttons-->
|
||||
<Button Grid.Row="4"
|
||||
<Button Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
Classes="transparent"
|
||||
Content="Buy me a Ko-fi"
|
||||
|
@ -158,7 +158,7 @@
|
|||
CommandParameter="https://ko-fi.com/toastie_t0ast"
|
||||
Command="{Binding OpenUrl}"/>
|
||||
|
||||
<Image Grid.Row="4"
|
||||
<Image Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
Classes="icon"
|
||||
MaxHeight="30"
|
||||
|
@ -167,7 +167,7 @@
|
|||
Margin="0 0 3 0"
|
||||
Source="{DynamicResource KofiIcon}"/>
|
||||
|
||||
<Button Grid.Row="4"
|
||||
<Button Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Classes="transparent"
|
||||
Content="Support EllieBot"
|
||||
|
@ -178,7 +178,7 @@
|
|||
CommandParameter="https://patreon.com/toastiet0ast"
|
||||
Command="{Binding OpenUrl}"/>
|
||||
|
||||
<Image Grid.Row="4"
|
||||
<Image Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Classes="icon"
|
||||
MaxHeight="30"
|
||||
|
@ -187,7 +187,7 @@
|
|||
Margin="0 0 3 0"
|
||||
Source="{DynamicResource PatreonIcon}"/>
|
||||
|
||||
<TextBlock Grid.Row="4"
|
||||
<TextBlock Grid.Row="5"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="3"
|
||||
Text="Thank You ♡"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
namespace EllieHub.Features.Common.Models;
|
||||
namespace EllieHub.Features.Shared.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the event arguments for when a valid uri is set to a <see cref="UriInputBarViewModel"/>.
|
|
@ -1,4 +1,4 @@
|
|||
namespace EllieHub.Features.Common.Services.Abstractions;
|
||||
namespace EllieHub.Features.Shared.Services.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a service that checks, downloads, installs, and updates a dependency.
|
|
@ -2,11 +2,11 @@ using Avalonia.Media.Immutable;
|
|||
using EllieHub.Enums;
|
||||
using EllieHub.Features.Abstractions;
|
||||
using EllieHub.Features.AppWindow.Views.Windows;
|
||||
using EllieHub.Features.Common.Views.Controls;
|
||||
using EllieHub.Features.Shared.Views.Controls;
|
||||
using ReactiveUI;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace EllieHub.Features.Common.ViewModels;
|
||||
namespace EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the view-model for a button that installs a dependency for Ellie.
|
|
@ -1,12 +1,11 @@
|
|||
using Avalonia.Platform.Storage;
|
||||
using Toastie.Utilities;
|
||||
using EllieHub.Features.Abstractions;
|
||||
using EllieHub.Features.Common.Models;
|
||||
using EllieHub.Features.Common.Views.Controls;
|
||||
using EllieHub.Features.Shared.Models;
|
||||
using EllieHub.Features.Shared.Views.Controls;
|
||||
using ReactiveUI;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace EllieHub.Features.Common.ViewModels;
|
||||
namespace EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a text box for inputting the absolute path of a directory.
|
||||
|
@ -15,7 +14,7 @@ public class UriInputBarViewModel : ViewModelBase<UriInputBar>
|
|||
{
|
||||
private static readonly FolderPickerOpenOptions _folderPickerOptions = new();
|
||||
private string _lastValidUri = AppStatics.AppDefaultConfigDirectoryUri;
|
||||
private bool _isDirectoryValid;
|
||||
private bool _isDirectoryValid = false;
|
||||
private string _currentUri = string.Empty;
|
||||
private readonly IStorageProvider _storageProvider;
|
||||
|
||||
|
@ -93,5 +92,5 @@ public class UriInputBarViewModel : ViewModelBase<UriInputBar>
|
|||
/// <param name="directoryUri">The absolute path to a directory.</param>
|
||||
/// <returns><see langword="true"/> if the directory is valid, <see langword="false"/> otherwise.</returns>
|
||||
private bool IsValidDirectory(string directoryUri)
|
||||
=> Directory.Exists(directoryUri) && ToastieUtilities.HasWritePermissionAt(directoryUri);
|
||||
=> Directory.Exists(directoryUri) && Utilities.CanWriteTo(directoryUri);
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:EllieHub.Features.Common.ViewModels"
|
||||
xmlns:vm="using:EllieHub.Features.Shared.ViewModels"
|
||||
xmlns:dd="using:EllieHub.Avalonia.DesignData.Controls"
|
||||
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="50"
|
||||
x:Class="EllieHub.Features.Common.Views.Controls.DependencyButton"
|
||||
x:Class="EllieHub.Features.Shared.Views.Controls.DependencyButton"
|
||||
x:DataType="vm:DependencyButtonViewModel">
|
||||
|
||||
<Design.DataContext>
|
|
@ -1,7 +1,7 @@
|
|||
using Avalonia.ReactiveUI;
|
||||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
namespace EllieHub.Features.Common.Views.Controls;
|
||||
namespace EllieHub.Features.Shared.Views.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a button that installs a dependency for Ellie.
|
|
@ -2,10 +2,10 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:EllieHub.Features.Common.ViewModels"
|
||||
xmlns:vm="using:EllieHub.Features.Shared.ViewModels"
|
||||
xmlns:dd="using:EllieHub.Avalonia.DesignData.Controls"
|
||||
mc:Ignorable="d" d:DesignWidth="700" d:DesignHeight="33"
|
||||
x:Class="EllieHub.Features.Common.Views.Controls.UriInputBar"
|
||||
x:Class="EllieHub.Features.Shared.Views.Controls.UriInputBar"
|
||||
x:DataType="vm:UriInputBarViewModel">
|
||||
|
||||
<Design.DataContext>
|
|
@ -1,7 +1,7 @@
|
|||
using Avalonia.ReactiveUI;
|
||||
using EllieHub.Features.Common.ViewModels;
|
||||
using EllieHub.Features.Shared.ViewModels;
|
||||
|
||||
namespace EllieHub.Features.Common.Views.Controls;
|
||||
namespace EllieHub.Features.Shared.Views.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a text box that receives the absolute path to a directory.
|
|
@ -21,7 +21,7 @@ public sealed class ViewLocator : IDataTemplate
|
|||
{
|
||||
return (data is ViewModelBase viewModel && viewModel.GetType().BaseType?.GenericTypeArguments[0] is Type controlType)
|
||||
? (Application.Current as App)?.Services.GetService(controlType) as Control
|
||||
?? new TextBlock { Text = $"View-model of type \"{data.GetType().FullName ?? "null"}\" is not registered in the IoC container.", TextWrapping = TextWrapping.WrapWithOverflow }
|
||||
?? new TextBlock { Text = $"View-model of type \"{data?.GetType().FullName ?? "null"}\" is not registered in the IoC container.", TextWrapping = TextWrapping.WrapWithOverflow }
|
||||
: new TextBlock { Text = $"Component of type \"{data?.GetType().FullName ?? "null"}\" is not a valid view-model.", TextWrapping = TextWrapping.WrapWithOverflow };
|
||||
}
|
||||
}
|
15
Jenkinsfile
vendored
15
Jenkinsfile
vendored
|
@ -1,15 +0,0 @@
|
|||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage('Setup Dependencies') {
|
||||
steps {
|
||||
sh 'dotnet restore'
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh 'dotnet build -c Release'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
747
LICENSE
747
LICENSE
|
@ -1,674 +1,73 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||
|
||||
Copyright 2023 ToastieSharp
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="toastielab.dev" value="https://toastielab.dev/api/packages/toastie_t0ast/nuget/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
</configuration>
|
44
README.md
44
README.md
|
@ -1,46 +1,2 @@
|
|||
# EllieHub
|
||||
|
||||
EllieHub is a cross-platform user-friendly desktop application designed for management of [EllieBot][EllieWebsite] Discord bot instances.
|
||||
|
||||
Download it [here][EllieHubReleases].
|
||||
For more information about this project, please visit the [wiki][ToastielabWiki].
|
||||
|
||||
## Features
|
||||
|
||||
- Install, update, and remove Ellie bots.
|
||||
- Install and update dependencies used by Ellie to play music.
|
||||
- Easy access to the settings of each Ellie bot.
|
||||
- Start and stop your bots directly from the Hub.
|
||||
- Create backups of your bots whenever you want.
|
||||
- Watch logs of your bots in real time and have them saved automatically for later inspection.
|
||||
- Works on Windows, Linux, and macOS.
|
||||
|
||||
## Screenshots
|
||||
|
||||
#### Screenshots are coming soon!
|
||||
|
||||
## License
|
||||
|
||||
EllieHub, a desktop application for managing instances of the EllieBot Discord bot.
|
||||
|
||||
Copyright (C) 2025 Toastie_t0ast & EllieBotDevs
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
[EllieWebsite]: https://elliebot.net/
|
||||
[HomeView]: ./.forgejo/readme_assets/elliehub_home.png
|
||||
[ConfigView]: ./.forgejo/readme_assets/elliehub_config.png
|
||||
[BotConfigeView]: ./.forgejo/readme_assets/elliehub_botconfig.png
|
||||
[ToastielabWiki]: https://toastielab.dev/EllieBotDevs/EllieHub/wiki
|
||||
[EllieHubReleases]: https://toastielab.dev/EllieBotDevs/EllieHub/releases/latest
|
Loading…
Reference in a new issue