tigervnc/winvnc/VNCServerWin32.h
Constantin Kaplinsky 47ed8d321c Initial revision
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2 3789f03b-4d11-0410-bbf8-ca57d06f2519
2004-10-08 09:43:57 +00:00

100 lines
3.1 KiB
C++

/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#ifndef __VNCSERVER_WIN32_H__
#define __VNCSERVER_WIN32_H__
#include <winsock2.h>
#include <network/TcpSocket.h>
#include <rfb/VNCServerST.h>
#include <rfb_win32/RegConfig.h>
#include <rfb_win32/SDisplay.h>
#include <rfb_win32/SocketManager.h>
#include <rfb_win32/TCharArray.h>
#include <winvnc/QueryConnectDialog.h>
#include <winvnc/JavaViewer.h>
namespace winvnc {
class VNCServerWin32 : rfb::VNCServerST::QueryConnectionHandler {
public:
VNCServerWin32();
virtual ~VNCServerWin32();
// Run the server in the current thread
int run();
// Cause the run() call to return
// THREAD-SAFE
void stop();
// Determine whether a viewer is active
// THREAD-SAFE
bool isServerInUse() const {return isDesktopStarted;}
// Connect out to the specified VNC Viewer
// THREAD-SAFE
bool addNewClient(const char* client);
// Disconnect all connected clients
// THREAD-SAFE
bool disconnectClients(const char* reason=0);
// Call used to notify VNCServerST of user accept/reject query completion
// CALLED FROM AcceptConnectDialog THREAD
void queryConnectionComplete();
// Overridden VNCServerST::QueryConnectionHandler callback,
// used to prompt user to accept or reject a connection.
// CALLBACK IN VNCServerST "HOST" THREAD
virtual rfb::VNCServerST::queryResult queryConnection(network::Socket* sock,
const char* userName,
char** reason);
// Where to read the configuration settings from
static const TCHAR* RegConfigPath;
protected:
// Perform a particular internal function in the server thread
typedef enum {NoCommand, DisconnectClients, AddClient, QueryConnectionComplete} Command;
bool queueCommand(Command cmd, const void* data, int len);
void doCommand();
Command command;
const void* commandData;
int commandDataLen;
rfb::Mutex commandLock;
rfb::Condition commandSig;
// VNCServerWin32 Server-internal state
rfb::win32::SDisplay desktop;
rfb::VNCServerST vncServer;
rfb::Mutex runLock;
rfb::Thread* hostThread;
bool runServer;
bool isDesktopStarted;
JavaViewerServer* httpServer;
rfb::win32::RegistryReader config;
rfb::win32::SocketManager sockMgr;
QueryConnectDialog* queryConnectDialog;
};
};
#endif