libxbku_common/
xbku_enums.rs

1/*
2    libxbku-common
3    Copyright (C) 2021 AluminiumTech
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU Lesser General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16 */
17
18pub enum XbkuError {
19    HardwareNotSupported,
20    OperatingSystemNotSupported,
21    InvalidSourceList,
22    InvalidSource,
23    InvalidNetworkConnection,
24    InvalidNetworkConfiguration,
25    InvalidArguments,
26    NoError
27}
28
29pub enum XbkuCommand {
30    Help,
31    CheckForXbkuUpdates,
32    CheckForKernelUpdates,
33    CheckForKernelUpdatesAndNotifyCurrentUser,
34    ListOfAvailableMainlineKernels,
35    ListOfInstalledKernels,
36    InstallLatestMainlineKernel,
37    InstallLatestKernelUpdateForPointSeries,
38    InstallSpecificMainlineKernel,
39    RemoveSpecifiedKernel,
40    PurgeOlderDownloads,
41    DownloadPackageForSpecifiedKernel,
42    CleanApplicationCache,
43    Undefined,
44    InvalidCommand
45}
46
47
48impl XbkuCommand {
49    pub fn convert_string_to_enum(input: &str) -> XbkuCommand {
50        return match input{
51            "-h" | "--help" | "--h" => XbkuCommand::Help,
52            "--check-app-updates" | "--check-updates" | "--check-xbku-updates" | "--update-xbku" => XbkuCommand::CheckForXbkuUpdates,
53            "--check-kernel-update" | "--check-kernel" | "--kernel-check" | "-kc" | "--kc" => XbkuCommand::CheckForKernelUpdates,
54            "--check-kernel-updates-notify-current-user" | "--kernel-check-notify" | "--check-kernel-notify" => XbkuCommand::CheckForKernelUpdatesAndNotifyCurrentUser,
55            "--clean-application-cache" | "--clean-app-cache" | "--clean-cache" | "--clear-app-cache" | "--clear-cache" => XbkuCommand::CleanApplicationCache,
56            "--download-package" | "--download" | "--download-specific" => XbkuCommand::DownloadPackageForSpecifiedKernel,
57            "--install-latest-mainline" | "--install-latest-kernel" | "--install-latest" => XbkuCommand::InstallLatestMainlineKernel,
58            "--install-latest-point-update" | "--install-point-update" => XbkuCommand::InstallLatestKernelUpdateForPointSeries,
59            "--install-specific-kernel" | "--install-specific" => XbkuCommand::InstallSpecificMainlineKernel,
60            "--list-available-kernels" | "--list-available" | "--list-available-mainline" | "--list-mainline" => XbkuCommand::ListOfAvailableMainlineKernels,
61            "--list-installed-kernels" => XbkuCommand::ListOfInstalledKernels,
62            "--purge-old-kernels" | "--purge-legacy-kernels" | "--purge-older-kernels" | "--purge-downloads" => XbkuCommand::PurgeOlderDownloads,
63            "--remove" | "--remove-kernel" | "--purge-kernel" => XbkuCommand::RemoveSpecifiedKernel,
64            _=> XbkuCommand::Undefined
65        }
66    }
67}
68
69pub enum XbkuKernelVariants {
70    LowLatency,
71    Generic,
72    GenericLPAE,
73    Snapdragon,
74    Custom,
75    Undefined,
76    InvalidKernelVariant
77}
78
79
80impl XbkuKernelVariants{
81    pub fn convert_string_to_enum(input: &str) -> XbkuKernelVariants {
82
83        /*
84        if input.to_string().to_lowercase().contains("low") ||
85            input.to_string().to_lowercase().contains("latency") ||
86            input.to_string().to_lowercase().contains("low") && input.to_string().to_lowercase().contains("latency")
87        {
88            let input: &str = "lowlatency";
89        }
90        else if input.to_string().to_lowercase().contains("generic") && input.to_string().to_lowercase().contains("lpae"){
91            let input: &str = "lpae";
92        }
93        else if input.to_string().to_lowercase().contains("generic") && !input.to_string().to_lowercase().contains("lpae"){
94            let input: &str = "generic";
95        }
96        */
97
98        return match input {
99            "generic" => XbkuKernelVariants::Generic,
100            "lowlatency" => XbkuKernelVariants::LowLatency,
101            "lpae" => XbkuKernelVariants::GenericLPAE,
102            "qualcomm" | "snapdragon" => XbkuKernelVariants::Snapdragon,
103            _=> XbkuKernelVariants::Undefined
104        }
105    }
106}