├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── README.md
├── client
├── CMakeLists.txt
├── main.cpp
├── qkxconnectiondialog.cpp
├── qkxconnectiondialog.h
├── qkxconnectiondialog.ui
├── qkxvncviewer.cpp
├── qkxvncviewer.h
├── qkxvncviewer.ui
├── resource
│ └── vncviewer.ico
├── version.h
├── versioninfo.rc.in
└── vncviewer.qrc
├── doc
├── ftp.png
├── main.png
└── vnc.png
├── kxcap
├── CMakeLists.txt
├── d3des.cpp
├── d3des.h
├── keycode.h
├── keysymdef.h
├── language
│ ├── release.bat
│ ├── update.bat
│ ├── vncserver_en.qm
│ ├── vncserver_en.ts
│ ├── vncserver_zh.qm
│ └── vncserver_zh.ts
├── macnap.h
├── objcapi.cpp
├── objcapi.h
├── qkxabstractcapture.cpp
├── qkxabstractcapture.h
├── qkxaudiocapture.cpp
├── qkxaudiocapture.h
├── qkxaudiostream.cpp
├── qkxaudiostream.h
├── qkxcap.cpp
├── qkxcap.h
├── qkxcap_private.h
├── qkxcap_share.h
├── qkxcapoption.cpp
├── qkxcapoption.h
├── qkxcapserver.cpp
├── qkxcapserver.h
├── qkxcapserverprivate.cpp
├── qkxcapserverprivate.h
├── qkxcapserverunixprivate.cpp
├── qkxcapserverunixprivate.h
├── qkxcapserverwindowprivate.cpp
├── qkxcapserverwindowprivate.h
├── qkxclipboard.cpp
├── qkxclipboard.h
├── qkxdaemonmaster.cpp
├── qkxdaemonmaster.h
├── qkxdaemonslave.cpp
├── qkxdaemonslave.h
├── qkxdirtyframe.cpp
├── qkxdirtyframe.h
├── qkxdxgicapture.cpp
├── qkxdxgicapture.h
├── qkxdxgiscreencapture.cpp
├── qkxdxgiscreencapture.h
├── qkxftpworker.cpp
├── qkxftpworker.h
├── qkxgdicapture.cpp
├── qkxgdicapture.h
├── qkxgdiscreencapture.cpp
├── qkxgdiscreencapture.h
├── qkxh264encoder.cpp
├── qkxh264encoder.h
├── qkxjpegencoder.cpp
├── qkxjpegencoder.h
├── qkxlocalvncserver.cpp
├── qkxlocalvncserver.h
├── qkxmaccapture.cpp
├── qkxmaccapture.h
├── qkxmacclipboard.h
├── qkxmacclipboard.mm
├── qkxmacscreencapture.cpp
├── qkxmacscreencapture.h
├── qkxmacsendinput.cpp
├── qkxmacsendinput.h
├── qkxopusencoder.cpp
├── qkxopusencoder.h
├── qkxprivacyscreen.cpp
├── qkxprivacyscreen.h
├── qkxresample.cpp
├── qkxresample.h
├── qkxscreencapture.cpp
├── qkxscreencapture.h
├── qkxscreenlistener.cpp
├── qkxscreenlistener.h
├── qkxscreenlistener_unix.cpp
├── qkxscreenlistener_win.cpp
├── qkxsecurity.cpp
├── qkxsecurity.h
├── qkxsendinput.cpp
├── qkxsendinput.h
├── qkxserviceapplication.cpp
├── qkxserviceapplication.h
├── qkxserviceprocess.cpp
├── qkxserviceprocess.h
├── qkxserviceprocess_unix.cpp
├── qkxserviceprocess_win.cpp
├── qkxtcpvncserver.cpp
├── qkxtcpvncserver.h
├── qkxutils.cpp
├── qkxutils.h
├── qkxutils_mac.cpp
├── qkxutils_unix.cpp
├── qkxutils_win.cpp
├── qkxvnccompress.cpp
├── qkxvnccompress.h
├── qkxvnccompressabort.cpp
├── qkxvnccompressabort.h
├── qkxvncserver.cpp
├── qkxvncserver.h
├── qkxvncserverpeer.cpp
├── qkxvncserverpeer.h
├── qkxwin8privacyscreen.cpp
├── qkxwin8privacyscreen.h
├── qkxwinaudiocapture.cpp
├── qkxwinaudiocapture.h
├── qkxwinclipboard.cpp
├── qkxwinclipboard.h
├── qkxwindows.cpp
├── qkxwindows.h
├── qkxwinsendinput.cpp
├── qkxwinsendinput.h
├── qkxx11capture.cpp
├── qkxx11capture.h
├── qkxx11clipboard.cpp
├── qkxx11clipboard.h
├── qkxx11screencapture.cpp
├── qkxx11screencapture.h
├── qkxx11sendinput.cpp
├── qkxx11sendinput.h
├── resample
│ ├── config.h
│ ├── configtemplate.h
│ ├── filterkit.cpp
│ ├── filterkit.h
│ ├── libresample.h
│ ├── resample.cpp
│ ├── resample_defs.h
│ └── resamplesubs.cpp
└── resource
│ ├── kblayout
│ └── default.kmap
│ ├── skin.fw.png
│ ├── skin
│ ├── configure.png
│ ├── exit.png
│ ├── eye.png
│ ├── play.png
│ ├── product.png
│ ├── reload.png
│ ├── stop.png
│ ├── vncserver.png
│ ├── vncserver2.png
│ └── wovncserver.png
│ ├── template.plist.in
│ ├── vncserver.ico
│ └── wovncserver.icns
├── kxftp
├── CMakeLists.txt
├── qkxftp.qrc
├── qkxftp_private.h
├── qkxftp_share.h
├── qkxftpclient.cpp
├── qkxftpclient.h
├── qkxftpdownload.cpp
├── qkxftpdownload.h
├── qkxftplocalmodel.cpp
├── qkxftplocalmodel.h
├── qkxftpremotemodel.cpp
├── qkxftpremotemodel.h
├── qkxftprequest.cpp
├── qkxftprequest.h
├── qkxftpresponse.cpp
├── qkxftpresponse.h
├── qkxftpserver.cpp
├── qkxftpserver.h
├── qkxftpserverprivate.cpp
├── qkxftpserverprivate.h
├── qkxftptransfermodel.cpp
├── qkxftptransfermodel.h
├── qkxftptransferwidget.cpp
├── qkxftptransferwidget.h
├── qkxftpupload.cpp
├── qkxftpupload.h
└── resource
│ └── skin
│ ├── back.png
│ ├── copy.png
│ ├── download.png
│ ├── folder.png
│ ├── forward.png
│ ├── home.png
│ ├── login.png
│ ├── pause.png
│ ├── reload.png
│ ├── remove.png
│ ├── removeall.png
│ ├── right.png
│ ├── start.png
│ ├── startall.png
│ ├── stopall.png
│ ├── time.png
│ ├── transfer.png
│ └── upload.png
├── kxutil
├── CMakeLists.txt
├── qkxcleandesktop.cpp
├── qkxcleandesktop.h
├── qkxcleandesktop_win.cpp
├── qkxhttpclient.cpp
├── qkxhttpclient.h
├── qkxkeepwakeup.cpp
├── qkxkeepwakeup.h
├── qkxlengthbodypacket.cpp
├── qkxlengthbodypacket.h
├── qkxlocalpeer.cpp
├── qkxlocalpeer.h
├── qkxmacaddress.cpp
├── qkxmacaddress.h
├── qkxmactimer.h
├── qkxmactimer.mm
├── qkxrc4crypt.cpp
├── qkxrc4crypt.h
├── qkxsetting.cpp
├── qkxsetting.h
├── qkxsharememory.cpp
├── qkxsharememory.h
├── qkxutil_private.h
├── qkxutil_share.h
├── qkxwallpaper.h
├── qkxwallpaper_unix.cpp
├── qkxwallpaper_winx.cpp
├── qkxzip.cpp
├── qkxzip.h
├── rc4.cpp
└── rc4.h
├── kxvnc
├── CMakeLists.txt
├── d3des.cpp
├── d3des.h
├── keysymdef.h
├── main.cpp
├── qkxaudioplayer.cpp
├── qkxaudioplayer.h
├── qkxbuffer.cpp
├── qkxbuffer.h
├── qkxh264decoder.cpp
├── qkxh264decoder.h
├── qkxjpegdecoder.cpp
├── qkxjpegdecoder.h
├── qkxopusdecoder.cpp
├── qkxopusdecoder.h
├── qkxreader.h
├── qkxresample.cpp
├── qkxresample.h
├── qkxsocket.cpp
├── qkxsocket.h
├── qkxutils.cpp
├── qkxutils.h
├── qkxvnc.cpp
├── qkxvnc.h
├── qkxvnc_share.h
├── qkxvncwidget.cpp
├── qkxvncwidget.h
├── qkxzip.cpp
├── qkxzip.h
└── resample
│ ├── config.h
│ ├── configtemplate.h
│ ├── filterkit.cpp
│ ├── filterkit.h
│ ├── libresample.h
│ ├── resample.cpp
│ ├── resample_defs.h
│ └── resamplesubs.cpp
└── server
├── .DS_Store
├── CMakeLists.txt
├── language
├── release.bat
├── update.bat
├── vncserver_en.qm
├── vncserver_en.ts
├── vncserver_zh.qm
└── vncserver_zh.ts
├── main.cpp
├── qkxfirewall.cpp
├── qkxfirewall.h
├── qkxglobal.h
├── qkxguiapplication.cpp
├── qkxguiapplication.h
├── qkxmoredialog.cpp
├── qkxmoredialog.h
├── qkxmoredialog.ui
├── qkxsetting.cpp
├── qkxsetting.h
├── qkxsystemconfig.cpp
├── qkxsystemconfig.h
├── qkxsystemconfig.ui
├── qkxutils.cpp
├── qkxutils.h
├── qkxutils_mac.cpp
├── qkxutils_unix.cpp
├── qkxutils_win.cpp
├── qwovncserverdef.h
├── resource
├── kblayout
│ └── default.kmap
├── skin.fw.png
├── skin
│ ├── configure.png
│ ├── connect.png
│ ├── exit.png
│ ├── eye.png
│ ├── play.png
│ ├── product.png
│ ├── reload.png
│ ├── stop.png
│ ├── vncserver.png
│ ├── vncserver2.png
│ └── wovncserver.png
├── template.plist.in
├── vncserver.ico
└── wovncserver.icns
├── version.h
├── versioninfo.rc.in
├── vncserver.qrc
└── vncserver.rc
/.gitignore:
--------------------------------------------------------------------------------
1 | # C++ objects and libs
2 | *.slo
3 | *.lo
4 | *.o
5 | *.a
6 | *.la
7 | *.lai
8 | *.so
9 | *.so.*
10 | *.dll
11 | *.dylib
12 |
13 | # Qt-es
14 | object_script.*.Release
15 | object_script.*.Debug
16 | *_plugin_import.cpp
17 | /.qmake.cache
18 | /.qmake.stash
19 | *.pro.user
20 | *.pro.user.*
21 | *.qbs.user
22 | *.qbs.user.*
23 | *.moc
24 | moc_*.cpp
25 | moc_*.h
26 | qrc_*.cpp
27 | ui_*.h
28 | *.qmlc
29 | *.jsc
30 | Makefile*
31 | *build-*
32 | *.qm
33 | *.prl
34 |
35 | # Qt unit tests
36 | target_wrapper.*
37 |
38 | # QtCreator
39 | *.autosave
40 |
41 | # QtCreator Qml
42 | *.qmlproject.user
43 | *.qmlproject.user.*
44 |
45 | # QtCreator CMake
46 | CMakeLists.txt.user*
47 |
48 | # QtCreator 4.8< compilation database
49 | compile_commands.json
50 |
51 | # QtCreator local machine specific files for imported projects
52 | *creator.user*
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Overview
2 | VNC Server & Client base on Qt 5.
3 |
4 | This project is licensed under the terms of the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html) or any later version. See the LICENSE file for the full text of the license.
5 |
6 | The main goal of this project is to provide a easy mult-platform tool.
7 |
8 | ## Feature
9 | - There is no limit on the number of users logging in at the same time.
10 | - Support the standard rfb3.8 protocol, support the standard raw / copyrect /hexile / trle / zrle / openh264 encoding, and expand the zrle2/trle2/trle3/zrle3 encoding to make it have a higher compression ratio.
11 | - Support the private screen feather.
12 | - Support window / linux / macosx, and android / ios in future
13 |
14 | ## WoTerm
15 | The woterm client full support the feature list above
16 |
17 | download the binary program [http://woterm.com](http://woterm.com)
18 | ## Details:
19 | http://www.wovnc.com
20 |
21 | ## Binary Program:
22 | http://wovnc.com
23 |
24 | ## Ui Preview
25 |
26 |
27 |
--------------------------------------------------------------------------------
/client/main.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxvncviewer.h"
13 |
14 | #include
15 |
16 | int main(int argc, char *argv[])
17 | {
18 | QApplication a(argc, argv);
19 | QKxVNCViewer w;
20 | w.show();
21 | return a.exec();
22 | }
23 |
--------------------------------------------------------------------------------
/client/qkxconnectiondialog.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCONNECTIONDIALOG_H
13 | #define QKXCONNECTIONDIALOG_H
14 |
15 | #include
16 |
17 | namespace Ui {
18 | class QKxConnectionDialog;
19 | }
20 |
21 | class QKxConnectionDialog : public QDialog
22 | {
23 | Q_OBJECT
24 |
25 | public:
26 | explicit QKxConnectionDialog(QWidget *parent = nullptr);
27 | ~QKxConnectionDialog();
28 | QString serverName() const;
29 | int port() const;
30 | QString password() const;
31 |
32 | void setErrorMessage(const QString& msg);
33 | private slots:
34 | void onButtonConnectClicked();
35 | void onAdjustSize();
36 | private:
37 | Ui::QKxConnectionDialog *ui;
38 | };
39 |
40 | #endif // QKXCONNECTIONDIALOG_H
41 |
--------------------------------------------------------------------------------
/client/qkxvncviewer.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXVNCVIEWER_H
13 | #define QKXVNCVIEWER_H
14 |
15 | #include
16 | #include
17 |
18 | namespace Ui {
19 | class QKxVNCViewer;
20 | }
21 |
22 | class QKxConnectionDialog;
23 | class QKxVncWidget;
24 | class QKxVNCViewer : public QMainWindow
25 | {
26 | Q_OBJECT
27 |
28 | public:
29 | explicit QKxVNCViewer(QWidget *parent = nullptr);
30 | ~QKxVNCViewer();
31 | Q_INVOKABLE void showInput(const QString& msg=QString());
32 | private slots:
33 | void onActionNewConnection();
34 | void onAppStart();
35 |
36 | // vnc
37 | void onVncFinished();
38 | void onVncConnectionStart();
39 | void onVncConnectionFinished(bool noErr);
40 | void onVncErrorArrived(const QByteArray& msg);
41 | void onVncPasswordResult(const QByteArray& msg, bool isSuccess);
42 | private:
43 | void reconnect(const QString& host, int port, const QString& pass, bool viewOnly);
44 | private:
45 | Ui::QKxVNCViewer *ui;
46 | QPointer m_vnc;
47 | QPointer m_dlgConnect;
48 | };
49 |
50 | #endif // QKXVNCVIEWER_H
51 |
--------------------------------------------------------------------------------
/client/qkxvncviewer.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | QKxVNCViewer
4 |
5 |
6 |
7 | 0
8 | 0
9 | 800
10 | 600
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
35 |
36 |
37 |
38 | New Connection
39 |
40 |
41 |
42 |
43 | Loseless mode
44 |
45 |
46 |
47 |
48 | HD mode
49 |
50 |
51 |
52 |
53 | Generic mode
54 |
55 |
56 |
57 |
58 | New Connection
59 |
60 |
61 |
62 |
63 | Stretch
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/client/resource/vncviewer.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/client/resource/vncviewer.ico
--------------------------------------------------------------------------------
/client/version.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define WOVNCVIEWER_VERSION ("3.2.0")
4 |
--------------------------------------------------------------------------------
/client/versioninfo.rc.in:
--------------------------------------------------------------------------------
1 | # if defined(UNDER_CE)
2 | # include
3 | # else
4 | # include
5 | # endif
6 | VS_VERSION_INFO VERSIONINFO
7 | FILEVERSION @BUILD_VERSION_MAJOR@, @BUILD_VERSION_MINOR@, @BUILD_VERSION_PATCH@
8 | PRODUCTVERSION @BUILD_VERSION_MAJOR@, @BUILD_VERSION_MINOR@, @BUILD_VERSION_PATCH@
9 | FILEFLAGSMASK 0x17L
10 | #ifdef _DEBUG
11 | FILEFLAGS 0x1L
12 | #else
13 | FILEFLAGS 0x0L
14 | #endif
15 | FILEOS 0x4L
16 | FILETYPE 0x0L
17 | FILESUBTYPE 0x0L
18 | BEGIN
19 | BLOCK "StringFileInfo"
20 | BEGIN
21 | BLOCK "040904b0"
22 | BEGIN
23 | VALUE "CompanyName", "Guangzhou AoYiDuo Network Technology Co., Ltd"
24 | VALUE "FileDescription", "WoVNCViewer - http://www.wovnc.com"
25 | VALUE "FileVersion", "@BUILD_VERSION_MAJOR@, @BUILD_VERSION_MINOR@, @BUILD_VERSION_PATCH@"
26 | VALUE "InternalName", "WoVNCViewer"
27 | VALUE "LegalCopyright", "Copyright(C)2022 AoYiDuo"
28 | VALUE "OriginalFilename", ""
29 | VALUE "ProductName", "WoVNCViewer"
30 | VALUE "ProductVersion", "@BUILD_VERSION_MAJOR@, @BUILD_VERSION_MINOR@, @BUILD_VERSION_PATCH@"
31 | END
32 | END
33 | BLOCK "VarFileInfo"
34 | BEGIN
35 | VALUE "Translation", 0x409, 1200
36 | END
37 | END
38 |
39 | IDI_ICON1 ICON DISCARDABLE "resource/vncviewer.ico"
--------------------------------------------------------------------------------
/client/vncviewer.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/doc/ftp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/doc/ftp.png
--------------------------------------------------------------------------------
/doc/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/doc/main.png
--------------------------------------------------------------------------------
/doc/vnc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/doc/vnc.png
--------------------------------------------------------------------------------
/kxcap/d3des.h:
--------------------------------------------------------------------------------
1 | #ifndef D3DES_H
2 | #define D3DES_H
3 |
4 | /*
5 | * This is D3DES (V5.09) by Richard Outerbridge with the double and
6 | * triple-length support removed for use in VNC.
7 | *
8 | * These changes are:
9 | * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
10 | *
11 | * This software is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 | */
15 |
16 | /* d3des.h -
17 | *
18 | * Headers and defines for d3des.c
19 | * Graven Imagery, 1992.
20 | *
21 | * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
22 | * (GEnie : OUTER; CIS : [71755,204])
23 | */
24 |
25 | #define EN0 0 /* MODE == encrypt */
26 | #define DE1 1 /* MODE == decrypt */
27 |
28 | extern void rfbDesKey(unsigned char *, int);
29 | /* hexkey[8] MODE
30 | * Sets the internal key register according to the hexadecimal
31 | * key contained in the 8 bytes of hexkey, according to the DES,
32 | * for encryption or decryption according to MODE.
33 | */
34 |
35 | extern void rfbUseKey(unsigned long *);
36 | /* cookedkey[32]
37 | * Loads the internal key register with the data in cookedkey.
38 | */
39 |
40 | extern void rfbCPKey(unsigned long *);
41 | /* cookedkey[32]
42 | * Copies the contents of the internal key register into the storage
43 | * located at &cookedkey[0].
44 | */
45 |
46 | extern void rfbDes(unsigned char *, unsigned char *);
47 | /* from[8] to[8]
48 | * Encrypts/Decrypts (according to the key currently loaded in the
49 | * internal key register) one block of eight bytes at address 'from'
50 | * into the block at address 'to'. They can be the same.
51 | */
52 |
53 | /* d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery
54 | ********************************************************************/
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/kxcap/language/release.bat:
--------------------------------------------------------------------------------
1 | echo "init vc env"
2 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
3 | echo "init qt env"
4 | call "C:\Qt\Qt5.6.3\5.6.3\msvc2013\bin\qtenv2.bat"
5 |
6 | set path_script=%~dp0
7 | echo %path_script%
8 |
9 | cd %path_script%
10 | lrelease %path_script%vncserver_en.ts -qm %path_script%vncserver_en.qm
11 | lrelease %path_script%vncserver_zh.ts -qm %path_script%vncserver_zh.qm
12 | pause
--------------------------------------------------------------------------------
/kxcap/language/update.bat:
--------------------------------------------------------------------------------
1 | echo "init vc env"
2 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
3 | echo "init qt env"
4 | call "C:\Qt\Qt5.6.3\5.6.3\msvc2013\bin\qtenv2.bat"
5 |
6 | set path_script=%~dp0
7 | echo %path_script%
8 |
9 | cd %path_script%
10 | lupdate -recursive %path_script%\..\ -ts %path_script%vncserver_en.ts
11 | lupdate -recursive %path_script%\..\ -ts %path_script%vncserver_zh.ts
12 | pause
--------------------------------------------------------------------------------
/kxcap/language/vncserver_en.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/language/vncserver_en.qm
--------------------------------------------------------------------------------
/kxcap/language/vncserver_zh.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/language/vncserver_zh.qm
--------------------------------------------------------------------------------
/kxcap/objcapi.cpp:
--------------------------------------------------------------------------------
1 | #include "objcapi.h"
2 |
3 | namespace mac {
4 |
5 | nsobj_unique_ptr wrap_string_as_ns_string(const std::string &str) {
6 | constexpr int kNSUTF8StringEncoding = 4;
7 | id ns_string = clscall("NSString", "alloc");
8 | auto *ptr = cast_call(
9 | ns_string,
10 | "initWithBytesNoCopy:length:encoding:freeWhenDone:", str.data(),
11 | str.size(), kNSUTF8StringEncoding, false);
12 | return wrap_as_nsobj_unique_ptr(ptr);
13 | }
14 |
15 | std::string to_string(TI_NSString *ns) {
16 | return cast_call(ns, "UTF8String");
17 | }
18 |
19 | int ns_array_count(TI_NSArray *na) {
20 | return cast_call(na, "count");
21 | }
22 |
23 | void ns_log_object(id obj) {
24 | // https://github.com/halide/Halide/blob/bce3abe95cf3aef36c6eb8dafb8c85c197408b6d/src/runtime/objc_support.h#L88-L92
25 | auto ns_str = wrap_string_as_ns_string("%@");
26 | NSLog(reinterpret_cast(ns_str.get()), obj);
27 | }
28 |
29 | TI_NSAutoreleasePool *create_autorelease_pool() {
30 | return cast_call(
31 | clscall("NSAutoreleasePool", "alloc"), "init");
32 | }
33 |
34 | void drain_autorelease_pool(TI_NSAutoreleasePool *pool) {
35 | // "drain" is same as "release", so we don't need to release |pool| itself.
36 | // https://developer.apple.com/documentation/foundation/nsautoreleasepool
37 | call(pool, "drain");
38 | }
39 |
40 | ScopedAutoreleasePool::ScopedAutoreleasePool() {
41 | pool_ = create_autorelease_pool();
42 | }
43 |
44 | ScopedAutoreleasePool::~ScopedAutoreleasePool() {
45 | drain_autorelease_pool(pool_);
46 | }
47 |
48 | } // namespace mac
49 |
--------------------------------------------------------------------------------
/kxcap/qkxabstractcapture.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxabstractcapture.h"
13 |
14 | #include
15 |
16 | QKxAbstractCapture::QKxAbstractCapture(QObject *parent)
17 | : QObject(parent)
18 | {
19 |
20 | }
21 |
22 | void QKxAbstractCapture::showError(const QString &msg)
23 | {
24 | qDebug() << "showError" << msg;
25 | }
26 |
--------------------------------------------------------------------------------
/kxcap/qkxabstractcapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXABSTRACTCAPTURE_H
13 | #define QKXABSTRACTCAPTURE_H
14 |
15 | #include
16 | #include "qkxcap_private.h"
17 |
18 |
19 | class QKxAbstractCapture : public QObject
20 | {
21 | Q_OBJECT
22 | public:
23 | explicit QKxAbstractCapture(QObject *parent = 0);
24 | virtual void showError(const QString& msg);
25 | virtual int drawFrame(UpdateRequest *req, uchar *pbuf, int bytesPerLine, bool reset) = 0;
26 | };
27 |
28 | #endif // QKXABSTRACTCAPTURE_H
29 |
--------------------------------------------------------------------------------
/kxcap/qkxaudiocapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXAUDIOCAPTURE_H
13 | #define QKXAUDIOCAPTURE_H
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 |
22 | class QKxAudioCapture : public QThread
23 | {
24 | Q_OBJECT
25 | private:
26 | struct MyMsg {
27 | uchar type;
28 | QByteArray data;
29 | };
30 | public:
31 | explicit QKxAudioCapture(QObject *parent = nullptr);
32 | virtual ~QKxAudioCapture();
33 | void stop();
34 | signals:
35 | void result(const QByteArray& buf);
36 | void internalAssemble(const QByteArray& buf);
37 | private slots:
38 | void onRequest(int cnt);
39 | void onInternalAssemble(const QByteArray& buf);
40 | protected:
41 | void push(uchar type, const QByteArray& data = QByteArray());
42 | bool pop(uchar &type, QByteArray& data);
43 | bool takeOne(uchar type, QByteArray& data);
44 | void popAll();
45 | void run();
46 | bool init();
47 | protected:
48 | virtual int running();
49 | virtual int findDefaultLoopbackDevice() = 0;
50 | protected:
51 | QList m_queue;
52 | QMutex m_mtx;
53 | int m_msgRead;
54 | int m_msgWrite;
55 |
56 | qint64 m_timeLast;
57 | };
58 |
59 | #endif // QKXAUDIOCAPTURE_H
60 |
--------------------------------------------------------------------------------
/kxcap/qkxaudiostream.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXAUDIOSTREAM_H
13 | #define QKXAUDIOSTREAM_H
14 |
15 | #include
16 | #include
17 |
18 | class QKxAudioStreamPrivate;
19 | class QKxAudioStream : public QObject
20 | {
21 | Q_OBJECT
22 | public:
23 | explicit QKxAudioStream(QObject *parent = nullptr);
24 | ~QKxAudioStream();
25 | static void initialize();
26 | static void terminate();
27 | bool init(int idx, int sampleRate, int channel, int framesPerBuffer, std::function cb);
28 | bool start();
29 | void close();
30 | private:
31 | QKxAudioStreamPrivate *m_prv;
32 | };
33 |
34 | #endif // QKXAUDIOSTREAM_H
35 |
--------------------------------------------------------------------------------
/kxcap/qkxcap.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxcap.h"
13 |
14 | QKxCap::QKxCap(QObject *parent)
15 | : QObject(parent)
16 | {
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/kxcap/qkxcap.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCAP_H
13 | #define QKXCAP_H
14 |
15 | #include "qkxcap_share.h"
16 |
17 | #include
18 |
19 | class KXCAP_EXPORT QKxCap : public QObject
20 | {
21 | Q_OBJECT
22 | public:
23 | explicit QKxCap(QObject *parent = nullptr);
24 |
25 | signals:
26 |
27 | public slots:
28 | };
29 |
30 | #endif // QKXCAP_H
31 |
--------------------------------------------------------------------------------
/kxcap/qkxcap_share.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCAP_SHARE_H
13 | #define QKXCAP_SHARE_H
14 |
15 | #if defined(KXCAP_LIBRARY)
16 | # define KXCAP_EXPORT Q_DECL_EXPORT
17 | #else
18 | # define KXCAP_EXPORT Q_DECL_IMPORT
19 | #endif
20 |
21 | class QGuiApplication;
22 | typedef void (*PFunInit)(QGuiApplication *app);
23 |
24 | #define SERVICE_COMMAND_CODE_EXIT (0x1)
25 | #define SERVICE_COMMAND_CODE_START (0x2)
26 | #define SERVICE_COMMAND_CODE_STOP (0x3)
27 |
28 | #endif // QKXCAP_SHARE_H
29 |
--------------------------------------------------------------------------------
/kxcap/qkxcapoption.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCAPOPTION_H
13 | #define QKXCAPOPTION_H
14 |
15 | #include "qkxcap_share.h"
16 |
17 | #include
18 | #include
19 |
20 | class QKxCapOptionPrivate;
21 | class KXCAP_EXPORT QKxCapOption : public QObject
22 | {
23 | Q_OBJECT
24 | public:
25 | explicit QKxCapOption(QObject *parent = nullptr);
26 | virtual ~QKxCapOption();
27 | static QKxCapOption *instance();
28 | int screenIndex() const;
29 | void setScreenIndex(int idx);
30 | QString authorizePassword() const;
31 | void setAuthorizePassword(const QString& pwd);
32 | int maxFPS() const;
33 | void setMaxFPS(int fps);
34 | bool enableEmptyFrame();
35 | void setEmptyFrameEnable(bool ok);
36 | void setServerUrl(const QString& url);
37 | QString serverUrl() const;
38 | QString serverUrlNodePath() const;
39 | QMap all() const;
40 |
41 | bool autoLockScreen() const;
42 | void setAutoLockScreen(bool on);
43 |
44 | bool dragWithContent() const;
45 | void setDragWithContent(bool on);
46 |
47 | bool blackWallpaper();
48 | void setBlackWallpaper(bool on);
49 | private:
50 | QKxCapOptionPrivate *m_prv;
51 | };
52 |
53 | #endif // QKXCAPOPTION_H
54 |
--------------------------------------------------------------------------------
/kxcap/qkxcapserver.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCAPSERVER_H
13 | #define QKXCAPSERVER_H
14 |
15 | #include "qkxcap_share.h"
16 |
17 | #include
18 | #include
19 | #include
20 |
21 | class QCoreApplication;
22 | class QKxCapOption;
23 | class QKxCapServerPrivate;
24 |
25 | class KXCAP_EXPORT QKxCapServer : public QObject
26 | {
27 | Q_OBJECT
28 | public:
29 | explicit QKxCapServer(const QString& envName, const QString& host, quint16 port, QObject *parent = nullptr);
30 | ~QKxCapServer();
31 | quint16 listenPort();
32 |
33 | Q_INVOKABLE void test();
34 |
35 | // same as QKxCapOption::instance();
36 | static QKxCapOption *option();
37 | static bool isRunAsService();
38 | // for window service
39 | static void ExitWithParentProcess(QCoreApplication *app);
40 | // vnc module.
41 | static int VncMain(int argc, char *argv[], PFunInit fn);
42 | // install service.
43 | static int InstallMain(int argc, char *argv[], const QByteArray &serviceName);
44 | // uninstall service
45 | static int UninstallMain(int argc, char *argv[], const QByteArray &serviceName);
46 | private slots:
47 | void onAboutToQuit();
48 | private:
49 | QPointer m_prv;
50 | };
51 |
52 | #endif // QKXCAPSERVER_H
53 |
--------------------------------------------------------------------------------
/kxcap/qkxcapserverprivate.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxcapserverprivate.h"
13 | #include "qkxcapoption.h"
14 | #include "qkxtcpvncserver.h"
15 |
16 | #include
17 | #include
18 | #include
19 |
20 | QKxCapServerPrivate::QKxCapServerPrivate(const QString& envName, const QString &host, quint16 port)
21 | : QObject(nullptr)
22 | , m_bClose(false)
23 | , m_envName(envName)
24 | , m_port(0)
25 | {
26 | m_worker = new QThread(nullptr);
27 | moveToThread(m_worker);
28 | m_worker->start();
29 | QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection, Q_ARG(QString, host), Q_ARG(quint16, port));
30 |
31 | QMutexLocker lk(&m_mtx);
32 | m_wait.wait(&m_mtx);
33 | }
34 |
35 | QKxCapServerPrivate::~QKxCapServerPrivate()
36 | {
37 | QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection);
38 | m_worker->wait();
39 | delete m_worker;
40 | }
41 |
42 | quint16 QKxCapServerPrivate::listenPort()
43 | {
44 | return m_port;
45 | }
46 |
47 | void QKxCapServerPrivate::init(const QString &host, quint16 port)
48 | {
49 | m_server = new QKxTcpVNCServer(this);
50 | port = m_server->start(host, port);
51 | QString vncServer;
52 | if(port > 0) {
53 | vncServer = QString("tcp:%1:%2").arg(host).arg(port);
54 | m_port = port;
55 | }
56 | updateServerUrl(vncServer);
57 | m_wait.wakeAll();
58 | }
59 |
60 | void QKxCapServerPrivate::close()
61 | {
62 | if(m_server) {
63 | m_server->stop();
64 | delete m_server;
65 | }
66 | updateServerUrl("");
67 | m_worker->quit();
68 | }
69 |
70 | void QKxCapServerPrivate::updateServerUrl(const QString &name)
71 | {
72 | QByteArray envName = m_envName.toUtf8();
73 | qputenv(envName, name.toUtf8());
74 | QKxCapOption::instance()->setServerUrl(name);
75 | }
76 |
--------------------------------------------------------------------------------
/kxcap/qkxcapserverprivate.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCAPSERVERPRIVATE_H
13 | #define QKXCAPSERVERPRIVATE_H
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | class QThread;
22 | class QKxTcpVNCServer;
23 | class QKxCapServerPrivate : public QObject
24 | {
25 | Q_OBJECT
26 | public:
27 | explicit QKxCapServerPrivate(const QString& envName, const QString &host, quint16 port);
28 | virtual ~QKxCapServerPrivate();
29 | quint16 listenPort();
30 | private:
31 | // port: 0 will auto assign port by os system and new port will be return value.
32 | Q_INVOKABLE void init(const QString &host, quint16 port = 0);
33 | Q_INVOKABLE void close();
34 | void updateServerUrl(const QString& name);
35 | signals:
36 |
37 | public slots:
38 | protected:
39 | QPointer m_worker;
40 | QPointer m_server;
41 | QString m_envName;
42 | bool m_bClose;
43 |
44 | quint16 m_port;
45 |
46 | QWaitCondition m_wait;
47 | QMutex m_mtx;
48 | };
49 |
50 | #endif // QKXCAPSERVERPRIVATE_H
51 |
--------------------------------------------------------------------------------
/kxcap/qkxcapserverunixprivate.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxcapserverunixprivate.h"
13 | #include "qkxcap_private.h"
14 | #include "qkxtcpvncserver.h"
15 | #include "qkxcapoption.h"
16 | #include "qkxvncserverpeer.h"
17 | #include "qkxutils.h"
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | QKxCapServerUnixPrivate::QKxCapServerUnixPrivate(const QString& envName, const QString &host, quint16 port)
27 | : QKxCapServerPrivate(envName, host, port)
28 | {
29 |
30 | }
31 |
32 | int QKxCapServerUnixPrivate::VncMain(int argc, char *argv[], PFunInit fn)
33 | {
34 | QApplication app(argc, argv);
35 |
36 | fn(&app);
37 |
38 | QKxUtils::setVisibleOnDock(false);
39 |
40 | QKxVNCServerPeer peer(&app);
41 | QObject::connect(&peer, SIGNAL(errorArrived(int)), &app, SLOT(quit()));
42 | return app.exec();
43 | }
44 |
45 | int QKxCapServerUnixPrivate::InstallMain(int argc, char *argv[], const QByteArray &serviceName)
46 | {
47 | //
48 | throw "do not need to impletement";
49 | return 0;
50 | }
51 |
52 | int QKxCapServerUnixPrivate::UninstallMain(int argc, char *argv[], const QByteArray &serviceName)
53 | {
54 | // do not need to impletement
55 | throw "do not need to impletement";
56 | return 0;
57 | }
58 |
--------------------------------------------------------------------------------
/kxcap/qkxcapserverunixprivate.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCAPSERVERUNIXPRIVATE_H
13 | #define QKXCAPSERVERUNIXPRIVATE_H
14 |
15 | #include "qkxcap_share.h"
16 | #include "qkxcapserverprivate.h"
17 |
18 | #include
19 |
20 | class QKxTcpVNCServer;
21 | class QKxShareMemory;
22 | class QKxCapServerUnixPrivate : public QKxCapServerPrivate
23 | {
24 | Q_OBJECT
25 | public:
26 | explicit QKxCapServerUnixPrivate(const QString& envName, const QString &host, quint16 port);
27 |
28 | // vnc module.
29 | static int VncMain(int argc, char *argv[], PFunInit fn);
30 | // install service.
31 | static int InstallMain(int argc, char *argv[], const QByteArray &serviceName);
32 | // uninstall service.
33 | static int UninstallMain(int argc, char *argv[], const QByteArray &serviceName);
34 | };
35 |
36 | #endif // QKXCAPSERVERUNIXPRIVATE_H
37 |
--------------------------------------------------------------------------------
/kxcap/qkxcapserverwindowprivate.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCAPSERVERWINDOWPRIVATE_H
13 | #define QKXCAPSERVERWINDOWPRIVATE_H
14 |
15 | #include "qkxcap_share.h"
16 | #include "qkxcapserverprivate.h"
17 |
18 | #include
19 | #include
20 |
21 | class QKxTcpVNCServer;
22 | class QKxCapServerWindowPrivate : public QKxCapServerPrivate
23 | {
24 | Q_OBJECT
25 | public:
26 | explicit QKxCapServerWindowPrivate(const QString& envName, const QString &host, quint16 port);
27 |
28 | // vnc module.
29 | static int VncMain(int argc, char *argv[], PFunInit fn);
30 | // install service.
31 | static int InstallMain(int argc, char *argv[], const QByteArray &serviceName);
32 | // uninstall service.
33 | static int UninstallMain(int argc, char *argv[], const QByteArray &serviceName);
34 | };
35 |
36 | #endif // QKXCAPSERVERWINDOWPRIVATE_H
37 |
--------------------------------------------------------------------------------
/kxcap/qkxclipboard.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxclipboard.h"
13 |
14 | #include
15 | #include
16 |
17 | QKxClipboard::QKxClipboard(QObject *parent)
18 | : QObject(parent)
19 | {
20 |
21 | }
22 |
23 | QString QKxClipboard::text() const
24 | {
25 | return QString();
26 | }
27 |
28 | void QKxClipboard::setText(const QString &txt)
29 | {
30 | QClipboard *clip = QGuiApplication::clipboard();
31 | QString clipTxt = clip->text();
32 | if(clipTxt != txt){
33 | clip->setText(txt);
34 | }
35 | }
36 |
37 | void QKxClipboard::queryForAppNap()
38 | {
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/kxcap/qkxclipboard.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCLIPBOARD_H
13 | #define QKXCLIPBOARD_H
14 |
15 | #include
16 |
17 | class QKxClipboard : public QObject
18 | {
19 | Q_OBJECT
20 | public:
21 | explicit QKxClipboard(QObject *parent = nullptr);
22 | virtual QString text() const;
23 | virtual void setText(const QString& txt);
24 | virtual void queryForAppNap();
25 | signals:
26 | void dataChanged();
27 | };
28 |
29 | #endif // QKXCLIPBOARD_H
30 |
--------------------------------------------------------------------------------
/kxcap/qkxdaemonmaster.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxdaemonmaster.h"
13 |
14 | #include
15 | #include
16 | #include
17 |
18 | QKxDaemonMaster::QKxDaemonMaster(const QString& name, QObject *parent)
19 | : QObject(parent)
20 | , m_name(name)
21 | {
22 | m_master = new QLocalServer(this);
23 | m_master->setSocketOptions(QLocalServer::WorldAccessOption);
24 | QObject::connect(m_master, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
25 | QLocalServer::removeServer(name);
26 | if(!m_master->listen(name)){
27 | qWarning() << "QLocalServer" << name << m_master->errorString();
28 | }
29 | }
30 |
31 | QKxDaemonMaster::~QKxDaemonMaster()
32 | {
33 | }
34 |
35 | void QKxDaemonMaster::activeSlave()
36 | {
37 | for(int i = 0; i < m_slaves.length(); i++) {
38 | QLocalSocket *slave = m_slaves.at(i);
39 | if(slave) {
40 | slave->write("activateArrived");
41 | }
42 | }
43 | }
44 |
45 | void QKxDaemonMaster::onNewConnection()
46 | {
47 | while(m_master->hasPendingConnections()) {
48 | QLocalSocket *slave = m_master->nextPendingConnection();
49 | QObject::connect(slave, &QLocalSocket::disconnected, this, &QKxDaemonMaster::onDisconnected);
50 | QObject::connect(slave, &QLocalSocket::readyRead, this, &QKxDaemonMaster::onReadyRead);
51 | m_slaves.append(slave);
52 | }
53 | }
54 |
55 | void QKxDaemonMaster::onDisconnected()
56 | {
57 | QLocalSocket *slave = qobject_cast(sender());
58 | slave->deleteLater();
59 | m_slaves.removeAll(slave);
60 | }
61 |
62 | void QKxDaemonMaster::onReadyRead()
63 | {
64 | QLocalSocket *slave = qobject_cast(sender());
65 | QByteArray buf = slave->readAll();
66 | }
67 |
--------------------------------------------------------------------------------
/kxcap/qkxdaemonmaster.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXDAEMONMASTER_H
13 | #define QKXDAEMONMASTER_H
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | class QLocalServer;
20 | class QLocalSocket;
21 | class QKxDaemonMaster : public QObject
22 | {
23 | Q_OBJECT
24 | public:
25 | explicit QKxDaemonMaster(const QString& name, QObject *parent = 0);
26 | virtual ~QKxDaemonMaster();
27 | void activeSlave();
28 | signals:
29 |
30 | public slots:
31 | void onNewConnection();
32 | void onDisconnected();
33 | void onReadyRead();
34 | private:
35 | QString m_name;
36 | QPointer m_master; // only for check master is exist or not.
37 | QList> m_slaves;
38 | };
39 |
40 | #endif // QKXDAEMONMASTER_H
41 |
--------------------------------------------------------------------------------
/kxcap/qkxdaemonslave.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxdaemonslave.h"
13 |
14 | #include
15 | #include
16 | #include
17 |
18 | QKxDaemonSlave::QKxDaemonSlave(const QString& name, QObject *parent)
19 | : QObject(parent)
20 | , m_name(name)
21 | , m_count(0)
22 | {
23 | m_slave = new QLocalSocket(this);
24 | m_slave->connectToServer(m_name);
25 | QObject::connect(m_slave, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
26 | QObject::connect(m_slave, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
27 | bool ok = QObject::connect(m_slave, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(onError()));
28 | bool ok2 = QObject::connect(m_slave, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)), this, SLOT(onStateChagned()));
29 | m_tick = new QTimer(this);
30 | QObject::connect(m_tick, SIGNAL(timeout()), this, SLOT(onTick()));
31 | m_tick->start(10 * 1000);
32 | }
33 |
34 | void QKxDaemonSlave::onDisconnected()
35 | {
36 | qDebug() << "QKxDaemonSlave::onDisconnected";
37 | emit quitArrived();
38 | }
39 |
40 | void QKxDaemonSlave::onReadyRead()
41 | {
42 | QByteArray cmd = m_slave->readAll();
43 | if(cmd == "activateArrived") {
44 | QMetaObject::invokeMethod(this, cmd, Qt::QueuedConnection);
45 | }
46 | }
47 |
48 | void QKxDaemonSlave::onError()
49 | {
50 | qDebug() << "QKxDaemonSlave::onError";
51 | emit quitArrived();
52 | }
53 |
54 | void QKxDaemonSlave::onStateChagned()
55 | {
56 | qDebug() << "stateChanged";
57 | }
58 |
59 | void QKxDaemonSlave::onTick()
60 | {
61 | if(!m_slave->isOpen()) {
62 | qDebug() << "QKxDaemonSlave::onTick";
63 | emit quitArrived();
64 | return;
65 | }
66 | m_slave->write("hello");
67 | }
68 |
--------------------------------------------------------------------------------
/kxcap/qkxdaemonslave.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXDAEMONSLAVE_H
13 | #define QKXDAEMONSLAVE_H
14 |
15 | #include
16 | #include
17 |
18 | class QTimer;
19 | class QLocalSocket;
20 | class QKxDaemonSlave : public QObject
21 | {
22 | Q_OBJECT
23 | public:
24 | explicit QKxDaemonSlave(const QString& name, QObject *parent = 0);
25 |
26 | signals:
27 | void activateArrived();
28 | void quitArrived();
29 | public slots:
30 | void onDisconnected();
31 | void onReadyRead();
32 | void onError();
33 | void onStateChagned();
34 | void onTick();
35 | private:
36 | QPointer m_slave;
37 | QPointer m_tick;
38 | QString m_name;
39 | int m_count;
40 | };
41 |
42 | #endif // QKXDAEMONSLAVE_H
43 |
--------------------------------------------------------------------------------
/kxcap/qkxdirtyframe.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXDIRTYFRAME_H
13 | #define QKXDIRTYFRAME_H
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 |
20 | class QKxDirtyFrame : public QObject
21 | {
22 | public:
23 | explicit QKxDirtyFrame(int width, int height, QObject *parent = nullptr);
24 | void setJpegDetectThreshold(int scoreLess);
25 | bool findDirtyRect(uchar *dataLastFrame, int stepLastFrame, uchar *dataFrame, int stepFrame);
26 | QList dirtyRects();
27 | bool jpegPreffer(uchar *pbits, int step, int idxRt);
28 | bool h264Preffer(uchar *pbits, int step, int idxRt);
29 | private:
30 | void mergeRect(QList& dirtyRt, const QRect &rt);
31 | int checkRoughness(QVector &pts, int pixelCount);
32 | void detectImageSmooth(uchar *pbits, int bytesPerline, int bsize, int x, int y, int width, int height, QVector &pts);
33 | private:
34 | struct DirtyFrame {
35 | QVector block; // dirty block
36 | QRect blockRt; // block dirty bound rect
37 |
38 | QList dirtyRt; // dirty Rect.
39 | QRect boundRt; // image dirty bound rect
40 |
41 | int score; // dirty level score, [0,100]
42 | int roughness; // dirty area roughness level.
43 | qint64 time; //dirty timestamp, [0, ~]
44 | };
45 | QList m_frames;
46 | int m_width, m_height;
47 | int m_ncol, m_nrow;
48 | int m_timeLast;
49 | int m_jpegThreshold;
50 | int m_jpegPrefferCount;
51 | };
52 |
53 | #endif // QKXDIRTYFRAME_H
54 |
--------------------------------------------------------------------------------
/kxcap/qkxdxgicapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXDXGICAPTURE_H
13 | #define QKXDXGICAPTURE_H
14 |
15 | #include "qkxcap_private.h"
16 |
17 | #include
18 | #include
19 | #include "qkxabstractcapture.h"
20 |
21 | class DXGICapturePrivate;
22 | class QKxDXGICapture : public QKxAbstractCapture
23 | {
24 | Q_OBJECT
25 | public:
26 | explicit QKxDXGICapture(int idx, const QRect& imageRt, const QRect& screenRt, QObject *parent=nullptr);
27 | virtual ~QKxDXGICapture();
28 | bool init();
29 | int getFrame();
30 | int drawFrame(UpdateRequest *req, uchar *pbuf, int bytesPerLine, bool reset);
31 | void releaseFrame();
32 | private:
33 | DXGICapturePrivate *m_prv;
34 | QRect m_imageRt;
35 | int m_idx;
36 | };
37 |
38 | #endif // QKXDXGICAPTURE_H
39 |
--------------------------------------------------------------------------------
/kxcap/qkxdxgiscreencapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXDXGISCREENCAPTURE_H
13 | #define QKXDXGISCREENCAPTURE_H
14 |
15 | #include "qkxscreencapture.h"
16 |
17 | class QKxDXGIScreenCapture : public QKxScreenCapture
18 | {
19 | Q_OBJECT
20 | public:
21 | explicit QKxDXGIScreenCapture(int screenIndex, const QRect& rt, const QRect& imgRt, QObject *parent = nullptr);
22 | protected:
23 | virtual int running();
24 | };
25 |
26 | #endif // QKXDXGISCREENCAPTURE_H
27 |
--------------------------------------------------------------------------------
/kxcap/qkxftpworker.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxftpworker.h"
13 | #include "qkxftpresponse.h"
14 |
15 | #include
16 |
17 | QKxFtpWorker::QKxFtpWorker(QObject *parent)
18 | : QObject(parent)
19 | {
20 | m_ftp = new QKxFtpResponse(this);
21 | QObject::connect(m_ftp, SIGNAL(result(QByteArray)), this, SIGNAL(result(QByteArray)));
22 | }
23 |
24 | QKxFtpWorker::~QKxFtpWorker()
25 | {
26 |
27 | }
28 |
29 | void QKxFtpWorker::onPacket(const QByteArray &buf)
30 | {
31 | qDebug() << "onPacket" << buf.length();
32 | m_ftp->handlePacket(buf);
33 | }
34 |
--------------------------------------------------------------------------------
/kxcap/qkxftpworker.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTPWORKER_H
13 | #define QKXFTPWORKER_H
14 |
15 | #include
16 | #include
17 |
18 | class QKxFtpResponse;
19 | class QKxLengthBodyPacket;
20 | class QKxFtpWorker : public QObject
21 | {
22 | Q_OBJECT
23 | public:
24 | explicit QKxFtpWorker(QObject *parent = nullptr);
25 | ~QKxFtpWorker();
26 | signals:
27 | void result(const QByteArray& buf);
28 | private slots:
29 | void onPacket(const QByteArray& buf);
30 | private:
31 | QPointer m_ftp;
32 | };
33 |
34 | #endif // QKXFTPWORKER_H
35 |
--------------------------------------------------------------------------------
/kxcap/qkxgdicapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXGDICAPTURE_H
13 | #define QKXGDICAPTURE_H
14 |
15 | #include "qkxcap_private.h"
16 | #include "qkxabstractcapture.h"
17 |
18 | class GDICapturePrivate;
19 | class QKxPrivacyScreen;
20 | class QKxGDICapture : public QKxAbstractCapture
21 | {
22 | public:
23 | explicit QKxGDICapture(int idx, const QRect& imageRt, const QRect& screenRt, QKxPrivacyScreen* prvScreen, QObject *parent = nullptr);
24 | virtual ~QKxGDICapture();
25 | bool reset();
26 | int getFrame();
27 | int drawFrame(UpdateRequest *req, uchar *pbuf, int bytesPerLine, bool reset);
28 | private:
29 | GDICapturePrivate *m_prv;
30 | QRect m_imageRt;
31 | int m_idx;
32 | };
33 |
34 | #endif // QKXGDICAPTURE_H
35 |
--------------------------------------------------------------------------------
/kxcap/qkxgdiscreencapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXGDISCREENCAPTURE_H
13 | #define QKXGDISCREENCAPTURE_H
14 |
15 | #include "qkxscreencapture.h"
16 |
17 | class QKxGDICapture;
18 | class QKxGDIScreenCapture : public QKxScreenCapture
19 | {
20 | public:
21 | explicit QKxGDIScreenCapture(int screenIndex, const QRect& rt, const QRect& imgRt, QObject *parent = nullptr);
22 | private:
23 | virtual int running();
24 | };
25 |
26 | #endif // QKXGDISCREENCAPTURE_H
27 |
--------------------------------------------------------------------------------
/kxcap/qkxh264encoder.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXH264ENCODER_H
13 | #define QKXH264ENCODER_H
14 |
15 | #include
16 |
17 | class QKxH264EncoderPrivate;
18 | class QKxH264Encoder : public QObject
19 | {
20 | Q_OBJECT
21 | public:
22 | explicit QKxH264Encoder(QObject *parent = nullptr);
23 | ~QKxH264Encoder();
24 | bool init(int width, int height, bool isCamera);
25 | void setQualityLevel(int lv);
26 | int encode(QDataStream &ds, uchar *src);
27 | private:
28 | QKxH264EncoderPrivate *m_prv;
29 | };
30 |
31 | #endif // QKXH264ENCODER_H
32 |
--------------------------------------------------------------------------------
/kxcap/qkxjpegencoder.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXJPEGENCODER_H
13 | #define QKXJPEGENCODER_H
14 |
15 | #include
16 | #include
17 |
18 | class QKxJpegEncoderPrivate;
19 | class QKxJpegEncoder : public QObject
20 | {
21 | Q_OBJECT
22 | public:
23 | explicit QKxJpegEncoder(QObject *parent = nullptr);
24 | ~QKxJpegEncoder();
25 | void setQualityLevel(int lv);
26 | bool encode(QDataStream &ds, uchar *src, int bytesPerLine, int width, int height, int quality);
27 | private:
28 | QKxJpegEncoderPrivate *m_prv;
29 | };
30 |
31 | #endif // QKXJPEGENCODER_H
32 |
--------------------------------------------------------------------------------
/kxcap/qkxlocalvncserver.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXLOCALVNCSERVER_H
13 | #define QKXLOCALVNCSERVER_H
14 |
15 | #include "qkxcap_share.h"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | class QLocalServer;
23 | class QLocalSocket;
24 | class QIODevice;
25 | class QKxShareMemory;
26 | class QProcess;
27 |
28 | /***
29 | * do not use this class, because the performance is worse than tcp.
30 | * http://www.kxtry.com/archives/3432
31 | *
32 | * do not use it.
33 | * do not use it.
34 | * do not use it.
35 | */
36 |
37 | class QKxLocalVNCServer : public QObject
38 | {
39 | Q_OBJECT
40 | public:
41 | explicit QKxLocalVNCServer(QObject *parent = 0);
42 | virtual ~QKxLocalVNCServer();
43 | bool start(const QString& name);
44 | int screenIndex();
45 | void setScreenIndex(int idx);
46 | QString authorizePassword();
47 | void setAuthorizePassword(const QString& pwd);
48 | int maxFPS() const;
49 | void setMaxFPS(int fps);
50 | void setEmptyFrameEnable(bool ok);
51 | void stop();
52 | signals:
53 |
54 | public slots:
55 | void onOpenNewConnection();
56 | void onLocalNewConnection();
57 | void onOpenDisconnected();
58 | void onLocalDisconnected();
59 | void onReadyRead();
60 | void onAboutToQuit();
61 | void onScreenChanged();
62 | void onVncProcessFinish();
63 | private:
64 | void createPeer(bool bInner);
65 | void stopAllClient();
66 | private:
67 | QPointer m_openServer;
68 | QPointer m_localServer;
69 | QMap, QPointer > m_pairs;
70 | QList > m_ready;
71 | QList > m_vncs;
72 | };
73 |
74 | #endif // QKXLOCALVNCSERVER_H
75 |
--------------------------------------------------------------------------------
/kxcap/qkxmaccapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXMACCAPTURE_H
13 | #define QKXMACCAPTURE_H
14 |
15 | #include "qkxabstractcapture.h"
16 |
17 | class MacCapturePrivate;
18 | class QKxMacCapture : public QKxAbstractCapture
19 | {
20 | public:
21 | explicit QKxMacCapture(int idx, const QRect& imageRt, const QRect& screenRt, QObject *parent = nullptr);
22 | virtual ~QKxMacCapture();
23 | bool reset();
24 | int getFrame();
25 | int drawFrame(UpdateRequest *req, uchar *pbuf, int bytesPerLine, bool reset);
26 | private:
27 | MacCapturePrivate *m_prv;
28 | QRect m_imageRt;
29 | int m_idx;
30 | };
31 |
32 | #endif // QKXMACCAPTURE_H
33 |
--------------------------------------------------------------------------------
/kxcap/qkxmacclipboard.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXMACCLIPBOARD_H
13 | #define QKXMACCLIPBOARD_H
14 |
15 | #include "qkxclipboard.h"
16 |
17 | #include
18 | #include
19 |
20 | class QKxMacClipboard : public QKxClipboard
21 | {
22 | Q_OBJECT
23 | public:
24 | explicit QKxMacClipboard(QObject *parent = nullptr);
25 | ~QKxMacClipboard();
26 | protected:
27 | virtual QString text() const;
28 | virtual void queryForAppNap();
29 | private slots:
30 | void onTimeout();
31 | private:
32 | void copyFromClipboard();
33 | private:
34 | QPointer m_timer;
35 | int m_countLast;
36 | QString m_plainText;
37 | qint64 m_tmLast;
38 | };
39 |
40 | #endif // QKXMACCLIPBOARD_H
41 |
--------------------------------------------------------------------------------
/kxcap/qkxmacclipboard.mm:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxmacclipboard.h"
13 | #include "qkxmactimer.h"
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #include
22 | #include
23 |
24 | QKxMacClipboard::QKxMacClipboard(QObject *parent)
25 | : QKxClipboard(parent)
26 | {
27 | QTimer *timer = new QTimer(this);
28 | m_timer = timer;
29 | QObject::connect(timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
30 | timer->setInterval(250);
31 | timer->start();
32 |
33 | m_tmLast = QDateTime::currentMSecsSinceEpoch();
34 | }
35 |
36 | QKxMacClipboard::~QKxMacClipboard()
37 | {
38 |
39 | }
40 |
41 | QString QKxMacClipboard::text() const
42 | {
43 | return m_plainText;
44 | }
45 |
46 | void QKxMacClipboard::queryForAppNap()
47 | {
48 | qint64 now = QDateTime::currentMSecsSinceEpoch();
49 | int ms = m_timer->interval();
50 | if(now - m_tmLast > ms) {
51 | copyFromClipboard();
52 | m_tmLast = now;
53 | }
54 | }
55 |
56 | void QKxMacClipboard::onTimeout()
57 | {
58 | copyFromClipboard();
59 | m_tmLast = QDateTime::currentMSecsSinceEpoch();
60 | }
61 |
62 | void QKxMacClipboard::copyFromClipboard()
63 | {
64 | NSPasteboard *pb = [NSPasteboard generalPasteboard];
65 | NSInteger newCount = [pb changeCount];
66 | if (newCount != m_countLast) {
67 | m_countLast = newCount;
68 | NSString *text = [pb stringForType:NSPasteboardTypeString];
69 | if (text){
70 | m_plainText = QString::fromNSString(text);
71 | }
72 | //qDebug() << "copyFromClipboard" << m_plainText;
73 | emit dataChanged();
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/kxcap/qkxmacscreencapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXMACSCREENCAPTURE_H
13 | #define QKXMACSCREENCAPTURE_H
14 |
15 | #include "qkxscreencapture.h"
16 |
17 | class QKxMacScreenCapture : public QKxScreenCapture
18 | {
19 | public:
20 | public:
21 | explicit QKxMacScreenCapture(int screenIndex, const QRect& rt, const QRect& imgRt, QObject *parent = nullptr);
22 | private:
23 | virtual int running();
24 | };
25 |
26 | #endif // QKXMACSCREENCAPTURE_H
27 |
--------------------------------------------------------------------------------
/kxcap/qkxmacsendinput.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXMACSENDINPUT_H
13 | #define QKXMACSENDINPUT_H
14 |
15 | #include "qkxsendinput.h"
16 |
17 | class MacSendInputPrivate;
18 | class QKxMacSendInput : public QKxSendInput
19 | {
20 | Q_OBJECT
21 | public:
22 | explicit QKxMacSendInput(const QRect& capRt, const QRect& deskRt, QObject *parent=nullptr);
23 | virtual ~QKxMacSendInput();
24 | protected:
25 | void handleMouseEvent(quint8 button, quint16 x, quint16 y);
26 | void handleKeyEvent(quint8 down, quint32 key);
27 | private:
28 | MacSendInputPrivate *m_prv;
29 | };
30 |
31 | #endif // QKXMACSENDINPUT_H
32 |
--------------------------------------------------------------------------------
/kxcap/qkxopusencoder.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXOPUSENCODER_H
13 | #define QKXOPUSENCODER_H
14 |
15 | #include
16 | #include
17 |
18 | class QKxOpusEncoderPrivate;
19 | class QKxOpusEncoder : public QObject
20 | {
21 | Q_OBJECT
22 | public:
23 | explicit QKxOpusEncoder(QObject *parent = nullptr);
24 | ~QKxOpusEncoder();
25 | bool init(int sampleRate, int channelCount);
26 | int process(char *pcm, int bytesTotal);
27 | int result(QDataStream& ds);
28 | private:
29 | QKxOpusEncoderPrivate *m_prv;
30 | };
31 |
32 | #endif // QKXOPUSENCODER_H
33 |
--------------------------------------------------------------------------------
/kxcap/qkxprivacyscreen.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxprivacyscreen.h"
13 |
14 | #include
15 |
16 | QKxPrivacyScreen::QKxPrivacyScreen(QObject *parent)
17 | : QObject(parent)
18 | {
19 | }
20 |
21 | QKxPrivacyScreen::~QKxPrivacyScreen()
22 | {
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/kxcap/qkxprivacyscreen.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXPRIVACYSCREEN_H
13 | #define QKXPRIVACYSCREEN_H
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | class QKxPrivacyScreen : public QObject
20 | {
21 | Q_OBJECT
22 | public:
23 | explicit QKxPrivacyScreen(QObject *parent = nullptr);
24 | ~QKxPrivacyScreen();
25 | virtual bool isVisible() = 0;
26 | virtual void setVisible(bool on) = 0;
27 | virtual bool snapshot(int idx, uchar *pbuf, int bytesPerline, int width, int height) const = 0;
28 | signals:
29 | void deactivedArrived();
30 | };
31 |
32 | #endif // QKXPRIVACYSCREEN_H
33 |
--------------------------------------------------------------------------------
/kxcap/qkxresample.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXRESAMPLE_H
13 | #define QKXRESAMPLE_H
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | class QKxResample : public QObject
20 | {
21 | public:
22 | explicit QKxResample(QObject *parent = nullptr);
23 | ~QKxResample();
24 | void init(int dsb_channel, int dsb_sampleRate, int dsb_sampleBits, int dst_channel, int dst_sampleRate, int dst_sampleBits);
25 | void process(const char* pcm, int cnt);
26 | int popSamples(char *buf, int nsample);
27 | QByteArray popAll();
28 | private:
29 | /*The principle of algorithmic implementation is: the number of data pushed here is the number of data extracted.*/
30 | void pushSamples(const char* buf, int nsample);
31 |
32 | void startResample(int srcSampleRate, int dstSampleRate);
33 | void runResample(const char *buf, int length);
34 | int writeSamples(const char *buf, int nSample, int nChannel, int nSampleBit);
35 | void stopResample();
36 | private:
37 | int m_dsb_channel;// Collected information.
38 | int m_dsb_sampleRate;
39 | int m_dsb_sampleBits;//8,16,32
40 |
41 | int m_dst_channel;// The number of target audio to be converted.
42 | int m_dst_sampleRate;
43 | int m_dst_sampleBits;
44 |
45 | std::string m_output_buffer;// Store audio data conforming to DST requirements.
46 |
47 | std::string m_cache_src;
48 | std::string m_cache_dst;
49 |
50 | /*resample*/
51 | std::string m_resample_srcpcm; // The collected data has not been converted.
52 | std::string m_resample_dstpcm; // The converted OK.
53 | std::string m_resample_srcchn[2];// Pre conversion temporary buffer for resampling.
54 | std::string m_resample_dstchn[2];// Temporary buffer for receiving color samples.
55 | void *m_hResample[2];
56 | };
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/kxcap/qkxscreenlistener.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxscreenlistener.h"
13 | #include "qkxutils.h"
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | QKxScreenListener::QKxScreenListener(QObject *parent)
23 | : QObject(parent)
24 | {
25 | QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
26 | }
27 |
28 | int QKxScreenListener::screenCount() const
29 | {
30 | return m_dis.length();
31 | }
32 |
33 | QList QKxScreenListener::screens()
34 | {
35 | QKxScreenListener listener;
36 | return listener.monitors();
37 | }
38 |
39 | void QKxScreenListener::onDisplayCheck()
40 | {
41 | //test();
42 | QList dis = monitors();
43 | if(dis.length() != m_dis.length()) {
44 | m_dis.swap(dis);
45 | emit screenChanged();
46 | }else{
47 | bool changed = false;
48 | for(int i = 0; i < dis.length(); i++) {
49 | const DisplayInfo &old = m_dis.at(i);
50 | const DisplayInfo &now = dis.at(i);
51 | if(old.name != now.name || old.rect != now.rect) {
52 | changed = true;
53 | break;
54 | }
55 | }
56 | if(changed) {
57 | m_dis.swap(dis);
58 | emit screenChanged();
59 | }
60 | }
61 | }
62 |
63 | void QKxScreenListener::init()
64 | {
65 | m_dis = monitors();
66 | QTimer *timer = new QTimer(this);
67 | QObject::connect(timer, &QTimer::timeout, this, &QKxScreenListener::onDisplayCheck);
68 | timer->start(1000);
69 | emit screenChanged();
70 | }
71 |
72 | void QKxScreenListener::test()
73 | {
74 | if(QKxUtils::isDesktopChanged()) {
75 | QKxUtils::resetThreadDesktop();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/kxcap/qkxscreenlistener.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXSCREENLISTENER_H
13 | #define QKXSCREENLISTENER_H
14 |
15 | #include "qkxcap_share.h"
16 |
17 | #include
18 | #include
19 | #include
20 |
21 | class QDesktopWidget;
22 | class KXCAP_EXPORT QKxScreenListener : public QObject
23 | {
24 | Q_OBJECT
25 | public:
26 | struct DisplayInfo {
27 | QRect rect;
28 | QString name;
29 | };
30 | public:
31 | explicit QKxScreenListener(QObject *parent = 0);
32 | int screenCount() const;
33 | static QList screens();
34 | signals:
35 | void screenChanged();
36 | private slots:
37 | void onDisplayCheck();
38 | protected:
39 | QList monitors();
40 | Q_INVOKABLE void init();
41 | void test();
42 | private:
43 | QList m_dis;
44 | };
45 |
46 | #endif // QKXSCREENLISTENER_H
47 |
--------------------------------------------------------------------------------
/kxcap/qkxscreenlistener_unix.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxscreenlistener.h"
13 | #include
14 | #include
15 |
16 | QList QKxScreenListener::monitors()
17 | {
18 | DisplayInfo di;
19 | QList dis;
20 | QList screens = QApplication::screens();
21 | for(int i = 0; i < screens.length(); i++) {
22 | QScreen *scn = screens.at(i);
23 | di.name = scn->name();
24 | di.rect = scn->geometry();
25 | dis.append(di);
26 | }
27 | return dis;
28 | }
29 |
--------------------------------------------------------------------------------
/kxcap/qkxscreenlistener_win.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxscreenlistener.h"
13 |
14 | #include "windows.h"
15 |
16 | BOOL CALLBACK monitorEnumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM p)
17 | {
18 | QList *pdis = (QList*)p;
19 | MONITORINFOEXW info;
20 | memset(&info, 0, sizeof(MONITORINFOEXW));
21 | info.cbSize = sizeof(MONITORINFOEXW);
22 | if (GetMonitorInfoW(hMonitor, &info) == FALSE){
23 | return false;
24 | }
25 | QKxScreenListener::DisplayInfo di;
26 | di.rect = QRect(QPoint(info.rcMonitor.left, info.rcMonitor.top), QPoint(info.rcMonitor.right - 1, info.rcMonitor.bottom - 1));
27 | di.name = QString::fromWCharArray(info.szDevice);
28 | pdis->append(di);
29 | return true;
30 | }
31 |
32 | QList QKxScreenListener::monitors()
33 | {
34 | QList dis;
35 | EnumDisplayMonitors(0, 0, monitorEnumCallback, reinterpret_cast(&dis));
36 | return dis;
37 | }
38 |
--------------------------------------------------------------------------------
/kxcap/qkxsendinput.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXSENDINPUT_H
13 | #define QKXSENDINPUT_H
14 |
15 | #include "qkxcap_private.h"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | class QKxSendInput : public QThread
26 | {
27 | Q_OBJECT
28 | private:
29 | struct MyMsg {
30 | uchar type;
31 | QByteArray data;
32 | };
33 | public:
34 | explicit QKxSendInput(const QRect& capRt, const QRect& deskRt, QObject *parent=nullptr);
35 | void stop();
36 | void sendMouseEvent(quint8 button, quint16 x, quint16 y);
37 | void sendKeyEvent(quint8 down, quint32 key);
38 | protected:
39 | virtual void handleMouseEvent(quint8 button, quint16 x, quint16 y) = 0;
40 | virtual void handleKeyEvent(quint8 down, quint32 key) = 0;
41 | private:
42 | void push(uchar type, const QByteArray& data = QByteArray());
43 | bool pop(uchar &type, QByteArray& data);
44 | bool takeOne(uchar type, QByteArray& data);
45 | void run();
46 | int running();
47 | bool init();
48 | protected:
49 | QRect m_capRect;
50 | QRect m_deskRect;
51 | bool m_tryDirect;
52 | private:
53 | QList m_queue;
54 | QMutex m_mtx;
55 | int m_msgRead;
56 | int m_msgWrite;
57 | };
58 |
59 | #endif // QKXSENDINPUT_H
60 |
--------------------------------------------------------------------------------
/kxcap/qkxserviceapplication.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXCAPAPPLICATION_H
13 | #define QKXCAPAPPLICATION_H
14 |
15 | #include "qkxcap_share.h"
16 |
17 | #include
18 | #include
19 | #include "qtservice.h"
20 |
21 | class QKxServiceProcess;
22 | class QKxDaemonMaster;
23 | class KXCAP_EXPORT QKxServiceApplication : public QtService
24 | {
25 | public:
26 | explicit QKxServiceApplication(int argc, char **argv, const QString& serviceName);
27 | virtual ~QKxServiceApplication();
28 | protected:
29 | void start();
30 | void stop();
31 | void pause();
32 | void resume();
33 | void processCommand(int code);
34 | void createApplication(int &argc, char **argv);
35 | int executeApplication();
36 | private:
37 | QPointer m_proxy;
38 | QPointer m_master;
39 | };
40 |
41 | #endif // QKXCAPAPPLICATION_H
42 |
--------------------------------------------------------------------------------
/kxcap/qkxserviceprocess.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxserviceprocess.h"
13 | #include "qkxutils.h"
14 |
15 | #include
16 | #include
17 |
18 | #ifdef Q_OS_WIN
19 | #include
20 | #else
21 | #endif
22 |
23 | QKxServiceProcess::QKxServiceProcess(bool asService, const QString& path, const QMap& envs, QObject *parent)
24 | : QThread(parent)
25 | , m_asService(asService)
26 | , m_envs(envs)
27 | , m_stop(false)
28 | , m_path(path)
29 | , m_daemon(true)
30 | {
31 | m_hProcess = (qint64)-1;
32 | bool ok = QObject::connect(this, SIGNAL(finished()), this, SLOT(onFinished()), Qt::QueuedConnection);
33 | QObject::connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
34 | }
35 |
36 | QKxServiceProcess::QKxServiceProcess(const QMap &envs, QObject *parent)
37 | :QKxServiceProcess(false, QCoreApplication::applicationFilePath(), envs, parent)
38 | {
39 |
40 | }
41 |
42 | QKxServiceProcess::~QKxServiceProcess()
43 | {
44 | if(!m_stop) {
45 | stop();
46 | }
47 | }
48 |
49 | void QKxServiceProcess::setDaemon(bool on)
50 | {
51 | m_daemon = on;
52 | }
53 |
54 | void QKxServiceProcess::onFinished()
55 | {
56 | if(!m_stop && m_daemon) {
57 | start();
58 | }
59 | }
60 |
61 | void QKxServiceProcess::onAboutToQuit()
62 | {
63 | stop();
64 | }
65 |
--------------------------------------------------------------------------------
/kxcap/qkxserviceprocess.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXSERVICEPROCESS_H
13 | #define QKXSERVICEPROCESS_H
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 |
20 | class QProcess;
21 | class QKxServiceProcess : public QThread
22 | {
23 | Q_OBJECT
24 | public:
25 | explicit QKxServiceProcess(bool asService, const QString& path, const QMap& envs, QObject *parent);
26 | explicit QKxServiceProcess(const QMap& envs, QObject *parent);
27 | virtual ~QKxServiceProcess();
28 | void setDaemon(bool on);
29 | void start();
30 | void stop();
31 | private slots:
32 | void onFinished();
33 | void onAboutToQuit();
34 | private:
35 | void run();
36 | bool createWinProcess();
37 | void recreate();
38 | private:
39 | bool m_asService;
40 | QMap m_envs;
41 | bool m_stop;
42 | QString m_path;
43 | qint64 m_hProcess;
44 | bool m_daemon;
45 | QPointer m_process;
46 | };
47 |
48 | #endif // QKXSERVICEPROCESS_H
49 |
--------------------------------------------------------------------------------
/kxcap/qkxserviceprocess_unix.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxserviceprocess.h"
13 | #include "qkxutils.h"
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | void QKxServiceProcess::start()
20 | {
21 | if(isRunning()) {
22 | return;
23 | }
24 | QThread::start();
25 | m_stop = false;
26 | }
27 |
28 | void QKxServiceProcess::stop()
29 | {
30 | m_stop = true;
31 | if(m_process != nullptr) {
32 | m_process->kill();
33 | wait();
34 | }
35 | }
36 |
37 | void QKxServiceProcess::run()
38 | {
39 | createWinProcess();
40 | }
41 |
42 | bool QKxServiceProcess::createWinProcess()
43 | {
44 | QProcess proc;
45 | m_process = &proc;
46 | proc.setProgram(QCoreApplication::applicationFilePath());
47 | QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
48 | for(QMap::Iterator it = m_envs.begin(); it != m_envs.end(); it++) {
49 | env.insert(it.key(), it.value());
50 | }
51 | proc.setProcessEnvironment(env);
52 | proc.start();
53 | proc.waitForFinished(-1);
54 | return true;
55 | }
56 |
--------------------------------------------------------------------------------
/kxcap/qkxserviceprocess_win.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxserviceprocess.h"
13 | #include "qkxutils.h"
14 |
15 | #include
16 | #include
17 |
18 | #include
19 |
20 |
21 | void QKxServiceProcess::start()
22 | {
23 | HANDLE hdl = (HANDLE)m_hProcess;
24 | if(hdl == INVALID_HANDLE_VALUE) {
25 | createWinProcess();
26 | QThread::start();
27 | }
28 | m_stop = false;
29 | }
30 |
31 | void QKxServiceProcess::stop()
32 | {
33 | HANDLE hdl = (HANDLE)m_hProcess;
34 | m_stop = true;
35 | if(hdl != INVALID_HANDLE_VALUE){
36 | ::TerminateProcess(hdl, 0);
37 | wait();
38 | }
39 | }
40 |
41 | void QKxServiceProcess::run()
42 | {
43 | HANDLE hdl = (HANDLE)m_hProcess;
44 | ::WaitForSingleObject(hdl, INFINITE);
45 | ::CloseHandle(hdl);
46 | m_hProcess = (qint64)INVALID_HANDLE_VALUE;
47 | }
48 |
49 | bool QKxServiceProcess::createWinProcess()
50 | {
51 | PROCESS_INFORMATION info;
52 | m_hProcess = (qint64)INVALID_HANDLE_VALUE;
53 | qDebug() <<"QKxServiceProcess::createWinProcess" << m_asService << m_path << m_envs;
54 | QStringList envs;
55 | for(QMap::Iterator it = m_envs.begin(); it != m_envs.end(); it++) {
56 | envs.append(it.key() + "=" + it.value());
57 | }
58 | if(m_asService) {
59 | if(QKxUtils::createProcessWithAdmin(m_path, envs, (void*)&info)) {
60 | m_hProcess = (qint64)info.hProcess;
61 | return true;
62 | }
63 | }else{
64 | if(QKxUtils::createProcess(m_path, envs, (void*)&info)) {
65 | m_hProcess = (qint64)info.hProcess;
66 | return true;
67 | }
68 | }
69 | return false;
70 | }
71 |
--------------------------------------------------------------------------------
/kxcap/qkxtcpvncserver.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXTCPVNCSERVER_H
13 | #define QKXTCPVNCSERVER_H
14 |
15 | #include "qkxcap_share.h"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | class QTcpServer;
23 | class QTcpSocket;
24 | class QIODevice;
25 | class QKxShareMemory;
26 | class QProcess;
27 |
28 | class KXCAP_EXPORT QKxTcpVNCServer : public QObject
29 | {
30 | Q_OBJECT
31 | public:
32 | explicit QKxTcpVNCServer(QObject *parent = 0);
33 | virtual ~QKxTcpVNCServer();
34 | quint16 start(const QString& host, quint16 port = 0);
35 | void stop();
36 |
37 | int screenIndex();
38 | void setScreenIndex(int idx);
39 | QString authorizePassword();
40 | void setAuthorizePassword(const QString& pwd);
41 | int maxFPS() const;
42 | void setMaxFPS(int fps);
43 | void setEmptyFrameEnable(bool ok);
44 | signals:
45 |
46 | public slots:
47 | void onOpenNewConnection();
48 | void onLocalNewConnection();
49 | void onOpenDisconnected();
50 | void onLocalDisconnected();
51 | void onReadyRead();
52 | void onAboutToQuit();
53 | void onScreenChanged();
54 | void onVncProcessFinish();
55 | private:
56 | void createPeer(bool bInner);
57 | void stopAllClient();
58 | private:
59 | QPointer m_openServer;
60 | QPointer m_localServer;
61 | QMap, QPointer > m_pairs;
62 | QList > m_ready;
63 | QList > m_vncs;
64 | };
65 |
66 | #endif // QKXTCPVNCSERVER_H
67 |
--------------------------------------------------------------------------------
/kxcap/qkxvncserverpeer.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxvncserverpeer.h"
13 | #include
14 | #include
15 | #include
16 |
17 | QKxVNCServerPeer::QKxVNCServerPeer(QObject *parent)
18 | : QKxVNCServer(parent)
19 | {
20 | QByteArray name = qgetenv("RPOXY_SERVER_NAME");
21 | if(name.startsWith("tcp:")) {
22 | QTcpSocket *tcp = new QTcpSocket(this);
23 | QByteArrayList hps = name.split(':');
24 | QByteArray host = hps.at(1);
25 | QByteArray port = hps.at(2);
26 | tcp->connectToHost(host, port.toInt());
27 | QObject::connect(tcp, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
28 | m_client = tcp;
29 | }else if(name.startsWith("local:")){
30 | QString svcName = name.mid(6);
31 | QLocalSocket *local = new QLocalSocket(this);
32 | local->connectToServer(svcName);
33 | QObject::connect(local, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
34 | m_client = local;
35 | }else {
36 | qWarning() << "never come here";
37 | }
38 | QTimer::singleShot(5 * 1000, this, SLOT(onConnectTimeout()));
39 | restart(m_client);
40 | }
41 |
42 | void QKxVNCServerPeer::onConnectTimeout()
43 | {
44 | if(!m_client->isOpen()) {
45 | emit errorArrived(-1);
46 | return;
47 | }
48 | }
49 |
50 | void QKxVNCServerPeer::onDisconnected()
51 | {
52 | qDebug() << "QKxVNCServerPeer::onDisconnected" << sender();
53 | emit errorArrived(-2);
54 | }
55 |
--------------------------------------------------------------------------------
/kxcap/qkxvncserverpeer.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXVNCSERVERPEER_H
13 | #define QKXVNCSERVERPEER_H
14 |
15 | #include "qkxcap_share.h"
16 | #include "qkxvncserver.h"
17 | #include
18 |
19 | class QLocalSocket;
20 | class QTcpSocket;
21 | class QTimer;
22 |
23 | class KXCAP_EXPORT QKxVNCServerPeer : public QKxVNCServer
24 | {
25 | Q_OBJECT
26 | public:
27 | explicit QKxVNCServerPeer(QObject *parent = 0);
28 | signals:
29 | void errorArrived(int err);
30 | public slots:
31 | void onConnectTimeout();
32 | void onDisconnected();
33 | private:
34 | QPointer m_client;
35 | QPointer m_tick;
36 | };
37 |
38 | #endif // QKXVNCSERVERPEER_H
39 |
--------------------------------------------------------------------------------
/kxcap/qkxwin8privacyscreen.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXWIN8PRIVACYSCREEN_H
13 | #define QKXWIN8PRIVACYSCREEN_H
14 |
15 | #include "qkxprivacyscreen.h"
16 |
17 | #include
18 | #include
19 |
20 |
21 | class QKxWin8SubPrivacyScreen;
22 | class QKxWin8PrivacyScreen : public QKxPrivacyScreen
23 | {
24 | Q_OBJECT
25 | public:
26 | explicit QKxWin8PrivacyScreen(const QVector& screenRt, QObject *parent = nullptr);
27 | ~QKxWin8PrivacyScreen();
28 | bool isVisible();
29 | void setVisible(bool on);
30 | bool snapshot(int idx, uchar *pbuf, int bytesPerline, int width, int height) const;
31 | private:
32 | QVector> m_subs;
33 | };
34 |
35 | #endif // QKXWIN8PRIVACYSCREEN_H
36 |
--------------------------------------------------------------------------------
/kxcap/qkxwinaudiocapture.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxwinaudiocapture.h"
13 |
14 | #include
15 |
16 | QKxWinAudioCapture::QKxWinAudioCapture(QObject *parent)
17 | : QKxAudioCapture(parent)
18 | {
19 |
20 | }
21 |
22 | QKxWinAudioCapture::~QKxWinAudioCapture()
23 | {
24 |
25 | }
26 |
27 | int QKxWinAudioCapture::findDefaultLoopbackDevice()
28 | {
29 | int idx = Pa_GetDefaultOutputDevice();
30 | if(idx == paNoDevice) {
31 | return paNoDevice;
32 | }
33 | const PaDeviceInfo *pdi = Pa_GetDeviceInfo(idx);
34 | QString name = QString::fromUtf8(pdi->name);
35 | PaDeviceIndex numDevices = Pa_GetDeviceCount();
36 | for(int i = 0; i < numDevices; i++) {
37 | const PaDeviceInfo *hit = Pa_GetDeviceInfo(i);
38 | QString nameHit = QString::fromUtf8(hit->name);
39 | if(nameHit.contains("[Loopback]") && nameHit.startsWith(name) && hit->maxInputChannels > 0) {
40 | return i;
41 | }
42 | }
43 | return paNoDevice;
44 | }
45 |
--------------------------------------------------------------------------------
/kxcap/qkxwinaudiocapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXWINAUDIOCAPTURE_H
13 | #define QKXWINAUDIOCAPTURE_H
14 |
15 | #include "qkxaudiocapture.h"
16 |
17 | class QKxWinAudioCapture : public QKxAudioCapture
18 | {
19 | Q_OBJECT
20 | public:
21 | explicit QKxWinAudioCapture(QObject *parent = nullptr);
22 | virtual ~QKxWinAudioCapture();
23 | private:
24 | int findDefaultLoopbackDevice();
25 |
26 | };
27 |
28 | #endif // QKXWINAUDIOCAPTURE_H
29 |
--------------------------------------------------------------------------------
/kxcap/qkxwinclipboard.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxwinclipboard.h"
13 |
14 | #include
15 | #include
16 |
17 | QKxWinClipboard::QKxWinClipboard(QObject *parent)
18 | : QKxClipboard(parent)
19 | {
20 | QClipboard *clipboard = QGuiApplication::clipboard();
21 | QObject::connect(clipboard, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()));
22 | }
23 |
24 | QKxWinClipboard::~QKxWinClipboard()
25 | {
26 |
27 | }
28 |
29 | QString QKxWinClipboard::text() const
30 | {
31 | QClipboard *clipboard = QGuiApplication::clipboard();
32 | QString clipTxt = clipboard->text();
33 | return clipTxt;
34 | }
35 |
--------------------------------------------------------------------------------
/kxcap/qkxwinclipboard.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXWINCLIPBOARD_H
13 | #define QKXWINCLIPBOARD_H
14 |
15 | #include "qkxclipboard.h"
16 | #include
17 |
18 |
19 | class QKxWinClipboard : public QKxClipboard
20 | {
21 | public:
22 | explicit QKxWinClipboard(QObject *parent = nullptr);
23 | virtual ~QKxWinClipboard();
24 | private:
25 | virtual QString text() const;
26 | };
27 |
28 | #endif // QKXWINCLIPBOARD_H
29 |
--------------------------------------------------------------------------------
/kxcap/qkxwindows.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXWINDOWS_H
13 | #define QKXWINDOWS_H
14 |
15 | #include
16 |
17 | DWORD GetLogonPid(DWORD dwSessionId, BOOL as_user);
18 | BOOL GetSessionUserTokenWin(OUT LPHANDLE lphUserToken, DWORD dwSessionId, BOOL as_user);
19 | HANDLE LaunchProcessWin(const QString& path, DWORD dwSessionId, BOOL as_user);
20 | bool launchProcess(const QString& cmd, BOOL as_user);
21 | BOOL inputDesktopSelected(QString& name);
22 | bool selectInputDesktop();
23 | void setBlankScreen(BOOL set);
24 | void lockWorkStation();
25 | HANDLE LaunchProcessWin2(const QString& path, DWORD dwSessionId);
26 | DWORD LaunchProcess(DWORD SessionId, const char **failed_operation);
27 | DWORD GetCurrentSessionId();
28 | BOOL SetWinSta0Desktop(WCHAR *szDesktopName);
29 | void PopupSessionMessage();
30 | void PopupSessionMessage2();
31 | void switchToLogonDesktop();
32 | void switchToDefaultDesktop();
33 |
34 |
35 | //netsh advfirewall firewall add rule name="app name" dir=in action=allow program="Full path of .exe" enable=yes
36 | void setFirewallRoute(const QString& appName, const QString& appPath);
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/kxcap/qkxwinsendinput.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXWINSENDINPUT_H
13 | #define QKXWINSENDINPUT_H
14 |
15 | #include "qkxsendinput.h"
16 |
17 | class QKxWinSendInput : public QKxSendInput
18 | {
19 | Q_OBJECT
20 | public:
21 | explicit QKxWinSendInput(const QRect& capRt, const QRect& deskRt, QObject *parent=nullptr);
22 | protected:
23 | void handleMouseEvent(quint8 button, quint16 x, quint16 y);
24 | void handleKeyEvent(quint8 down, quint32 key);
25 | private:
26 | void setMouseEvent(quint32 flags, qint32 delta, int x, int y);
27 | void setKeybdEvent(quint16 vkey, bool down);
28 | bool isKeyToggled(quint16 vkey);
29 | bool isKeyPressed(quint16 vkey);
30 | QFlags shortCutHint(quint8 ch);
31 | private:
32 | quint32 m_mouseButtonFlags;
33 | };
34 | #endif // QKXWINSENDINPUT_H
35 |
--------------------------------------------------------------------------------
/kxcap/qkxx11capture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXX11CAPTURE_H
13 | #define QKXX11CAPTURE_H
14 |
15 | #include "qkxabstractcapture.h"
16 |
17 | class QKxH264Encoder;
18 | class X11CapturePrivate;
19 | class QKxX11Capture : public QKxAbstractCapture
20 | {
21 | public:
22 | explicit QKxX11Capture(int idx, const QRect& imageRt, const QRect& screenRt, QObject *parent = nullptr);
23 | virtual ~QKxX11Capture();
24 | bool reset();
25 | int getFrame();
26 | int drawFrame(UpdateRequest *req, uchar *pbuf, int bytesPerLine, bool reset);
27 | private:
28 | X11CapturePrivate *m_prv;
29 | QRect m_imageRt;
30 | int m_idx;
31 | };
32 |
33 | #endif // QKXX11CAPTURE_H
34 |
--------------------------------------------------------------------------------
/kxcap/qkxx11clipboard.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxx11clipboard.h"
13 |
14 | #include
15 | #include
16 |
17 | QKxX11Clipboard::QKxX11Clipboard(QObject *parent)
18 | : QKxClipboard(parent)
19 | {
20 | QClipboard *clipboard = QGuiApplication::clipboard();
21 | QObject::connect(clipboard, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()));
22 | }
23 |
24 | QKxX11Clipboard::~QKxX11Clipboard()
25 | {
26 |
27 | }
28 |
29 | QString QKxX11Clipboard::text() const
30 | {
31 | QClipboard *clipboard = QGuiApplication::clipboard();
32 | QString clipTxt = clipboard->text();
33 | return clipTxt;
34 | }
35 |
--------------------------------------------------------------------------------
/kxcap/qkxx11clipboard.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXX11CLIPBOARD_H
13 | #define QKXX11CLIPBOARD_H
14 |
15 | #include "qkxclipboard.h"
16 | #include
17 |
18 |
19 | class QKxX11Clipboard : public QKxClipboard
20 | {
21 | public:
22 | explicit QKxX11Clipboard(QObject *parent = nullptr);
23 | virtual ~QKxX11Clipboard();
24 | private:
25 | virtual QString text() const;
26 | };
27 |
28 | #endif // QKXX11CLIPBOARD_H
29 |
--------------------------------------------------------------------------------
/kxcap/qkxx11screencapture.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXX11SCREENCAPTURE_H
13 | #define QKXX11SCREENCAPTURE_H
14 |
15 | #include "qkxscreencapture.h"
16 |
17 | class QKxX11ScreenCapture : public QKxScreenCapture
18 | {
19 | public:
20 | public:
21 | explicit QKxX11ScreenCapture(int screenIndex, const QRect& rt, const QRect& imgRt, QObject *parent = nullptr);
22 | private:
23 | virtual int running();
24 | };
25 |
26 | #endif // QKXX11SCREENCAPTURE_H
27 |
--------------------------------------------------------------------------------
/kxcap/qkxx11sendinput.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXUNIXSENDINPUT_H
13 | #define QKXUNIXSENDINPUT_H
14 |
15 | #include "qkxsendinput.h"
16 |
17 | class X11SendInputPrivate;
18 | class QKxX11SendInput : public QKxSendInput
19 | {
20 | Q_OBJECT
21 | public:
22 | explicit QKxX11SendInput(const QRect& capRt, const QRect& deskRt, QObject *parent=nullptr);
23 | virtual ~QKxX11SendInput();
24 | protected:
25 | void handleMouseEvent(quint8 button, quint16 x, quint16 y);
26 | void handleKeyEvent(quint8 down, quint32 key);
27 | void changeKeyboard();
28 | private slots:
29 | void onFindAllLessGreater();
30 | private:
31 | X11SendInputPrivate *m_prv;
32 | };
33 |
34 | #endif // QKXUNIXSENDINPUT_H
35 |
--------------------------------------------------------------------------------
/kxcap/resample/config.h:
--------------------------------------------------------------------------------
1 | /* src/config.h. Generated from configtemplate.h by configure. */
2 | /* Run configure to generate config.h automatically on any
3 | system supported by GNU autoconf. For all other systems,
4 | use this file as a template to create config.h
5 | */
6 |
7 | #define HAVE_INTTYPES_H 1
8 |
9 |
--------------------------------------------------------------------------------
/kxcap/resample/configtemplate.h:
--------------------------------------------------------------------------------
1 | /* Run configure to generate config.h automatically on any
2 | system supported by GNU autoconf. For all other systems,
3 | use this file as a template to create config.h
4 | */
5 |
6 | #undef HAVE_INTTYPES_H
7 |
8 |
--------------------------------------------------------------------------------
/kxcap/resample/filterkit.h:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 |
3 | resamplesubs.c
4 |
5 | Real-time library interface by Dominic Mazzoni
6 |
7 | Based on resample-1.7:
8 | http://www-ccrma.stanford.edu/~jos/resample/
9 |
10 | License: LGPL - see the file LICENSE.txt for more information
11 |
12 | **********************************************************************/
13 |
14 | /* Definitions */
15 | #include "resample_defs.h"
16 |
17 | /*
18 | * FilterUp() - Applies a filter to a given sample when up-converting.
19 | * FilterUD() - Applies a filter to a given sample when up- or down-
20 | */
21 |
22 | float lrsFilterUp(float Imp[], float ImpD[], UWORD Nwing, BOOL Interp,
23 | float *Xp, double Ph, int Inc);
24 |
25 | float lrsFilterUD(float Imp[], float ImpD[], UWORD Nwing, BOOL Interp,
26 | float *Xp, double Ph, int Inc, double dhb);
27 |
28 | void lrsLpFilter(double c[], int N, double frq, double Beta, int Num);
29 |
--------------------------------------------------------------------------------
/kxcap/resample/libresample.h:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 |
3 | resample.h
4 |
5 | Real-time library interface by Dominic Mazzoni
6 |
7 | Based on resample-1.7:
8 | http://www-ccrma.stanford.edu/~jos/resample/
9 |
10 | License: LGPL - see the file LICENSE.txt for more information
11 |
12 | **********************************************************************/
13 |
14 | #ifndef LIBRESAMPLE_INCLUDED
15 | #define LIBRESAMPLE_INCLUDED
16 |
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif /* __cplusplus */
20 |
21 | void *resample_open(int highQuality,
22 | double minFactor,
23 | double maxFactor);
24 |
25 | void *resample_dup(const void *handle);
26 |
27 | int resample_get_filter_width(const void *handle);
28 |
29 | int resample_process(void *handle,
30 | double factor,
31 | float *inBuffer,
32 | int inBufferLen,
33 | int lastFlag,
34 | int *inBufferUsed,
35 | float *outBuffer,
36 | int outBufferLen);
37 |
38 | void resample_close(void *handle);
39 |
40 | #ifdef __cplusplus
41 | } /* extern "C" */
42 | #endif /* __cplusplus */
43 |
44 | #endif /* LIBRESAMPLE_INCLUDED */
45 |
--------------------------------------------------------------------------------
/kxcap/resample/resample_defs.h:
--------------------------------------------------------------------------------
1 | /**********************************************************************
2 |
3 | resample_defs.h
4 |
5 | Real-time library interface by Dominic Mazzoni
6 |
7 | Based on resample-1.7:
8 | http://www-ccrma.stanford.edu/~jos/resample/
9 |
10 | License: LGPL - see the file LICENSE.txt for more information
11 |
12 | **********************************************************************/
13 |
14 | #ifndef __RESAMPLE_DEFS__
15 | #define __RESAMPLE_DEFS__
16 |
17 | #if !defined(WIN32) && !defined(__CYGWIN__)
18 | #include "config.h"
19 | #endif
20 |
21 | #ifndef TRUE
22 | #define TRUE 1
23 | #endif
24 |
25 | #ifndef FALSE
26 | #define FALSE 0
27 | #endif
28 |
29 | #ifndef PI
30 | #define PI (3.14159265358979232846)
31 | #endif
32 |
33 | #ifndef PI2
34 | #define PI2 (6.28318530717958465692)
35 | #endif
36 |
37 | #define D2R (0.01745329348) /* (2*pi)/360 */
38 | #define R2D (57.29577951) /* 360/(2*pi) */
39 |
40 | #ifndef MAX
41 | #define MAX(x,y) ((x)>(y) ?(x):(y))
42 | #endif
43 | #ifndef MIN
44 | #define MIN(x,y) ((x)<(y) ?(x):(y))
45 | #endif
46 |
47 | #ifndef ABS
48 | #define ABS(x) ((x)<0 ?(-(x)):(x))
49 | #endif
50 |
51 | #ifndef SGN
52 | #define SGN(x) ((x)<0 ?(-1):((x)==0?(0):(1)))
53 | #endif
54 |
55 | #if HAVE_INTTYPES_H
56 | #include
57 | typedef char BOOL;
58 | typedef int32_t WORD;
59 | typedef uint32_t UWORD;
60 | #else
61 | typedef char BOOL;
62 | typedef int WORD;
63 | typedef unsigned int UWORD;
64 | #endif
65 |
66 | #ifdef DEBUG
67 | #define INLINE
68 | #else
69 | #define INLINE inline
70 | #endif
71 |
72 | /* Accuracy */
73 |
74 | #define Npc 4096
75 |
76 | /* Function prototypes */
77 |
78 | int lrsSrcUp(float X[], float Y[], double factor, double *Time,
79 | UWORD Nx, UWORD Nwing, float LpScl,
80 | float Imp[], float ImpD[], BOOL Interp);
81 |
82 | int lrsSrcUD(float X[], float Y[], double factor, double *Time,
83 | UWORD Nx, UWORD Nwing, float LpScl,
84 | float Imp[], float ImpD[], BOOL Interp);
85 |
86 | #endif
87 |
--------------------------------------------------------------------------------
/kxcap/resource/skin.fw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin.fw.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/configure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/configure.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/exit.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/eye.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/eye.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/play.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/product.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/product.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/reload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/reload.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/stop.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/vncserver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/vncserver.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/vncserver2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/vncserver2.png
--------------------------------------------------------------------------------
/kxcap/resource/skin/wovncserver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/skin/wovncserver.png
--------------------------------------------------------------------------------
/kxcap/resource/template.plist.in:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${MACOSX_BUNDLE_EXECUTABLE_NAME}
9 | CFBundleGetInfoString
10 | ${MACOSX_BUNDLE_INFO_STRING}
11 | CFBundleIconFile
12 | ${MACOSX_BUNDLE_ICON_FILE}
13 | CFBundleIdentifier
14 | ${MACOSX_BUNDLE_GUI_IDENTIFIER}
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleLongVersionString
18 | ${MACOSX_BUNDLE_LONG_VERSION_STRING}
19 | CFBundleName
20 | ${MACOSX_BUNDLE_BUNDLE_NAME}
21 | CFBundlePackageType
22 | APPL
23 | CFBundleShortVersionString
24 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING}
25 | CFBundleSignature
26 | ????
27 | CFBundleVersion
28 | ${MACOSX_BUNDLE_BUNDLE_VERSION}
29 | CSResourcesFileMapped
30 |
31 | NSHumanReadableCopyright
32 | ${MACOSX_BUNDLE_COPYRIGHT}
33 | LSUIElement
34 | 0
35 |
36 |
37 |
--------------------------------------------------------------------------------
/kxcap/resource/vncserver.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/vncserver.ico
--------------------------------------------------------------------------------
/kxcap/resource/wovncserver.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aoyiduo/wovnc/5893a6e7bf2e9f3a64f53774e31c72a512d692b2/kxcap/resource/wovncserver.icns
--------------------------------------------------------------------------------
/kxftp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.1)
2 |
3 | project(kxftp LANGUAGES CXX)
4 |
5 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
6 | set(CMAKE_AUTOMOC ON)
7 | set(CMAKE_AUTORCC ON)
8 | set(CMAKE_AUTOUIC ON)
9 | set(CMAKE_CXX_STANDARD 11)
10 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
11 |
12 | if(WIN32)
13 | else()
14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
15 | endif()
16 |
17 | add_definitions(-DKXFTP_LIBRARY)
18 |
19 | find_package(Qt5 COMPONENTS Core Network Widgets)
20 |
21 | set(SOURCE_FILES
22 | qkxftpserver.cpp
23 | qkxftpserverprivate.cpp
24 | qkxftpclient.cpp
25 | qkxftpresponse.cpp
26 | qkxftprequest.cpp
27 | qkxftpupload.cpp
28 | qkxftpdownload.cpp
29 | qkxftptransferwidget.cpp
30 | qkxftptransfermodel.cpp
31 | qkxftpremotemodel.cpp
32 | qkxftplocalmodel.cpp
33 | )
34 |
35 | set(HEADER_FILES
36 | qkxftp_share.h
37 | qkxftp_private.h
38 | qkxftpserver.h
39 | qkxftpserverprivate.h
40 | qkxftpclient.h
41 | qkxftpresponse.h
42 | qkxftprequest.h
43 | qkxftpupload.h
44 | qkxftpdownload.h
45 | qkxftptransferwidget.h
46 | qkxftptransfermodel.h
47 | qkxftpremotemodel.h
48 | qkxftplocalmodel.h
49 | )
50 |
51 | set(OTHER_FILES
52 | qkxftp.qrc
53 | )
54 |
55 | include_directories(${SERVICE_ROOT_DIR}
56 | ${KXUTIL_ROOT_DIR}
57 | )
58 | link_libraries(kxutil)
59 |
60 | if(WIN32)
61 | link_libraries(ws2_32)
62 | elseif(APPLE)
63 | message("APPLE Here")
64 | else()
65 | message("other")
66 | endif()
67 |
68 | add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${OTHER_FILES})
69 | target_compile_definitions(${PROJECT_NAME} PRIVATE $<$,$>:QT_QML_DEBUG>)
70 | target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network Qt5::Widgets)
71 |
72 |
73 |
--------------------------------------------------------------------------------
/kxftp/qkxftp.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | resource/skin/back.png
4 | resource/skin/folder.png
5 | resource/skin/forward.png
6 | resource/skin/home.png
7 | resource/skin/reload.png
8 | resource/skin/copy.png
9 | resource/skin/download.png
10 | resource/skin/login.png
11 | resource/skin/pause.png
12 | resource/skin/remove.png
13 | resource/skin/removeall.png
14 | resource/skin/start.png
15 | resource/skin/startall.png
16 | resource/skin/stopall.png
17 | resource/skin/upload.png
18 | resource/skin/right.png
19 | resource/skin/time.png
20 | resource/skin/transfer.png
21 |
22 |
23 |
--------------------------------------------------------------------------------
/kxftp/qkxftp_private.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTP_PRIVATE_H
13 | #define QKXFTP_PRIVATE_H
14 |
15 | #include "qkxftp_share.h"
16 |
17 | #include
18 | #include
19 |
20 | #define FTP_FILEMODEL_DATA (1)
21 | #define FTP_FILEMODEL_LIST_FILES_REQ (2)
22 | #define FTP_FILEMODEL_LIST_FILES_RESP (3)
23 | #define FTP_FILEMODEL_ENTRY_INFO_LIST_REQ (4) //entryInfoList
24 | #define FTP_FILEMODEL_ENTRY_INFO_LIST_RESP (5)
25 | #define FTP_FILEMODEL_MKDIR_REQ (6)
26 | #define FTP_FILEMODEL_MKDIR_RESP (7)
27 |
28 | #define FTP_DOWNLOAD_INIT_REQ (50)
29 | #define FTP_DOWNLOAD_INIT_RESP (51)
30 | #define FTP_DOWNLOAD_DATA_START (52)
31 | #define FTP_DOWNLOAD_DATA_BLOCK (53)
32 | #define FTP_DOWNLOAD_DATA_NEXT (54)
33 | #define FTP_DOWNLOAD_DATA_END (55)
34 | #define FTP_DOWNLOAD_DATA_ABORT (56)
35 |
36 | #define FTP_UPLOAD_INIT_REQ (100)
37 | #define FTP_UPLOAD_INIT_RESP (101)
38 | #define FTP_UPLOAD_DATA_START (102)
39 | #define FTP_UPLOAD_DATA_BLOCK (103)
40 | #define FTP_UPLOAD_DATA_NEXT (104)
41 | #define FTP_UPLOAD_DATA_END (105)
42 | #define FTP_UPLOAD_DATA_ABORT (106)
43 |
44 |
45 | #define FTP_REQUEST_PROXY_PREFIX ("ftp-request-proxy")
46 | #define FTP_SERVER_PREFIX ("ftp-server")
47 |
48 | #endif // QKXFTP_PRIVATE_H
49 |
--------------------------------------------------------------------------------
/kxftp/qkxftp_share.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTP_SHARE_H
13 | #define QKXFTP_SHARE_H
14 |
15 | #if defined(KXFTP_LIBRARY)
16 | # define KXFTP_EXPORT Q_DECL_EXPORT
17 | #else
18 | # define KXFTP_EXPORT Q_DECL_IMPORT
19 | #endif
20 |
21 | #endif // QKXNET_SHARE_H
22 |
--------------------------------------------------------------------------------
/kxftp/qkxftpclient.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxftpclient.h"
13 | #include "qkxftp_private.h"
14 |
15 | #include "qkxlengthbodypacket.h"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 |
26 | QKxFtpClient::QKxFtpClient(QIODevice *local, QObject *parent)
27 | : QKxFtpResponse(parent)
28 | , m_local(local)
29 | , m_crypt(QCryptographicHash::Md5)
30 | , m_recvLeft(0)
31 | {
32 | m_stream.setDevice(local);
33 | QObject::connect(local, SIGNAL(readyRead()), this, SLOT(onLocalReadyRead()));
34 | m_recvBuffer.reserve(1024);
35 | }
36 |
37 | QKxFtpClient::~QKxFtpClient()
38 | {
39 | }
40 |
41 | void QKxFtpClient::onLocalReadyRead()
42 | {
43 | QByteArray all = m_local->readAll();
44 | handlePacket(all);
45 | }
46 |
47 | void QKxFtpClient::writeResult(const QByteArray &buf)
48 | {
49 | m_stream << buf;
50 | }
51 |
--------------------------------------------------------------------------------
/kxftp/qkxftpclient.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTPCLIENT_H
13 | #define QKXFTPCLIENT_H
14 |
15 | #include "qkxftpresponse.h"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 |
23 | class QIODevice;
24 | class QLocalSocket;
25 | class QFile;
26 |
27 | class QKxFtpClient : public QKxFtpResponse
28 | {
29 | Q_OBJECT
30 | public:
31 | explicit QKxFtpClient(QIODevice *local, QObject *parent = nullptr);
32 | ~QKxFtpClient();
33 |
34 | private slots:
35 | void onLocalReadyRead();
36 | private:
37 | virtual void writeResult(const QByteArray& buf);
38 | private:
39 | QPointer m_local;
40 | QDataStream m_stream;
41 | QPointer m_lbp;
42 | // transfer
43 | QCryptographicHash m_crypt;
44 | QPointer m_file;
45 | qint32 m_recvLeft;
46 | QByteArray m_recvBuffer;
47 | };
48 |
49 | #endif // QKXFTPCLIENT_H
50 |
--------------------------------------------------------------------------------
/kxftp/qkxftpdownload.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTPDOWNLOAD_H
13 | #define QKXFTPDOWNLOAD_H
14 |
15 | #include "qkxftp_share.h"
16 |
17 | #include
18 | #include
19 | #include
20 |
21 | class QKxFtpRequest;
22 | class QFile;
23 | class KXFTP_EXPORT QKxFtpDownload : public QObject
24 | {
25 | Q_OBJECT
26 | public:
27 | explicit QKxFtpDownload(QKxFtpRequest *ftp, QObject *parent = nullptr);
28 | virtual ~QKxFtpDownload();
29 | void start(const QString& local, const QString& remote, bool fromZero);
30 | void stop();
31 | signals:
32 | void error(int err, const QString& msg);
33 | void finished();
34 | void progress(int i, int pos, int fsize);
35 | public slots:
36 | void onDownloadInitResult(qint8 err, const QByteArray& msg, qint64 fsize, qint32 jobId);
37 | void onDownloadResult(qint8 err, const QByteArray& data, qint32 jobId);
38 | private:
39 | Q_INVOKABLE void verifyMd5(qint32 jobId);
40 | private:
41 | qint32 m_jobId;
42 | QPointer m_ftp;
43 | QPointer m_file;
44 | QCryptographicHash m_crypt;
45 | QString m_local;
46 | QString m_remote;
47 | qint64 m_fileSize;
48 | int m_percentLast;
49 | bool m_fromZero;
50 | bool m_stop;
51 |
52 | qint64 m_tmStart;
53 | };
54 |
55 | #endif // QKXFTPDOWNLOAD_H
56 |
--------------------------------------------------------------------------------
/kxftp/qkxftplocalmodel.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTPLOCALMODEL_H
13 | #define QKXFTPLOCALMODEL_H
14 |
15 | #include "qkxftp_share.h"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | class KXFTP_EXPORT QKxFtpLocalModel : public QAbstractListModel
24 | {
25 | Q_OBJECT
26 | public:
27 | explicit QKxFtpLocalModel(QObject *parent = nullptr);
28 | QFileInfo fileInfo(const QModelIndex& idx) const;
29 | QModelIndex mkdir(const QModelIndex &parent, const QString &name);
30 | void setPath(const QString& path);
31 | QString path() const;
32 | void reload();
33 |
34 | void setHome();
35 | protected:
36 | int rowCount(const QModelIndex &parent = QModelIndex()) const override;
37 | QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
38 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
39 | bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
40 | Qt::ItemFlags flags(const QModelIndex &index) const override;
41 | bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
42 | bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
43 | void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
44 | Qt::DropActions supportedDropActions() const override;
45 | // header
46 | int columnCount(const QModelIndex &parent = QModelIndex()) const override;
47 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
48 | private slots:
49 | void onFileListActive(const QList& fis);
50 | private:
51 | QString m_path;
52 | QList m_fileInfos;
53 | QFileIconProvider m_iconProvider;
54 | };
55 |
56 | #endif // QKXFTPLOCALMODEL_H
57 |
--------------------------------------------------------------------------------
/kxftp/qkxftpresponse.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTPRESPONSE_H
13 | #define QKXFTPRESPONSE_H
14 |
15 | #include "qkxftp_share.h"
16 | #include "qkxlengthbodypacket.h"
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 |
24 | class QIODevice;
25 | class QLocalSocket;
26 | class QFile;
27 |
28 | class KXFTP_EXPORT QKxFtpResponse : public QObject,
29 | public QKxLengthBodyPacket
30 | {
31 | Q_OBJECT
32 | public:
33 | explicit QKxFtpResponse(QObject *parent = nullptr);
34 | ~QKxFtpResponse();
35 |
36 | void handlePacket(const QByteArray& buf);
37 | signals:
38 | void result(const QByteArray& buf);
39 | protected:
40 | virtual void writeResult(const QByteArray& buf);
41 | private:
42 | Q_INVOKABLE void downloadVerify(const QByteArray& md5, qint64 fsize, qint32 jobId);
43 | Q_INVOKABLE void uploadVerify(qint32 jobId);
44 | bool tryTohandlePacket();
45 | bool handleNextPacket(QDataStream& in, QDataStream& out);
46 | void sendFileBlock(qint64 pos, qint32 jobId, QDataStream& out);
47 | bool listFiles(const QByteArray &path, QByteArrayList& all);
48 | bool listFiles(const QString &path, QStringList &all, int maxCount);
49 | QByteArray entryInfoList(QByteArray& path);
50 | private:
51 | // transfer
52 | QCryptographicHash m_crypt;
53 | QPointer m_file;
54 | qint32 m_recvLeft;
55 | QByteArray m_recvBuffer;
56 | };
57 |
58 | #endif // QKXFTPRESPONSE_H
59 |
--------------------------------------------------------------------------------
/kxftp/qkxftpserver.cpp:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #include "qkxftpserver.h"
13 | #include "qkxftpclient.h"
14 |
15 | #include "qkxftp_private.h"
16 | #include "qkxftpserverprivate.h"
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 |
24 | QKxFtpServer::QKxFtpServer(const QString& envName)
25 | : QObject(nullptr)
26 | {
27 | m_prv = new QKxFtpServerPrivate(envName);
28 | }
29 |
30 | QKxFtpServer::~QKxFtpServer()
31 | {
32 | delete m_prv;
33 | }
34 |
--------------------------------------------------------------------------------
/kxftp/qkxftpserver.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTPSERVER_H
13 | #define QKXFTPSERVER_H
14 |
15 | #include "qkxftp_share.h"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | class QRemoteObjectHost;
23 | class QTcpServer;
24 | class QLocalSocket;
25 | class QTcpSocket;
26 | class QKxFtpIconProvider;
27 | class QThread;
28 | class QFile;
29 | class QKxFtpClient;
30 | class QIODevice;
31 | class QLocalServer;
32 | class QKxFtpServerPrivate;
33 |
34 | class KXFTP_EXPORT QKxFtpServer : public QObject
35 | {
36 | Q_OBJECT
37 | public:
38 | explicit QKxFtpServer(const QString& envName);
39 | ~QKxFtpServer();
40 | private:
41 | QPointer m_prv;
42 | };
43 |
44 | #endif // QKXFTPSERVER_H
45 |
--------------------------------------------------------------------------------
/kxftp/qkxftpserverprivate.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * Copyright (C) 2022 Guangzhou AoYiDuo Network Technology Co.,Ltd. All Rights Reserved.
4 | *
5 | * Contact: http://www.aoyiduo.com
6 | *
7 | * this file is used under the terms of the GPLv3[GNU GENERAL PUBLIC LICENSE v3]
8 | * more information follow the website: https://www.gnu.org/licenses/gpl-3.0.en.html
9 | *
10 | *******************************************************************************************/
11 |
12 | #ifndef QKXFTPSERVERPRIVATE_H
13 | #define QKXFTPSERVERPRIVATE_H
14 |
15 | #include