Skip to content

Commit

Permalink
KangLin/tigervnc fd32c28515c83ec3db6b812f2ee8f5fbbcf29b33
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Sep 27, 2024
1 parent adbdc10 commit 00c117c
Show file tree
Hide file tree
Showing 100 changed files with 656 additions and 491 deletions.
4 changes: 4 additions & 0 deletions common/os/Mutex.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifdef WIN32
#include <windows.h>
#else
Expand Down
10 changes: 10 additions & 0 deletions common/os/Thread.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifdef WIN32
#include <windows.h>
#else
Expand Down Expand Up @@ -46,6 +50,12 @@ Thread::~Thread()
{
#ifdef WIN32
delete (HANDLE*)threadId;
#elif ANDROID
if (isRunning()) {
// See: https://github.com/Hax4us/Hax4us.github.io/blob/master/Pthread_patches/Bpthread.h
pthread_kill(*(pthread_t*)threadId, SIGUSR1);
}
delete (pthread_t*)threadId;
#else
if (isRunning())
pthread_cancel(*(pthread_t*)threadId);
Expand Down
1 change: 0 additions & 1 deletion common/rdr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ set(RDR_HEADS
${CMAKE_CURRENT_SOURCE_DIR}/TLSOutStream.h
${CMAKE_CURRENT_SOURCE_DIR}/ZlibInStream.h
${CMAKE_CURRENT_SOURCE_DIR}/ZlibOutStream.h
${CMAKE_CURRENT_SOURCE_DIR}/types.h
)

set(RDR_LIBRARIES ${ZLIB_LIBRARIES})
Expand Down
1 change: 0 additions & 1 deletion common/rdr/FdOutStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include <sys/select.h>
#endif

#include <os/os.h>
#include <rdr/FdOutStream.h>
#include <rdr/Exception.h>
#include <rfb/util.h>
Expand Down
4 changes: 4 additions & 0 deletions common/rdr/FileInStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <errno.h>

#include <rdr/Exception.h>
Expand Down
9 changes: 6 additions & 3 deletions common/rdr/HexInStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <algorithm>
#include <rdr/HexInStream.h>
#include <rdr/Exception.h>
#include <rfb/util.h>
#include <algorithm>

using namespace rdr;

Expand All @@ -32,11 +36,10 @@ HexInStream::HexInStream(InStream& is)
HexInStream::~HexInStream() {
}


bool HexInStream::fillBuffer() {
if (!in_stream.hasData(2))
return false;

size_t length = std::min(in_stream.avail()/2, availSpace());
const uint8_t* iptr = in_stream.getptr(length*2);

Expand Down
6 changes: 2 additions & 4 deletions common/rdr/HexOutStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <algorithm>
#include <rdr/HexOutStream.h>
#include <rfb/util.h>
#include <algorithm>

using namespace rdr;

Expand All @@ -40,7 +39,7 @@ bool HexOutStream::flushBuffer()
{
while (sentUpTo != ptr) {
uint8_t* optr = out_stream.getptr(2);
size_t length = std::min(ptr-sentUpTo, (int64_t)out_stream.avail()/2);
size_t length = std::min((size_t)(ptr-sentUpTo), out_stream.avail()/2);

for (size_t i=0; i<length; i++)
rfb::binToHex(&sentUpTo[i], 1, (char*)&optr[i*2], 2);
Expand All @@ -63,4 +62,3 @@ void HexOutStream::cork(bool enable)
BufferedOutStream::cork(enable);
out_stream.cork(enable);
}

4 changes: 4 additions & 0 deletions common/rdr/RandomStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <rdr/RandomStream.h>
#include <rdr/Exception.h>
#include <rfb/LogWriter.h>
Expand Down
3 changes: 1 addition & 2 deletions common/rdr/RandomStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
#include <stdio.h>
#include <rdr/BufferedInStream.h>

#include <os/os.h>

#ifdef WIN32
#include <windows.h>
#include <wincrypt.h>
#ifdef WINCRYPT32API
#define RFB_HAVE_WINCRYPT
Expand Down
4 changes: 4 additions & 0 deletions common/rdr/ZlibInStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <assert.h>

#include <rdr/ZlibInStream.h>
Expand Down
77 changes: 0 additions & 77 deletions common/rdr/types.h

This file was deleted.

5 changes: 5 additions & 0 deletions common/rfb/Blacklist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <rfb/Blacklist.h>
#include <rfb/Configuration.h>

Expand Down
7 changes: 6 additions & 1 deletion common/rfb/CConnection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <assert.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -327,7 +332,7 @@ bool CConnection::processSecurityResultMsg()

if (server.beforeVersion(3,8)) {
state_ = RFBSTATE_INVALID;
throw AuthFailureException();
throw AuthFailureException("Authentication failed");
}

state_ = RFBSTATE_SECURITY_REASON;
Expand Down
42 changes: 31 additions & 11 deletions common/rfb/CConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ namespace rfb {
class CSecurity;
class IdentityVerifier;

enum class MsgBoxFlags{
M_OK = 0,
M_OKCANCEL = 1,
M_YESNO = 4,
M_ICONERROR = 0x10,
M_ICONQUESTION = 0x20,
M_ICONWARNING = 0x30,
M_ICONINFORMATION = 0x40,
M_DEFBUTTON1 = 0,
M_DEFBUTTON2 = 0x100
};

class CConnection : public CMsgHandler {
public:

Expand Down Expand Up @@ -75,16 +87,11 @@ namespace rfb {
// there is data to read on the InStream.
void initialiseProtocol();

// processMsg() should be called whenever there is either:
// - data available on the underlying network stream
// In this case, processMsg may return without processing an RFB message,
// if the available data does not result in an RFB message being ready
// to handle. e.g. if data is encrypted.
// NB: This makes it safe to call processMsg() in response to select()
// - data available on the CConnection's current InStream
// In this case, processMsg should always process the available RFB
// message before returning.
// NB: In either case, you must have called initialiseProtocol() first.
// processMsg() should be called whenever there is data available on
// the CConnection's current InStream. It will process at most one
// RFB message before returning. If there was insufficient data,
// then it will return false and should be called again once more
// data is available.
bool processMsg();

// close() gracefully shuts down the connection to the server and
Expand Down Expand Up @@ -126,7 +133,20 @@ namespace rfb {


// Methods to be overridden in a derived class


// getUserPasswd gets the username and password. This might involve a
// dialog, getpass(), etc. The user buffer pointer can be null, in which
// case no user name will be retrieved.
virtual void getUserPasswd(bool secure, std::string* user,
std::string* password) = 0;
/*!
* Get x509 authentication CA and CRL file, the file format is pem.
* \param ca: certificate authority, the file format is pem.
* \param crl: certificate revocation list, the file format is pem.
*/
virtual int getX509File(std::string* ca, std::string* crl) = 0;
virtual bool showMsgBox(MsgBoxFlags flags, const char *title, const char *text) = 0;

// authSuccess() is called when authentication has succeeded.
virtual void authSuccess();

Expand Down
12 changes: 6 additions & 6 deletions common/rfb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ set(RFB_HEADS ${RFB_HEADS}
${CMAKE_CURRENT_SOURCE_DIR}/Exception.h
${CMAKE_CURRENT_SOURCE_DIR}/Hostname.h
${CMAKE_CURRENT_SOURCE_DIR}/UserMsgBox.h
${CMAKE_CURRENT_SOURCE_DIR}/InputHandler.h
${CMAKE_CURRENT_SOURCE_DIR}/obfuscate.h
)

Expand All @@ -183,7 +182,7 @@ endif(WIN32)

set(RFB_LIBRARIES ${JPEG_LIBRARIES} ${PIXMAN_LIBRARY})

if(UNIX AND NOT APPLE)
if(UNIX AND NOT APPLE AND NOT ANDROID)
list(APPEND RFB_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/UnixPasswordValidator.cxx)
list(APPEND RFB_HEADS
Expand Down Expand Up @@ -232,19 +231,20 @@ if(ENABLE_H264 AND NOT H264_LIBS STREQUAL "NONE")
${CMAKE_CURRENT_SOURCE_DIR}/H264WinDecoderContext.cxx)
endif()
endif()
set(RabbitVNC_INCLUDE_DIR ${RabbitVNC_INCLUDE_DIR}

set(TIGERVNC_INCLUDE_DIR ${TIGERVNC_INCLUDE_DIR}
${RFB_INCLUDE_DIR}
PARENT_SCOPE)

set(RabbitVNC_SOURCES ${RabbitVNC_SOURCES}
set(TIGERVNC_SOURCES ${TIGERVNC_SOURCES}
${RFB_SOURCES}
PARENT_SCOPE)

set(RabbitVNC_HEADS ${RabbitVNC_HEADS}
set(TIGERVNC_HEADS ${TIGERVNC_HEADS}
${RFB_HEADS}
PARENT_SCOPE)

set(RabbitVNC_LIBS ${RabbitVNC_LIBS}
set(TIGERVNC_LIBS ${TIGERVNC_LIBS}
${RFB_LIBRARIES}
PARENT_SCOPE)

Expand Down
10 changes: 5 additions & 5 deletions common/rfb/CMsgHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>

#include <rfb/Exception.h>
Expand Down Expand Up @@ -54,11 +59,6 @@ void CMsgHandler::setExtendedDesktopSize(unsigned reason, unsigned result,
server.setDimensions(width, height, layout);
}

void CMsgHandler::setPixelFormat(const PixelFormat& pf)
{
server.setPF(pf);
}

void CMsgHandler::setName(const char* name)
{
server.setName(name);
Expand Down
Loading

0 comments on commit 00c117c

Please sign in to comment.