Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Alberto Mardegan
Lomiri VNC
Commits
c671fc90
Commit
c671fc90
authored
Dec 18, 2020
by
Daniel O'Neill
Committed by
Alberto Mardegan
Dec 20, 2020
Browse files
VncClient: basic password authentication support
parent
7f21b0d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
8 deletions
+34
-8
src/desktop/qml/MainPage.qml
src/desktop/qml/MainPage.qml
+11
-2
src/desktop/qml/main.qml
src/desktop/qml/main.qml
+1
-1
src/vnc_client.cpp
src/vnc_client.cpp
+21
-4
src/vnc_client.h
src/vnc_client.h
+1
-1
No files found.
src/desktop/qml/MainPage.qml
View file @
c671fc90
...
...
@@ -5,7 +5,7 @@ import QtQuick.Layouts 1.3
Page
{
id
:
root
signal
connectionRequested
(
string
host
)
signal
connectionRequested
(
string
host
,
string
password
)
title
:
qsTr
(
"
VNC Client
"
)
...
...
@@ -26,10 +26,19 @@ Page {
onAccepted
:
activate
()
function
activate
()
{
root
.
connectionRequested
(
text
)
root
.
connectionRequested
(
text
,
passwordField
.
text
)
}
}
TextFieldWithContextMenu
{
id
:
passwordField
Layout.fillWidth
:
true
placeholderText
:
qsTr
(
"
Password (optional)
"
)
echoMode
:
TextInput
.
PasswordEchoOnEdit
selectByMouse
:
true
onAccepted
:
urlField
.
activate
();
}
Button
{
Layout.alignment
:
Qt
.
AlignHCenter
text
:
qsTr
(
"
Connect
"
)
...
...
src/desktop/qml/main.qml
View file @
c671fc90
...
...
@@ -22,7 +22,7 @@ ApplicationWindow {
id
:
mainPageComponent
MainPage
{
onConnectionRequested
:
{
vncClient
.
connectToServer
(
host
);
vncClient
.
connectToServer
(
host
,
password
);
}
}
}
...
...
src/vnc_client.cpp
View file @
c671fc90
...
...
@@ -48,6 +48,7 @@ public:
static
void
vncError
(
const
char
*
format
,
...);
static
void
gotFrameBufferUpdate
(
rfbClient
*
cl
,
int
x
,
int
y
,
int
w
,
int
h
);
static
char
*
GetPassword
(
rfbClient
*
cl
);
static
rfbBool
mallocFrameBuffer
(
rfbClient
*
client
);
static
int
qtToRfb
(
Qt
::
MouseButtons
buttons
);
...
...
@@ -56,8 +57,9 @@ public:
void
onUpdate
(
int
x
,
int
y
,
int
w
,
int
h
);
void
onResize
();
char
*
getPassword
();
bool
connectToServer
(
const
QString
&
host
);
bool
connectToServer
(
const
QString
&
host
,
const
QString
&
password
);
void
disconnect
();
void
onSocketActivated
();
...
...
@@ -72,6 +74,7 @@ private:
int
m_bytesPerPixel
;
QImage
m_image
;
QList
<
QQuickItem
*>
m_viewers
;
QString
m_password
;
rfbClient
*
m_client
;
VncClient
*
q_ptr
;
};
...
...
@@ -124,6 +127,12 @@ void VncClientPrivate::gotFrameBufferUpdate(rfbClient *client,
static_cast
<
VncClientPrivate
*>
(
ptr
)
->
onUpdate
(
x
,
y
,
w
,
h
);
}
char
*
VncClientPrivate
::
GetPassword
(
rfbClient
*
client
)
{
void
*
ptr
=
rfbClientGetClientData
(
client
,
dataTag
());
return
static_cast
<
VncClientPrivate
*>
(
ptr
)
->
getPassword
();
}
rfbBool
VncClientPrivate
::
mallocFrameBuffer
(
rfbClient
*
client
)
{
void
*
ptr
=
rfbClientGetClientData
(
client
,
dataTag
());
...
...
@@ -271,7 +280,12 @@ void VncClientPrivate::onResize()
}
}
bool
VncClientPrivate
::
connectToServer
(
const
QString
&
host
)
char
*
VncClientPrivate
::
getPassword
()
{
return
strdup
(
m_password
.
toUtf8
().
constData
());
}
bool
VncClientPrivate
::
connectToServer
(
const
QString
&
host
,
const
QString
&
password
)
{
Q_Q
(
VncClient
);
...
...
@@ -279,9 +293,12 @@ bool VncClientPrivate::connectToServer(const QString &host)
disconnect
();
}
m_password
=
QString
(
password
);
m_client
=
rfbGetClient
(
8
,
3
,
m_bytesPerPixel
);
m_client
->
MallocFrameBuffer
=
mallocFrameBuffer
;
m_client
->
GotFrameBufferUpdate
=
gotFrameBufferUpdate
;
m_client
->
GetPassword
=
GetPassword
;
rfbClientSetClientData
(
m_client
,
dataTag
(),
this
);
QByteArrayList
arguments
=
{
...
...
@@ -397,10 +414,10 @@ const QImage &VncClient::image() const
return
d
->
m_image
;
}
bool
VncClient
::
connectToServer
(
const
QString
&
host
)
bool
VncClient
::
connectToServer
(
const
QString
&
host
,
const
QString
&
password
)
{
Q_D
(
VncClient
);
return
d
->
connectToServer
(
host
);
return
d
->
connectToServer
(
host
,
password
);
}
void
VncClient
::
disconnect
()
...
...
src/vnc_client.h
View file @
c671fc90
...
...
@@ -46,7 +46,7 @@ public:
void
removeViewer
(
QQuickItem
*
viewer
);
const
QImage
&
image
()
const
;
Q_INVOKABLE
bool
connectToServer
(
const
QString
&
host
);
Q_INVOKABLE
bool
connectToServer
(
const
QString
&
host
,
const
QString
&
password
);
Q_INVOKABLE
void
disconnect
();
void
sendKeyEvent
(
QChar
c
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment