C

油门杆:渲染安全关键UI

/****************************************************************************** ** ** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Safe Renderer. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
#include <unistd.h> #include <stdlib.h> #include <time.h> #include <stdio.h> #include <sys/dispatch.h> #include <QtSafeRenderer/qsafeevent.h> #include <QtSafeRenderer/qsafeglobal.h> #define ATTACH_POINT "saferenderer" using namespace SafeRenderer; typedef struct _pulse msg_header_t; typedef struct _message_data { msg_header_t hdr; SafeRenderer::QSafeEvent event; } message_data; class MessageSender { public: MessageSender() : m_serverCoid(-1) { } ~MessageSender() { disconnect(); } bool connect() { bool returnValue = true; m_serverCoid = name_open(ATTACH_POINT, 0); if (m_serverCoid < 0) returnValue = false; return returnValue; } void disconnect() const { name_close(m_serverCoid); } void sendMessage(const SafeRenderer::QSafeEvent& event) const { message_data msg; msg.hdr.type = 0U; msg.hdr.subtype = 0U; msg.event = event; if (m_serverCoid == -1 || MsgSend(m_serverCoid, &msg, sizeof(msg), NULL, 0) == -1) { printf("Failed to send message.\n"); } } private: qint32 m_serverCoid; };