added qasecret support

This commit is contained in:
Andrei Yankovich 2024-01-21 16:44:23 +01:00
parent 10d0361ae1
commit 08c27ec560
3 changed files with 62 additions and 1 deletions

View File

@ -63,7 +63,8 @@ file(GLOB SOURCE_CPP
"*.cpp" "*.h"
)
add_library(${PROJECT_NAME} ${SOURCE_CPP})
add_library(${PROJECT_NAME} ${SOURCE_CPP}
qasecretservice.h qasecretservice.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

27
qasecretservice.cpp Normal file
View File

@ -0,0 +1,27 @@
#include "qasecretservice.h"
#include <QProcess>
QByteArray QuasarAppUtils::QASecretService::getByAlias(const QString &alias) {
QProcess proc;
proc.setProgram("qasecretservice");
proc.setArguments(QStringList() << "get" << "-alias" << alias);
proc.start();
proc.waitForFinished(2000);
return proc.readAllStandardOutput();
}
QByteArray QuasarAppUtils::QASecretService::getByHash(const QByteArray &hash)
{
QProcess proc;
proc.setProgram("qasecretservice");
proc.setArguments(QStringList() << "get" << "-hash" << hash);
proc.start();
proc.waitForFinished(2000);
return proc.readAllStandardOutput();
}

33
qasecretservice.h Normal file
View File

@ -0,0 +1,33 @@
/*
* Copyright (C) 2024-2024 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#ifndef QASECRETSERVICE_H
#define QASECRETSERVICE_H
#include <QByteArray>
namespace QuasarAppUtils {
/**
* @brief The qasecretservice class This is a simeple provider of QASecretService tool
* See https://github.com/QuasarApp/SecretService
* @note Before use this class please install QASecretService to your runtime mashine.
*
*/
class QASecretService
{
public:
QASecretService();
static QByteArray getByAlias(const QString& alias);
static QByteArray getByHash(const QByteArray& hash);
};
}
#endif // QASECRETSERVICE_H