Commit 72fb0796 authored by Eskil Abrahamsen-Blomfeldt's avatar Eskil Abrahamsen-Blomfeldt
Browse files

VncChat example + some docs

A small example and some details in documentation.
parent 50b38687
cmake_minimum_required(VERSION 3.16)
project(vncchat LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/vncserver/vncchat")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick VncServer)
qt_add_executable(vncchat
main.cpp
)
set_target_properties(vncchat PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
target_link_libraries(vncchat PUBLIC
Qt::Core
Qt::Gui
Qt::Quick
Qt::VncServer
)
qt_add_qml_module(vncchat
URI Example
VERSION 1.0
QML_FILES main.qml
NO_RESOURCE_TARGET_PATH
)
install(TARGETS vncchat
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example vncchat
\ingroup vncserver-examples
\title Qt VNC Server - VncChat Example
\brief Demonstrates how to make a simple application that uses Qt VNC Server.
\e {VncChat} demonstrates the use of the \l{Qt VNC Server} module. The example
is a simple, disorganized chat application where a text editor component is
exposed to VNC®-compatible clients and anyone connecting can edit it together.
*/
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
import QtQuick.Controls
import QtQuickVnc
Window {
id: window
width: 640
height: 640
visible: true
color: "white"
title: "Qt Vnc Chat"
Rectangle {
id: activeRect
anchors.centerIn: parent
width: parent.width * 0.75
height: parent.height * 0.75
radius: parent.width * 0.1
color: grabber.connectionActive ? "darkseagreen" : "salmon"
Label {
id: titleLabel
anchors.top: activeRect.top
anchors.horizontalCenter: activeRect.horizontalCenter
text: "Qt Vnc Chat"
font.pixelSize: window.height * 0.03
}
Label {
id: portLabel
anchors.top: titleLabel.bottom
anchors.horizontalCenter: activeRect.horizontalCenter
text: "(Port " + grabber.vncPort + " is open for business)"
font.pixelSize: window.height * 0.015
}
VncItem {
id: grabber
anchors.fill: parent
Rectangle {
anchors.fill: parent
anchors.margins: window.width * 0.1
radius: window.width * 0.1
color: "gainsboro"
TextArea {
id: textArea
anchors.fill: parent
anchors.margins: window.width * 0.1
background: null
placeholderText: "Say something nice"
placeholderTextColor: "darkslategrey"
}
}
}
}
}
......@@ -30,12 +30,12 @@
\title Qt VNC Server
\brief Provides API for creating a VNC server with Qt.
Qt VNC Server provides APIs for creating a simple VNC server with Qt. The VNC server uses the
"Remote Frame Buffer protocol" (RFB) to share graphics and input between the server and one or more
remote VNC clients.
Qt VNC Server provides APIs for creating a simple VNC®-compatible server with Qt. The VNC®-compatible server
uses the "Remote Frame Buffer protocol" (RFB®) to share graphics and input between the server and one or more
remote VNC®-compatible clients.
A typical use case is to share parts of a Qt Quick application with a remote user or remote screen,
by using the QtQuickVnc module. Using VNC client software, the remote user will be able to see and
by using the QtQuickVnc module. Using VNC®-compatible client software, the remote user will be able to see and
interact with the application.
The module can be combined with \l{Qt Wayland Compositor} in order to make a remote desktop
......@@ -49,6 +49,8 @@ solution.
\section2 C++ API
\section1
\section1 Examples
The best way to see what Qt VNC Server can do is to check out the examples:
......@@ -56,6 +58,44 @@ The best way to see what Qt VNC Server can do is to check out the examples:
\list
\endlist
\section1 Supported features
The Qt VNC Server supports a subset of features from the RFB® specification.
\section2 Encodings
Qt VNC Server supports clients connecting with the following encodings:
\list
\li Raw - Graphics is transmitted as uncompressed data.
\li Hextile - Graphics is transmitted using hextile compression.
\li Zlib - Uses zlib for compressing data before transmission.
\endlist
The \c{QT_VNCSERVER_PREFERRED_ENCODING} environment variable can be used to set the
preferred encodings for the server as a semi-colon separated list of the encodings above.
It also decides the order of preference.
If unset, the server will respect the preferences of the client. But if the environment variable
is set, it will be used as basis of negotiation. The first encoding in the semi-colon separated
list which is also supported by the client will be used.
The "raw" encoding will always be the fall back if no other suitable encoding is found, even if
not listed.
In addition to the compression algorithms mentioned here, Qt VNC Server also defaults to detecting
dirty regions in updated frames. This can be disabled by setting \c{QT_VNC_NO_DIRTYMAP} to 1 in
the environment. Under certain circumstances where the application updates all or most of the surface
each frame, it can be more efficient to skip the detection of dirty regions.
\section2 Security
If \l{https://www.libtom.net/}{LibTomCrypt} is available, Qt VNC Server will be built with support for
password protection using DEC Authentication. This is considered weak security, and may protect against
accidental access, but not against targeted attacks.
There is otherwise no encryption on the connection, and the recommendation is to use the server on trusted
networks and VPNs.
\section1 Reference
\list
\li \l{Qt VNC Server QML Types}
......@@ -70,8 +110,7 @@ as APIs may change based on user feedback and general improvements.
\section1 License and Attributions
Qt VNC Server is available under the commercial license from \l {The Qt Company}.
In addition, it is available under the
\l{GNU General Public License, version 3}.
See \l {Qt Licensing} for further details.
VNC® and RFB® are registered trademarks of RealVNC® Ltd.
*/
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment