diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 57cba84..c4800a7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -21,7 +21,6 @@ jobs: config: - name: "Build on x64" os: ubuntu-latest - artifact: "Linux-x64" env: CC: gcc CXX: g++ @@ -61,11 +60,10 @@ jobs: - name: "CMake Install" working-directory: ${{github.workspace}}/build run: cmake --install . --prefix "${{github.workspace}}/install" - - name: "CMake Test" - working-directory: ${{github.workspace}}/build + - name: "Test" run: ${{github.workspace}}/build/libaura_test - name: Upload uses: actions/upload-artifact@v3 with: path: ${{github.workspace}}/install - name: ${{matrix.config.artifact}}-${{env.BUILD_TYPE}} + name: Linux-x64-${{env.BUILD_TYPE}} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a7f0389..b9b2614 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -21,7 +21,6 @@ jobs: config: - name: "Build on x64" os: windows-latest - artifact: "Windows-x64" fail-fast: false steps: - name: "Checkout" @@ -43,11 +42,10 @@ jobs: - name: "CMake Install" working-directory: ${{github.workspace}}/build run: cmake --install . --prefix "${{github.workspace}}/install" - - name: "CMake Test" - working-directory: ${{github.workspace}}/build/Release + - name: "Test" run: ${{github.workspace}}/build/Release/libaura_test.exe - name: Upload uses: actions/upload-artifact@v3 with: path: ${{github.workspace}}/install - name: ${{matrix.config.artifact}}-${{env.BUILD_TYPE}} + name: Windows-x64-${{env.BUILD_TYPE}} diff --git a/README.md b/README.md index 43acb4c..75efd15 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,7 @@ Documentation for this library and its modules can be found [here](/docs). ## Installation with Conan -1. Download the `conanrecipe.py` file from the `conan` folder in the root directory of the repo. -1. Rename `conanrecipe.py` to `conanfile.py` and move it to a new folder called `libaura`. -1. From this new `libaura` folder, run `conan create . --build=missing`. -1. Once this is completed, you can reference `libaura/2024.1.0` in your project's conanfile. +TODO ## Manual Building and Installation libaura uses Conan package manager for resolving dependencies and CMake as it's build system. @@ -53,4 +50,4 @@ Visual Studio 2022 with C++ Desktop workload is required to be installed. 1. To install libaura to the system, from the `build` folder, run `cmake --install . --prefix "PATH_TO_INSTALL_DIR"`. - Replace `PATH_TO_INSTALL_DIR` with the path to a folder to install libaura to. This is usually a dependencies folder set up by the programmer, added to the PATH variable, to allow linking to said dependencies. - On linux, `PATH_TO_INSTALL_DIR` would usually be `/usr`. -1. If contributing to upstream, remove `conanfile-windows.txt` and `conanprofile-windows.txt` from the repo's root directory as to not accidentally add and commit them. +1. If contributing to upstream, remove `conanfile-windows.txt` and `conanprofile-windows.txt` from the repo's root directory as to not accidentally add and commit them. \ No newline at end of file diff --git a/conan/conanrecipe.py b/conan/conanrecipe.py deleted file mode 100644 index 0a6120e..0000000 --- a/conan/conanrecipe.py +++ /dev/null @@ -1,81 +0,0 @@ -import os - -from conan import ConanFile -from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps -from conan.tools.scm import Git -from conan.tools.build import check_min_cppstd - -class libauraRecipe(ConanFile): - name = "libaura" - version = "2024.1.0" - package_type = "library" - - # Optional metadata - license = "GPLv3" - author = "Nicholas Logozzo nlogozzo225@gmai.com" - url = "https://github.com/NickvisionApps/libaura" - description = "A cross-platform base for native Nickvision applications." - topics = ("framework", "desktop", "gtk", "winui") - - # Binary configuration - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - - def validate(self): - check_min_cppstd(self, "20") - - def requirements(self): - self.test_requires("gtest/1.14.0") - self.requires("boost/1.83.0") - self.requires("jsoncpp/1.9.5") - self.requires("libcurl/8.4.0") - self.requires("libgettext/0.22") - self.requires("maddy/1.3.0") - self.requires("sqlcipher/4.5.1") - if self.settings.os == "Linux": - self.requires("glib/2.78.1") - self.requires("libsecret/0.20.5") - self.requires("libuuid/1.0.3") - - def source(self): - git = Git(self) - git.clone(url="https://github.com/NickvisionApps/libaura.git", target=".") - git.checkout("2024.1.0") - - def config_options(self): - if self.settings.os == "Windows": - self.options.rm_safe("fPIC") - else: - self.settings.os.libc = "glibc" - self.settings.os.libc.version = "2.35" - - def configure(self): - if self.options.shared: - self.options.rm_safe("fPIC") - - def layout(self): - cmake_layout(self) - - def generate(self): - deps = CMakeDeps(self) - deps.generate() - tc = CMakeToolchain(self) - tc.generate() - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - #if not self.conf.get("tools.build:skip_test", default=False): - #test_folder = os.path.join("") - #if self.settings.os == "Windows": - #test_folder = os.path.join("", str(self.settings.build_type)) - #self.run(os.path.join(test_folder, "libaura_test")) - - def package(self): - cmake = CMake(self) - cmake.install() - - def package_info(self): - self.cpp_info.libs = ["libaura"] \ No newline at end of file diff --git a/docs/aura.md b/docs/aura.md index 13a2db1..0d3bad3 100644 --- a/docs/aura.md +++ b/docs/aura.md @@ -517,6 +517,22 @@ Path: `Nickvision::Aura::Version` - Constructs a Version. - Accepts: The version as a string to parse, version. - Note: version must be in the format of `"major.minor.build-dev"`. +- ```cpp + int getMajor() const + ``` + - Returns: The major number of the version. +- ```cpp + int getMinor() const + ``` + - Returns: The minor number of the version. +- ```cpp + int getBuild() const + ``` + - Returns: The build number of the version. +- ```cpp + const std::string& getDev() const + ``` + - Returns: The dev string of the version. - ```cpp const std::string& toString() const ``` diff --git a/docs/helpers.md b/docs/helpers.md index 30b70b2..d3e081c 100644 --- a/docs/helpers.md +++ b/docs/helpers.md @@ -45,6 +45,7 @@ Path: `Nickvision::Aura::StringHelpers` ``` - Accepts: A string parameter, s, and a string delimiter, delimiter. - Returns: A list of the splits of s on delimiter and casted to type T. + - Note: T requires the `StringImplicitlyConstructible` concept defined as: `std::is_constructible_v && std::is_convertible_v`. - Ex: `StringHelpers::split("1,2,3,4", ",")` will return `std::vector{ "1", "2", "3", "4" }`. - Ex: `StringHelpers::split("1,2,3,4", ",")` will return `std::vector{ 1, 2, 3, 4 }`. - ```cpp diff --git a/include/aura.h b/include/aura.h index 8727255..911b283 100644 --- a/include/aura.h +++ b/include/aura.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "appinfo.h" #include "configurationbase.h" diff --git a/include/helpers/stringhelpers.h b/include/helpers/stringhelpers.h index 0815a43..ef3bf5d 100644 --- a/include/helpers/stringhelpers.h +++ b/include/helpers/stringhelpers.h @@ -4,10 +4,14 @@ #define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING #include +#include #include namespace Nickvision::Aura::StringHelpers { + template + concept StringImplicitlyConstructible = std::is_constructible_v && std::is_convertible_v; + /** * @brief Gets a fully lowercase string from the provided string. * @param s The string to get lowercase @@ -35,19 +39,19 @@ namespace Nickvision::Aura::StringHelpers std::string trim(const std::string& s, char delimiter) noexcept; /** * @brief Splits a string based on a delimiter. - * @tparam T The type of the resulting splits + * @tparam T The type of the resulting splits (must be a type that can be implicitly converted to string) * @param s The string to split * @param delimiter The delimiter to split the string on * @return The splits of the string */ - template + template std::vector split(std::string s, const std::string& delimiter) noexcept { std::vector splits; - size_t pos; + size_t pos{ 0 }; while ((pos = s.find(delimiter)) != std::string::npos) { - std::string split = s.substr(0, pos); + std::string split{ s.substr(0, pos) }; splits.push_back(split); s.erase(0, pos + 1); } diff --git a/include/keyring/store.h b/include/keyring/store.h index ca71f5c..b912b78 100644 --- a/include/keyring/store.h +++ b/include/keyring/store.h @@ -1,6 +1,8 @@ #ifndef STORE_H #define STORE_H +#define SQLITE_HAS_CODEC 1 + #include #include #include diff --git a/include/notifications/notifyicon.h b/include/notifications/notifyicon.h index c435c50..c504e56 100644 --- a/include/notifications/notifyicon.h +++ b/include/notifications/notifyicon.h @@ -12,6 +12,7 @@ #include #include "notifyiconmenu.h" #include "shellnotificationsenteventargs.h" +#pragma comment(lib,"shell32.lib") namespace Nickvision::Aura::Notifications { diff --git a/include/taskbar/taskbaritem.h b/include/taskbar/taskbaritem.h index 9b5e29e..b9fab8e 100644 --- a/include/taskbar/taskbaritem.h +++ b/include/taskbar/taskbaritem.h @@ -10,6 +10,7 @@ #include #include #include +#pragma comment(lib,"shell32.lib") #pragma comment(lib,"gdiplus.lib") #elif defined(__linux__) #include diff --git a/include/version.h b/include/version.h index 5bf493e..04e2650 100644 --- a/include/version.h +++ b/include/version.h @@ -39,6 +39,26 @@ namespace Nickvision::Aura * @throw std::invalid_argument Thrown when the version string is not formatted correctly */ Version(const std::string& version); + /** + * @brief Gets the major number of the version. + * @return The major number + */ + int getMajor() const noexcept; + /** + * @brief Gets the minor number of the version. + * @return The minor number + */ + int getMinor() const noexcept; + /** + * @brief Gets the build number of the version. + * @return The build number + */ + int getBuild() const noexcept; + /** + * @brief Gets the dev string of the version. + * @return The dev string + */ + const std::string& getDev() const noexcept; /** * @brief Gets the type of the version. * @return VersionType diff --git a/src/aura.cpp b/src/aura.cpp index 828d249..f7b63f7 100644 --- a/src/aura.cpp +++ b/src/aura.cpp @@ -53,7 +53,7 @@ namespace Nickvision::Aura std::string Aura::getEnvVar(const std::string& key) noexcept { - char* var = std::getenv(key.c_str()); + char* var{ std::getenv(key.c_str()) }; if (var) { return { var }; @@ -83,7 +83,7 @@ namespace Nickvision::Aura #endif if (locations.contains(dependency)) { - const std::filesystem::path& location = locations[dependency]; + const std::filesystem::path& location{ locations[dependency] }; if (std::filesystem::exists(location)) { return location; diff --git a/src/helpers/webhelpers.cpp b/src/helpers/webhelpers.cpp index 245a41e..5240518 100644 --- a/src/helpers/webhelpers.cpp +++ b/src/helpers/webhelpers.cpp @@ -54,7 +54,7 @@ namespace Nickvision::Aura stream->write(ptr, size * nmemb); return size * nmemb; }); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&out); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &out); #ifdef _WIN32 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); @@ -100,7 +100,7 @@ namespace Nickvision::Aura stream->write(ptr, size * nmemb); return size * nmemb; }); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&out); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &out); #ifdef _WIN32 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); diff --git a/src/keyring/passwordstrength.cpp b/src/keyring/passwordstrength.cpp index 75db030..a96c650 100644 --- a/src/keyring/passwordstrength.cpp +++ b/src/keyring/passwordstrength.cpp @@ -12,7 +12,7 @@ namespace Nickvision::Aura::Keyring { return PasswordStrength::VeryWeak; } - int strength = 0; + int strength{ 0 }; bool containsDigit = false; bool containsLower = false; bool containsUpper = false; diff --git a/src/keyring/store.cpp b/src/keyring/store.cpp index 6958b8e..3aae5f2 100644 --- a/src/keyring/store.cpp +++ b/src/keyring/store.cpp @@ -40,15 +40,17 @@ namespace Nickvision::Aura::Keyring } else { - throw std::runtime_error("Unable to exec create table command. Key may be invalid. " + std::string(err ? err : "")); + std::string error{ err ? err : "" }; sqlite3_free(err); + sqlite3_close(database); + throw std::runtime_error("Unable to exec create table command. Key may be invalid. " + error); } } else { + sqlite3_close(database); throw std::runtime_error("Unable to key the database."); } - sqlite3_close(database); } else { diff --git a/src/keyring/systemcredentials.cpp b/src/keyring/systemcredentials.cpp index e4d817d..b27d5f3 100644 --- a/src/keyring/systemcredentials.cpp +++ b/src/keyring/systemcredentials.cpp @@ -4,6 +4,7 @@ #ifdef _WIN32 #include #include +#pragma comment(lib,"advapi32.lib") #elif defined(__linux__) #include #endif @@ -32,7 +33,7 @@ namespace Nickvision::Aura::Keyring } #elif defined(__linux__) GError* error{ nullptr }; - char* password = secret_password_lookup_sync(&KEYRING_SCHEMA, nullptr, &error, "application", name.c_str(), NULL); + char* password{ secret_password_lookup_sync(&KEYRING_SCHEMA, nullptr, &error, "application", name.c_str(), NULL) }; if (!error && password) { Credential c{ name, "", "default", password }; @@ -107,7 +108,7 @@ namespace Nickvision::Aura::Keyring } #elif defined(__linux__) GError* error{ nullptr }; - char* password = secret_password_lookup_sync(&KEYRING_SCHEMA, nullptr, &error, "application", credential.getName().c_str(), NULL); + char* password{ secret_password_lookup_sync(&KEYRING_SCHEMA, nullptr, &error, "application", credential.getName().c_str(), NULL) }; if (!error && password) { secret_password_free(password); @@ -133,7 +134,7 @@ namespace Nickvision::Aura::Keyring return CredDeleteA(name.c_str(), CRED_TYPE_GENERIC, 0); #elif defined(__linux__) GError* error{ nullptr }; - bool res = secret_password_clear_sync(&KEYRING_SCHEMA, nullptr, &error, "application", name.c_str(), NULL); + bool res{ secret_password_clear_sync(&KEYRING_SCHEMA, nullptr, &error, "application", name.c_str(), NULL) }; if (!error) { return res; @@ -142,7 +143,7 @@ namespace Nickvision::Aura::Keyring { g_error_free(error); } -#endif return false; +#endif } } \ No newline at end of file diff --git a/src/update/updater.cpp b/src/update/updater.cpp index 1e85ea8..333dc5f 100644 --- a/src/update/updater.cpp +++ b/src/update/updater.cpp @@ -28,7 +28,7 @@ namespace Nickvision::Aura::Update } try { - std::vector fields = StringHelpers::split(githubRepoUrl, "/"); + std::vector fields{ StringHelpers::split(githubRepoUrl, "/") }; m_repoOwner = fields[3]; m_repoName = fields[4]; } @@ -56,7 +56,7 @@ namespace Nickvision::Aura::Update { return false; } - std::string release = WebHelpers::fetchJsonString("https://api.github.com/repos/" + m_repoOwner + "/" + m_repoName + "/releases/" + std::to_string(versionType == VersionType::Stable ? m_latestStableReleaseId : m_latestPreviewReleaseId)); + std::string release{ WebHelpers::fetchJsonString("https://api.github.com/repos/" + m_repoOwner + "/" + m_repoName + "/releases/" + std::to_string(versionType == VersionType::Stable ? m_latestStableReleaseId : m_latestPreviewReleaseId)) }; if (!release.empty()) { Json::Value root; @@ -90,7 +90,7 @@ namespace Nickvision::Aura::Update Version Updater::fetchCurrentVersion(VersionType versionType) noexcept { std::lock_guard lock{ m_mutex }; - std::string releases = WebHelpers::fetchJsonString("https://api.github.com/repos/" + m_repoOwner + "/" + m_repoName + "/releases"); + std::string releases{ WebHelpers::fetchJsonString("https://api.github.com/repos/" + m_repoOwner + "/" + m_repoName + "/releases") }; if (!releases.empty()) { Json::Value root; diff --git a/src/userdirectories.cpp b/src/userdirectories.cpp index 0823864..5d896e0 100644 --- a/src/userdirectories.cpp +++ b/src/userdirectories.cpp @@ -53,7 +53,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_Profile, 0, nullptr, &p) == S_OK) { result = p; @@ -70,7 +70,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &p) == S_OK) { result = p; @@ -95,7 +95,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &p) == S_OK) { result = p; @@ -131,7 +131,7 @@ namespace Nickvision::Aura std::filesystem::path UserDirectories::getApplicationLocalData() noexcept { - std::filesystem::path result = getLocalData() / Aura::getActive().getAppInfo().getName(); + std::filesystem::path result{ getLocalData() / Aura::getActive().getAppInfo().getName() }; std::filesystem::create_directories(result); return result; } @@ -150,7 +150,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_Desktop, 0, nullptr, &p) == S_OK) { result = p; @@ -168,7 +168,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_Documents, 0, nullptr, &p) == S_OK) { result = p; @@ -186,7 +186,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_Downloads, 0, nullptr, &p) == S_OK) { result = p; @@ -204,7 +204,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_Music, 0, nullptr, &p) == S_OK) { result = p; @@ -222,7 +222,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_Pictures, 0, nullptr, &p) == S_OK) { result = p; @@ -249,7 +249,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_Templates, 0, nullptr, &p) == S_OK) { result = p; @@ -267,7 +267,7 @@ namespace Nickvision::Aura { std::filesystem::path result; #ifdef _WIN32 - wchar_t* p = nullptr; + wchar_t* p{ nullptr }; if (SHGetKnownFolderPath(FOLDERID_Videos, 0, nullptr, &p) == S_OK) { result = p; diff --git a/src/version.cpp b/src/version.cpp index 4dac7a8..6599d15 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -40,13 +40,13 @@ namespace Nickvision::Aura m_minor{ 0 }, m_build{ 0 } { - std::string s = version; - size_t pos; - int i = 0; + std::string s{ version }; + size_t pos{ 0 }; + int i{ 0 }; while ((pos = s.find('.')) != std::string::npos) { - std::string token = s.substr(0, pos); - if (i == 0) + std::string token{ s.substr(0, pos) }; + if (i == 0) { m_major = std::stoi(token); } @@ -65,7 +65,7 @@ namespace Nickvision::Aura { throw std::invalid_argument("Ill-formated version string."); } - size_t dashIndex = s.find('-'); + size_t dashIndex{ s.find('-') }; m_build = std::stoi(s.substr(0, dashIndex)); s.erase(0, dashIndex); if (!s.empty() && s[0] == '-') //dev version @@ -75,6 +75,26 @@ namespace Nickvision::Aura m_str = std::to_string(m_major) + "." + std::to_string(m_minor) + "." + std::to_string(m_build) + m_dev; } + int Version::getMajor() const noexcept + { + return m_major; + } + + int Version::getMinor() const noexcept + { + return m_minor; + } + + int Version::getBuild() const noexcept + { + return m_build; + } + + const std::string& Version::getDev() const noexcept + { + return m_dev; + } + VersionType Version::getVersionType() const noexcept { return m_dev.empty() ? VersionType::Stable : VersionType::Preview;