Files
orbithub/src/profile_repository.h

49 lines
1.1 KiB
C++

#ifndef ORBITHUB_PROFILE_REPOSITORY_H
#define ORBITHUB_PROFILE_REPOSITORY_H
#include <QString>
#include <QtGlobal>
#include <optional>
#include <vector>
struct Profile
{
qint64 id = -1;
QString name;
QString host;
int port = 22;
QString username;
QString protocol = QStringLiteral("SSH");
QString authMode = QStringLiteral("Password");
QString privateKeyPath;
QString knownHostsPolicy = QStringLiteral("Ask");
};
class ProfileRepository
{
public:
ProfileRepository();
~ProfileRepository();
QString initError() const;
QString lastError() const;
std::vector<Profile> listProfiles(const QString& searchQuery = QString()) const;
std::optional<Profile> getProfile(qint64 id) const;
std::optional<Profile> createProfile(const Profile& profile) const;
bool updateProfile(const Profile& profile) const;
bool deleteProfile(qint64 id) const;
private:
QString m_connectionName;
QString m_initError;
mutable QString m_lastError;
bool initializeDatabase();
bool ensureProfileSchema() const;
void setLastError(const QString& error) const;
};
#endif