1 Star 0 Fork 6

liubuguiii/src-kiran-session-guard

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0007-fix-kiran-session-guard-fits-the-Qt5.9.7-interface.patch 4.50 KB
一键复制 编辑 原始数据 按行查看 历史
liubuguiii 提交于 2024-01-18 11:52 . 同步更新,修复BUG
From af28157ad311c38ab8990b1abd2b1a3041c65a22 Mon Sep 17 00:00:00 2001
From: niko_yhc <yinhongchang@kylinsec.com.cn>
Date: Tue, 12 Sep 2023 19:20:14 +0800
Subject: [PATCH 7/7] fix(kiran-session-guard):fits the Qt5.9.7 interface
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 适配Qt5.9.7接口,修复编译报错
Closes:#15019
---
lib/auth-proxy/auth-controller.cpp | 21 +++++++++++++++++++++
src/polkit-agent/listener.cpp | 26 ++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/lib/auth-proxy/auth-controller.cpp b/lib/auth-proxy/auth-controller.cpp
index ce574a2..9d7acd4 100644
--- a/lib/auth-proxy/auth-controller.cpp
+++ b/lib/auth-proxy/auth-controller.cpp
@@ -145,7 +145,12 @@ bool AuthController::processAuthDaemonCommand(const QString& msg)
auto cmdStr = msg.midRef(strlen(KAP_PROTO_JSON_PREFIX), -1);
QJsonDocument jsonDoc = QJsonDocument::fromJson(cmdStr.toUtf8());
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
int protoID = jsonDoc[KAP_PJK_KEY_HEAD][KAP_PJK_KEY_CMD].toInt(-1);
+#else
+ QJsonValue val = jsonDoc.object()[KAP_PJK_KEY_HEAD];
+ int protoID = val.toObject()[KAP_PJK_KEY_CMD].toInt(-1);
+#endif
if (protoID == -1)
{
return false;
@@ -155,7 +160,12 @@ bool AuthController::processAuthDaemonCommand(const QString& msg)
{
case KAP_REQ_CMD_NOTIFY_AUTH_MODE:
{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
auto authMode = jsonDoc[KAP_PJK_KEY_BODY][KAP_PJK_KEY_AUTH_MODE].toInt(-1);
+#else
+ QJsonValue val = jsonDoc.object()[KAP_PJK_KEY_BODY];
+ auto authMode = val.toObject()[KAP_PJK_KEY_AUTH_MODE].toInt(-1);
+#endif
if (authMode < KAD_AUTH_MODE_NONE || authMode > KAD_AUTH_MODE_LAST)
{
KLOG_WARNING() << "invalid auth mode" << authMode;
@@ -171,7 +181,13 @@ bool AuthController::processAuthDaemonCommand(const QString& msg)
}
case KAP_REQ_CMD_NOTIFY_SUPPORT_AUTH_TYPE:
{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
auto authTypesArray = jsonDoc[KAP_PJK_KEY_BODY][KAP_PJK_KEY_AUTH_TYPES].toArray(QJsonArray());
+#else
+ QJsonValue val = jsonDoc.object()[KAP_PJK_KEY_BODY];
+ const QJsonObject object = val.toObject();
+ auto authTypesArray = object[KAP_PJK_KEY_AUTH_TYPES].toArray(QJsonArray());
+#endif
if (authTypesArray.isEmpty())
{
KLOG_WARNING() << "invalid auth types";
@@ -202,7 +218,12 @@ bool AuthController::processAuthDaemonCommand(const QString& msg)
}
case KAP_REQ_CMD_NOTIFY_AUTH_TYPE:
{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
auto authType = jsonDoc[KAP_PJK_KEY_BODY][KAP_PJK_KEY_AUTH_TYPE].toInt(-1);
+#else
+ QJsonValue val = jsonDoc.object()[KAP_PJK_KEY_BODY];
+ auto authType = val.toObject()[KAP_PJK_KEY_AUTH_TYPES].toInt(-1);
+#endif
if (authType <= KAD_AUTH_TYPE_NONE || authType >= KAD_AUTH_TYPE_LAST)
{
KLOG_WARNING() << "invalid auth types";
diff --git a/src/polkit-agent/listener.cpp b/src/polkit-agent/listener.cpp
index fbcd66a..7474329 100644
--- a/src/polkit-agent/listener.cpp
+++ b/src/polkit-agent/listener.cpp
@@ -38,6 +38,28 @@ Listener::~Listener()
{
}
+#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
+static QScreen *screenAt(const QPoint &point)
+{
+ QVarLengthArray<const QScreen *, 8> visitedScreens;
+ for (const QScreen *screen : QGuiApplication::screens()) {
+ if (visitedScreens.contains(screen))
+ continue;
+
+ // The virtual siblings include the screen itself, so iterate directly
+ for (QScreen *sibling : screen->virtualSiblings()) {
+ if (sibling->geometry().contains(point))
+ return sibling;
+
+ visitedScreens.append(sibling);
+ }
+ }
+
+ return nullptr;
+}
+#endif
+
+
void Listener::initiateAuthentication(const QString &actionId,
const QString &message,
const QString &iconName,
@@ -83,7 +105,11 @@ void Listener::initiateAuthentication(const QString &actionId,
connect(m_authDialog, &Dialog::completed, this, &Listener::onAuthDialogCompleted);
connect(m_authDialog, &Dialog::cancelled, this, &Listener::onAuthDialogCancelled);
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
auto screen = QApplication::screenAt(QCursor::pos());
+#else
+ auto screen = screenAt(QCursor::pos());
+#endif
if (screen != nullptr)
{
QRect screenGeometry = screen->geometry();
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liubuguiii/src-kiran-session-guard.git
git@gitee.com:liubuguiii/src-kiran-session-guard.git
liubuguiii
src-kiran-session-guard
src-kiran-session-guard
master

搜索帮助