mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-17 07:15:57 +01:00
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
|
#pragma once
|
||
|
|
||
|
#include <memory>
|
||
|
#include <optional>
|
||
|
#include <string>
|
||
|
#include <mutex>
|
||
|
#include <condition_variable>
|
||
|
|
||
|
class CAuth {
|
||
|
public:
|
||
|
struct SPamConversationState {
|
||
|
std::string input = "";
|
||
|
std::string prompt = "";
|
||
|
std::string failText = "";
|
||
|
|
||
|
std::mutex inputMutex;
|
||
|
std::condition_variable inputSubmittedCondition;
|
||
|
|
||
|
bool waitingForPamAuth = false;
|
||
|
bool inputRequested = false;
|
||
|
|
||
|
bool success = false;
|
||
|
};
|
||
|
|
||
|
CAuth();
|
||
|
|
||
|
void start();
|
||
|
bool auth();
|
||
|
bool didAuthSucceed();
|
||
|
|
||
|
void waitForInput();
|
||
|
void submitInput(std::string input);
|
||
|
|
||
|
std::optional<std::string> getLastFailText();
|
||
|
std::optional<std::string> getLastPrompt();
|
||
|
|
||
|
bool checkWaiting();
|
||
|
|
||
|
void terminate();
|
||
|
|
||
|
// Should only be set via the main thread
|
||
|
bool m_bDisplayFailText = false;
|
||
|
|
||
|
private:
|
||
|
SPamConversationState m_sConversationState;
|
||
|
|
||
|
bool m_bBlockInput = true;
|
||
|
|
||
|
std::string m_sPamModule;
|
||
|
|
||
|
void resetConversation();
|
||
|
};
|
||
|
|
||
|
inline std::unique_ptr<CAuth> g_pAuth;
|