Skip to content

Commit

Permalink
Cleanup (#13)
Browse files Browse the repository at this point in the history
* Conan --> Vcpkg

* Keyring - Cleanup

* All - Cleanup

* Update GitHub Actions for Vcpkg

* GitHub Actions Fix Triplets

* vcpkg --> conan

* Delete CMakePresets.json
  • Loading branch information
nlogozzo authored Jan 4, 2024
1 parent 46b1d9d commit fd452b3
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 129 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
config:
- name: "Build on x64"
os: ubuntu-latest
artifact: "Linux-x64"
env:
CC: gcc
CXX: g++
Expand Down Expand Up @@ -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}}
6 changes: 2 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
config:
- name: "Build on x64"
os: windows-latest
artifact: "Windows-x64"
fail-fast: false
steps:
- name: "Checkout"
Expand All @@ -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}}
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
81 changes: 0 additions & 81 deletions conan/conanrecipe.py

This file was deleted.

16 changes: 16 additions & 0 deletions docs/aura.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
1 change: 1 addition & 0 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, std::string> && std::is_convertible_v<std::string, T>`.
- Ex: `StringHelpers::split<std::string>("1,2,3,4", ",")` will return `std::vector<std::string>{ "1", "2", "3", "4" }`.
- Ex: `StringHelpers::split<int>("1,2,3,4", ",")` will return `std::vector<int>{ 1, 2, 3, 4 }`.
- ```cpp
Expand Down
1 change: 1 addition & 0 deletions include/aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <memory>
#include <stdexcept>
#include <string>
#include <type_traits>
#include "appinfo.h"
#include "configurationbase.h"

Expand Down
12 changes: 8 additions & 4 deletions include/helpers/stringhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING

#include <string>
#include <type_traits>
#include <vector>

namespace Nickvision::Aura::StringHelpers
{
template<typename T>
concept StringImplicitlyConstructible = std::is_constructible_v<T, std::string> && std::is_convertible_v<std::string, T>;

/**
* @brief Gets a fully lowercase string from the provided string.
* @param s The string to get lowercase
Expand Down Expand Up @@ -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<typename T = std::string>
template<StringImplicitlyConstructible T = std::string>
std::vector<T> split(std::string s, const std::string& delimiter) noexcept
{
std::vector<T> 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);
}
Expand Down
2 changes: 2 additions & 0 deletions include/keyring/store.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef STORE_H
#define STORE_H

#define SQLITE_HAS_CODEC 1

#include <filesystem>
#include <memory>
#include <mutex>
Expand Down
1 change: 1 addition & 0 deletions include/notifications/notifyicon.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <shellapi.h>
#include "notifyiconmenu.h"
#include "shellnotificationsenteventargs.h"
#pragma comment(lib,"shell32.lib")

namespace Nickvision::Aura::Notifications
{
Expand Down
1 change: 1 addition & 0 deletions include/taskbar/taskbaritem.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <atlbase.h>
#include <gdiplus.h>
#include <shlobj_core.h>
#pragma comment(lib,"shell32.lib")
#pragma comment(lib,"gdiplus.lib")
#elif defined(__linux__)
#include <glib.h>
Expand Down
20 changes: 20 additions & 0 deletions include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/aura.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/webhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/keyring/passwordstrength.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/keyring/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
9 changes: 5 additions & 4 deletions src/keyring/systemcredentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifdef _WIN32
#include <windows.h>
#include <wincred.h>
#pragma comment(lib,"advapi32.lib")
#elif defined(__linux__)
#include <libsecret/secret.h>
#endif
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -142,7 +143,7 @@ namespace Nickvision::Aura::Keyring
{
g_error_free(error);
}
#endif
return false;
#endif
}
}
Loading

0 comments on commit fd452b3

Please sign in to comment.