forked from quickshell/quickshell
		
	service/pam: add responseVisible
Fixes misunderstanding of "echo".
This commit is contained in:
		
							parent
							
								
									6efa05a8eb
								
							
						
					
					
						commit
						59cf60d83e
					
				
					 3 changed files with 22 additions and 18 deletions
				
			
		| 
						 | 
					@ -123,12 +123,7 @@ void PamConversation::onMessage() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (!ok) goto fail;
 | 
								if (!ok) goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			this->message(
 | 
								this->message(QString::fromUtf8(message), flags.error, flags.responseRequired, flags.echo);
 | 
				
			||||||
			    QString::fromUtf8(message),
 | 
					 | 
				
			||||||
			    /*flags.echo*/ true,
 | 
					 | 
				
			||||||
			    flags.error,
 | 
					 | 
				
			||||||
			    flags.responseRequired
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			qCCritical(logPam) << "Unexpected message from subprocess.";
 | 
								qCCritical(logPam) << "Unexpected message from subprocess.";
 | 
				
			||||||
			goto fail;
 | 
								goto fail;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -193,6 +193,7 @@ void PamContext::setUser(QString user) {
 | 
				
			||||||
QString PamContext::message() const { return this->mMessage; }
 | 
					QString PamContext::message() const { return this->mMessage; }
 | 
				
			||||||
bool PamContext::messageIsError() const { return this->mMessageIsError; }
 | 
					bool PamContext::messageIsError() const { return this->mMessageIsError; }
 | 
				
			||||||
bool PamContext::isResponseRequired() const { return this->mIsResponseRequired; }
 | 
					bool PamContext::isResponseRequired() const { return this->mIsResponseRequired; }
 | 
				
			||||||
 | 
					bool PamContext::isResponseVisible() const { return this->mIsResponseVisible; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PamContext::onCompleted(PamResult::Enum result) {
 | 
					void PamContext::onCompleted(PamResult::Enum result) {
 | 
				
			||||||
	this->abortConversation();
 | 
						this->abortConversation();
 | 
				
			||||||
| 
						 | 
					@ -207,20 +208,23 @@ void PamContext::onError(PamError::Enum error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PamContext::onMessage(
 | 
					void PamContext::onMessage(
 | 
				
			||||||
    QString message,
 | 
					    QString message,
 | 
				
			||||||
    bool messageChanged,
 | 
					 | 
				
			||||||
    bool isError,
 | 
					    bool isError,
 | 
				
			||||||
    bool responseRequired
 | 
					    bool responseRequired,
 | 
				
			||||||
 | 
					    bool responseVisible
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
	if (messageChanged) {
 | 
						if (message != this->mMessage) {
 | 
				
			||||||
		if (message != this->mMessage) {
 | 
							this->mMessage = std::move(message);
 | 
				
			||||||
			this->mMessage = std::move(message);
 | 
							emit this->messageChanged();
 | 
				
			||||||
			emit this->messageChanged();
 | 
						}
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (isError != this->mMessageIsError) {
 | 
						if (isError != this->mMessageIsError) {
 | 
				
			||||||
			this->mMessageIsError = isError;
 | 
							this->mMessageIsError = isError;
 | 
				
			||||||
			emit this->messageIsErrorChanged();
 | 
							emit this->messageIsErrorChanged();
 | 
				
			||||||
		}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (responseVisible != this->mIsResponseVisible) {
 | 
				
			||||||
 | 
							this->mIsResponseVisible = responseVisible;
 | 
				
			||||||
 | 
							emit this->responseVisibleChanged();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (responseRequired != this->mIsResponseRequired) {
 | 
						if (responseRequired != this->mIsResponseRequired) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,6 +46,8 @@ class PamContext
 | 
				
			||||||
	///
 | 
						///
 | 
				
			||||||
	/// Responses can be returned with the `respond()` function.
 | 
						/// Responses can be returned with the `respond()` function.
 | 
				
			||||||
	Q_PROPERTY(bool responseRequired READ isResponseRequired NOTIFY responseRequiredChanged);
 | 
						Q_PROPERTY(bool responseRequired READ isResponseRequired NOTIFY responseRequiredChanged);
 | 
				
			||||||
 | 
						/// If the user's response should be visible. Only valid when `responseRequired` is true.
 | 
				
			||||||
 | 
						Q_PROPERTY(bool responseVisible READ isResponseVisible NOTIFY responseVisibleChanged);
 | 
				
			||||||
	// clang-format on
 | 
						// clang-format on
 | 
				
			||||||
	QML_ELEMENT;
 | 
						QML_ELEMENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,6 +86,7 @@ public:
 | 
				
			||||||
	[[nodiscard]] QString message() const;
 | 
						[[nodiscard]] QString message() const;
 | 
				
			||||||
	[[nodiscard]] bool messageIsError() const;
 | 
						[[nodiscard]] bool messageIsError() const;
 | 
				
			||||||
	[[nodiscard]] bool isResponseRequired() const;
 | 
						[[nodiscard]] bool isResponseRequired() const;
 | 
				
			||||||
 | 
						[[nodiscard]] bool isResponseVisible() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
	/// Emitted whenever authentication completes.
 | 
						/// Emitted whenever authentication completes.
 | 
				
			||||||
| 
						 | 
					@ -104,11 +107,12 @@ signals:
 | 
				
			||||||
	void messageChanged();
 | 
						void messageChanged();
 | 
				
			||||||
	void messageIsErrorChanged();
 | 
						void messageIsErrorChanged();
 | 
				
			||||||
	void responseRequiredChanged();
 | 
						void responseRequiredChanged();
 | 
				
			||||||
 | 
						void responseVisibleChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private slots:
 | 
					private slots:
 | 
				
			||||||
	void onCompleted(PamResult::Enum result);
 | 
						void onCompleted(PamResult::Enum result);
 | 
				
			||||||
	void onError(PamError::Enum error);
 | 
						void onError(PamError::Enum error);
 | 
				
			||||||
	void onMessage(QString message, bool messageChanged, bool isError, bool responseRequired);
 | 
						void onMessage(QString message, bool isError, bool responseRequired, bool responseVisible);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	PamConversation* conversation = nullptr;
 | 
						PamConversation* conversation = nullptr;
 | 
				
			||||||
| 
						 | 
					@ -121,4 +125,5 @@ private:
 | 
				
			||||||
	QString mMessage;
 | 
						QString mMessage;
 | 
				
			||||||
	bool mMessageIsError = false;
 | 
						bool mMessageIsError = false;
 | 
				
			||||||
	bool mIsResponseRequired = false;
 | 
						bool mIsResponseRequired = false;
 | 
				
			||||||
 | 
						bool mIsResponseVisible = false;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue