Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 9fdce90
Author: Nick Logozzo <[email protected]>
Date:   Mon Dec 11 13:49:32 2023 -0500

    Update store.cpp

commit c9ec266
Author: Nick Logozzo <[email protected]>
Date:   Mon Dec 11 13:42:58 2023 -0500

    Update store.cpp

commit 21eab5d
Author: Nick Logozzo <[email protected]>
Date:   Mon Dec 11 13:13:43 2023 -0500

    Update store.cpp

commit cdce6b0
Author: Nick Logozzo <[email protected]>
Date:   Mon Dec 11 13:06:42 2023 -0500

    Update store.cpp

commit a250658
Author: Nick Logozzo <[email protected]>
Date:   Mon Dec 11 12:49:46 2023 -0500

    Update store.cpp

commit c41e28d
Author: Nick Logozzo <[email protected]>
Date:   Mon Dec 11 12:42:10 2023 -0500

    Keyring - Cleanup

commit d50301c
Author: Nick Logozzo <[email protected]>
Date:   Mon Dec 11 12:37:30 2023 -0500

    Update CMakeLists.txt
  • Loading branch information
nlogozzo committed Dec 11, 2023
1 parent 0db9e17 commit f884ff2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ add_library (${PROJECT_NAME}
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION})
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()

#libaura Packages
find_package(Intl REQUIRED)
Expand Down
5 changes: 0 additions & 5 deletions include/keyring/store.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ namespace Nickvision::Aura::Keyring
std::filesystem::path m_path;

public:
/**
* @brief Gets the directory where stores are saved on disk.
* @return The directory for stores
*/
static std::filesystem::path getStoreDir();
/**
* @brief Gets whether or not a store exists with the provided name.
* @param name The name of the store to check
Expand Down
4 changes: 2 additions & 2 deletions src/keyring/keyring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Nickvision::Aura::Keyring
{
if (m_store.destroy())
{
(void)SystemCredentials::deleteCredential(m_store.getName()); //keyring's password may not be in system credentials
SystemCredentials::deleteCredential(m_store.getName()); //keyring's password may not be in system credentials
return true;
}
return false;
Expand Down Expand Up @@ -95,7 +95,7 @@ namespace Nickvision::Aura::Keyring
{
if (Store::destroy(name))
{
(void)SystemCredentials::deleteCredential(name);
SystemCredentials::deleteCredential(name); //keyring's password may not be in system credentials
return true;
}
return false;
Expand Down
27 changes: 15 additions & 12 deletions src/keyring/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ namespace Nickvision::Aura::Keyring
{
static std::string sqlite3_column_string(sqlite3_stmt* statement, int index)
{
(void)sqlite3_column_bytes(statement, index);
sqlite3_column_bytes(statement, index);
const char* data{ static_cast<const char*>(sqlite3_column_blob(statement, index)) };
return { data, static_cast<size_t>(sqlite3_column_bytes(statement, index)) };
}

static std::filesystem::path getPathFromName(const std::string& name)
{
return Store::getStoreDir() / (name + ".ring");
std::filesystem::path dir{ UserDirectories::getConfig() / "Nickvision" / "Keyring" };
std::filesystem::create_directories(dir);
return dir / (name + ".ring");
}

Store::Store(const std::string& name, const std::string& password)
Expand Down Expand Up @@ -48,7 +50,7 @@ namespace Nickvision::Aura::Keyring
{
if (m_database)
{
sqlite3_close_v2(m_database);
sqlite3_close(m_database);
}
}

Expand Down Expand Up @@ -218,7 +220,7 @@ namespace Nickvision::Aura::Keyring
std::lock_guard<std::mutex> lock{ m_mutex };
if (m_database)
{
sqlite3_close_v2(m_database);
sqlite3_close(m_database);
m_database = nullptr;
}
return std::filesystem::exists(m_path) ? std::filesystem::remove(m_path) : true;
Expand Down Expand Up @@ -262,20 +264,21 @@ namespace Nickvision::Aura::Keyring
{
if (sqlite3_exec(m_database, "SELECT count(*) FROM sqlite_master;", nullptr, nullptr, nullptr) == SQLITE_OK)
{
sqlite3_exec(m_database, "CREATE TABLE IF NOT EXISTS credentials (id TEXT PRIMARY KEY, name TEXT, uri TEXT, username TEXT, password TEXT)", nullptr, nullptr, nullptr);
return;
if (sqlite3_exec(m_database, "CREATE TABLE IF NOT EXISTS credentials (id TEXT PRIMARY KEY, name TEXT, uri TEXT, username TEXT, password TEXT)", nullptr, nullptr, nullptr) == SQLITE_OK)
{
return;
}
std::cout << "Cannot create table" << std::endl;
}
std::cout << "Invalid key" << std::endl;
}
sqlite3_close_v2(m_database);
std::cout << "Cannot key" << std::endl;
sqlite3_close(m_database);
}
std::cout << "Cannot open" << std::endl;
m_database = nullptr;
}

std::filesystem::path Store::getStoreDir()
{
return UserDirectories::getConfig() / "Nickvision" / "Keyring";
}

bool Store::exists(const std::string& name)
{
return std::filesystem::exists(getPathFromName(name));
Expand Down

0 comments on commit f884ff2

Please sign in to comment.