Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
- Remove "enumflags.h"
- Add sqlcipher as a dependency for Windows...no longer need to build it manually...only on Linux
  • Loading branch information
nlogozzo committed Jun 11, 2024
1 parent 3df9f46 commit 9291568
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
- name: "Setup Environment"
run: mkdir build
- name: "Vcpkg"
uses: johnwason/vcpkg-action@v5
uses: johnwason/vcpkg-action@v6
id: vcpkg
with:
pkgs: curl gettext-libintl gtest jsoncpp maddy openssl
pkgs: curl gettext-libintl gtest jsoncpp maddy sqlcipher
triplet: x64-windows
revision: b27651341123a59f7187b42ef2bc476284afb310
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 2024.6.3 (next)
### Breaking Changes
- Removed `enumflags.h`
- Added `sqlcipher` as a dependency for Windows build
- `sqlcipher` will continue to be built manually on Linux until the `vcpkg` port is fixed for Linux
#### App
- Removed `Nickvision::App::Aura::getEnvVar()`
- Removed `Nickvision::App::Aura::setEnvVar()`
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,26 @@ endif()
find_package(CURL REQUIRED)
find_package(jsoncpp CONFIG REQUIRED)
find_package(Intl REQUIRED)
find_package(OpenSSL REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC CURL::libcurl JsonCpp::JsonCpp Intl::Intl OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(${PROJECT_NAME} PUBLIC CURL::libcurl JsonCpp::JsonCpp Intl::Intl)
if(USING_VCPKG)
find_package(unofficial-maddy CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC unofficial::maddy::maddy)
endif()
if(WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC Advapi32 Dwmapi Gdiplus Kernel32 Shell32 UxTheme)
find_package(sqlcipher CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC sqlcipher::sqlcipher Advapi32 Dwmapi Gdiplus Kernel32 Shell32 UxTheme)
elseif(LINUX)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(glib REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(gio REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(gmodule REQUIRED IMPORTED_TARGET gmodule-2.0)
pkg_check_modules(gobject REQUIRED IMPORTED_TARGET gobject-2.0)
pkg_check_modules(gthread REQUIRED IMPORTED_TARGET gthread-2.0)
pkg_check_modules(libsecret REQUIRED IMPORTED_TARGET libsecret-1)
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads PkgConfig::glib PkgConfig::gio PkgConfig::gmodule PkgConfig::gobject PkgConfig::gthread PkgConfig::libsecret)
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads OpenSSL::SSL OpenSSL::Crypto PkgConfig::glib PkgConfig::gio PkgConfig::gmodule PkgConfig::gobject PkgConfig::gthread PkgConfig::libsecret)
if(USING_VCPKG)
find_package(unofficial-libuuid CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC unofficial::UUID::uuid)
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ The following are a list of dependencies used by libnick.
- libcurl
- libintl
- maddy
- openssl
- Used for sqlcipher, as libnick manually includes and compiles sqlcipher.

### Windows Only
The above dependencies must be installed, plus the following for Windows systems:
- sqlcipher

### Linux Only
The above dependencies must be installed, plus the following for linux systems:
The above dependencies must be installed, plus the following for Linux systems:
- glib
- libsecret
- libuuid
- openssl
- Used for sqlcipher, as libnick manually includes and compiles sqlcipher on Linux as the vcpkg version is broken.

## Consuming libnick via vcpkg
libnick is available through `vcpkg`.
Expand All @@ -52,7 +56,7 @@ A C++20 compiler is also required to build libnick.
1. Set the `VCPKG_ROOT` environment variable to the path of your vcpkg installation's root directory.
#### Windows
1. Set the `VCPKG_DEFAULT_TRIPLET` environment variable to `x64-windows`
1. Run `vcpkg install curl gettext-libintl gtest jsoncpp maddy openssl`
1. Run `vcpkg install curl gettext-libintl gtest jsoncpp maddy sqlcipher`
#### Linux
1. Set the `VCPKG_DEFAULT_TRIPLET` environment variable to `x64-linux`
1. Run `vcpkg install curl gettext-libintl glib gtest jsoncpp libsecret libuuid maddy openssl`
Expand Down
16 changes: 0 additions & 16 deletions docs/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,6 @@ int main()
config.save(); //lambda will be invoked on success
}
```

## EnumFlags
Description: Macros for working with enums to be used as flags.

Interface: [enumflags.h](/include/enumflags.h)

Type: `file`

### Macros
- ```cpp
#define DEFINE_ENUM_FLAG_OPERATORS(T)
```
- Accepts: The type name of an `enum class` to be used as flags, T.
- Defines: Operators `~`, `|`, `&`, `^`, `|=`, `&=`, `^=` for T.
- Note: T must be of type `enum class`.
- Note: T's values must be separate by bits, i.e. values must be 1, 2, 4, 8, 16, and so on.

## InterProcessCommunicator
Description: An inter process communicator (server/client).
Expand Down
16 changes: 9 additions & 7 deletions docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,27 @@ Path: `Nickvision::Events::Event`
```
- Moves an Event object.
- ```cpp
void subscribe(const std::function<void(const T&)>& handler)
HandlerId subscribe(const std::function<void(const T&)>& handler)
```
- Accepts: A `std::function` with signature `void handler(const T&)` to register as a callback for the event, handler.
- Returns: The id of the newly subscribed handler.
- ```cpp
void unsubscribe(const std::function<void(const T&)>& handler)
void unsubscribe(HandlerId id)
```
- Accepts: A `std::function` with signature `void handler(const T&)` to remove as a callback for the event, handler.
- Accepts: The id of a subscribed handler, id
- ```cpp
void invoke(const T& param) const
```
- Accepts: A `T` object to pass as a parameter, param, as all registered callbacks are called on this event.
- ```cpp
void operator+=(const std::function<void(const T&)>& handler)
HandlerId operator+=(const std::function<void(const T&)>& handler)
```
- Accepts: A `std::function` with signature `void handler(const T&)` to register as a callback for the event, handler.
- Accepts: A `std::function` with signature `void handler(const T&)` to register as a callback for the event, handler.
- Returns: The id of the newly subscribed handler.
- ```cpp
void operator-=(const std::function<void(const T&)>& handler)
void operator-=(HandlerId id)
```
- Accepts: A `std::function` with signature `void handler(const T&)` to remove as a callback for the event, handler.
- Accepts: The id of a subscribed handler, id
- ```cpp
void operator()(const T& param)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Description: Flags to describe properties of a file system object that can chang

Interface: [watcherflags.h](/include/filesystem/watcherflags.h)

Type: `enum class` with `DEFINE_ENUM_FLAG_OPERATORS`
Type: `enum class`

Path: `Nickvision::Filesystem::WatcherFlags`

Expand Down
4 changes: 2 additions & 2 deletions docs/keyring.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Description: Flags to describe the status of a validated credential.

Interface: [credentialcheckstatus.h](/include/keyring/credentialcheckstatus.h)

Type: `enum class` with `DEFINE_ENUM_FLAG_OPERATORS`
Type: `enum class`

Path: `Nickvision::Keyring::CredentialCheckStatus`

Expand Down Expand Up @@ -255,7 +255,7 @@ Description: Flags to describe the content of a password.
Interface: [passwordcontent.h](/include/keyring/passwordcontent.h)
Type: `enum class` with `DEFINE_ENUM_FLAG_OPERATORS`
Type: `enum class`
Path: `Nickvision::Keyring::PasswordContent`
Expand Down
4 changes: 4 additions & 0 deletions include/database/sqlcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#include <string>
#include <vector>
#ifdef _WIN32
#include <sqlcipher/sqlite3.h>
#elif defined(__linux__)
#include "sqlite3.h"
#endif
#include "sqlvalue.h"

namespace Nickvision::Database
Expand Down
6 changes: 5 additions & 1 deletion include/database/sqldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
#include <mutex>
#include <string>
#include <unordered_map>
#include "sqlcontext.h"
#ifdef _WIN32
#include <sqlcipher/sqlite3.h>
#elif defined(__linux__)
#include "sqlite3.h"
#endif
#include "sqlcontext.h"
#include "sqlstatement.h"

namespace Nickvision::Database
Expand Down
4 changes: 4 additions & 0 deletions include/database/sqlite3.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef __linux__

/*
** 2001-09-15
**
Expand Down Expand Up @@ -12894,3 +12896,5 @@ struct fts5_api {
#endif /* _FTS5_H */

/******** End of fts5.h *********/

#endif //__linux__
4 changes: 4 additions & 0 deletions include/database/sqlstatement.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#include <memory>
#include <string>
#include <utility>
#ifdef _WIN32
#include <sqlcipher/sqlite3.h>
#elif defined(__linux__)
#include "sqlite3.h"
#endif

namespace Nickvision::Database
{
Expand Down
4 changes: 4 additions & 0 deletions include/database/sqlvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

#include <string>
#include <utility>
#ifdef _WIN32
#include <sqlcipher/sqlite3.h>
#elif defined(__linux__)
#include "sqlite3.h"
#endif

namespace Nickvision::Database
{
Expand Down
37 changes: 0 additions & 37 deletions include/enumflags.h

This file was deleted.

37 changes: 34 additions & 3 deletions include/filesystem/watcherflags.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef WATCHERFLAGS_H
#define WATCHERFLAGS_H

#include "enumflags.h"

namespace Nickvision::Filesystem
{
/**
Expand All @@ -18,7 +16,40 @@ namespace Nickvision::Filesystem
LastAccess = 32
};

DEFINE_ENUM_FLAG_OPERATORS(WatcherFlags);
inline WatcherFlags operator~(WatcherFlags a)
{
return static_cast<WatcherFlags>(~static_cast<int>(a));
}

inline WatcherFlags operator|(WatcherFlags a, WatcherFlags b)
{
return static_cast<WatcherFlags>(static_cast<int>(a) | static_cast<int>(b));
}

inline WatcherFlags operator&(WatcherFlags a, WatcherFlags b)
{
return static_cast<WatcherFlags>(static_cast<int>(a) & static_cast<int>(b));
}

inline WatcherFlags operator^(WatcherFlags a, WatcherFlags b)
{
return static_cast<WatcherFlags>(static_cast<int>(a) ^ static_cast<int>(b));
}

inline WatcherFlags& operator|=(WatcherFlags& a, WatcherFlags b)
{
return reinterpret_cast<WatcherFlags&>(reinterpret_cast<int&>(a) |= static_cast<int>(b));
}

inline WatcherFlags& operator&=(WatcherFlags& a, WatcherFlags b)
{
return reinterpret_cast<WatcherFlags&>(reinterpret_cast<int&>(a) &= static_cast<int>(b));
}

inline WatcherFlags& operator^=(WatcherFlags& a, WatcherFlags b)
{
return reinterpret_cast<WatcherFlags&>(reinterpret_cast<int&>(a) ^= static_cast<int>(b));
}
}

#endif
37 changes: 34 additions & 3 deletions include/keyring/credentialcheckstatus.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef CREDENTIALCHECKSTATUS_H
#define CREDENTIALCHECKSTATUS_H

#include "enumflags.h"

namespace Nickvision::Keyring
{
/**
Expand All @@ -16,7 +14,40 @@ namespace Nickvision::Keyring
InvalidUri = 8
};

DEFINE_ENUM_FLAG_OPERATORS(CredentialCheckStatus);
inline CredentialCheckStatus operator~(CredentialCheckStatus a)
{
return static_cast<CredentialCheckStatus>(~static_cast<int>(a));
}

inline CredentialCheckStatus operator|(CredentialCheckStatus a, CredentialCheckStatus b)
{
return static_cast<CredentialCheckStatus>(static_cast<int>(a) | static_cast<int>(b));
}

inline CredentialCheckStatus operator&(CredentialCheckStatus a, CredentialCheckStatus b)
{
return static_cast<CredentialCheckStatus>(static_cast<int>(a) & static_cast<int>(b));
}

inline CredentialCheckStatus operator^(CredentialCheckStatus a, CredentialCheckStatus b)
{
return static_cast<CredentialCheckStatus>(static_cast<int>(a) ^ static_cast<int>(b));
}

inline CredentialCheckStatus& operator|=(CredentialCheckStatus& a, CredentialCheckStatus b)
{
return reinterpret_cast<CredentialCheckStatus&>(reinterpret_cast<int&>(a) |= static_cast<int>(b));
}

inline CredentialCheckStatus& operator&=(CredentialCheckStatus& a, CredentialCheckStatus b)
{
return reinterpret_cast<CredentialCheckStatus&>(reinterpret_cast<int&>(a) &= static_cast<int>(b));
}

inline CredentialCheckStatus& operator^=(CredentialCheckStatus& a, CredentialCheckStatus b)
{
return reinterpret_cast<CredentialCheckStatus&>(reinterpret_cast<int&>(a) ^= static_cast<int>(b));
}
}

#endif //CREDENTIALCHECKSTATUS_H
Loading

0 comments on commit 9291568

Please sign in to comment.